mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-06-17 21:51:08 +00:00
Fix Polkadot identicon blake2 (#103)
* Fix Polkadot identicon blake2 * CHANGELOG
This commit is contained in:
@@ -24,8 +24,8 @@
|
||||
"react": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^0.40.1",
|
||||
"@polkadot/util-crypto": "^0.40.1",
|
||||
"@polkadot/keyring": "^0.42.0-beta.1",
|
||||
"@polkadot/util-crypto": "^0.42.0-beta.1",
|
||||
"xmlserializer": "^0.6.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,14 @@ type Scheme = {
|
||||
colors: Array<number>
|
||||
};
|
||||
|
||||
const blake2 = (value: Uint8Array) =>
|
||||
blake2AsU8a(value, 512);
|
||||
|
||||
const s = 64;
|
||||
const c = s / 2;
|
||||
const z = s / 64 * 5;
|
||||
|
||||
const zero = blake2AsU8a(new Uint8Array(32));
|
||||
const zero = blake2(new Uint8Array(32));
|
||||
const schema: { [index: string]: Scheme } = {
|
||||
target: { freq: 1, colors: [0, 28, 0, 0, 28, 0, 0, 28, 0, 0, 28, 0, 0, 28, 0, 0, 28, 0, 1] },
|
||||
cube: { freq: 20, colors: [0, 1, 3, 2, 4, 3, 0, 1, 3, 2, 4, 3, 0, 1, 3, 2, 4, 3, 5] },
|
||||
@@ -130,7 +133,7 @@ export default class Identicon extends React.PureComponent<Props> {
|
||||
private getColors () {
|
||||
const { value } = this.props;
|
||||
const total = Object.keys(schema).map(k => schema[k].freq).reduce((a, b) => a + b);
|
||||
const id = Array.from(blake2AsU8a(decodeAddress(value))).map((x, i) => (x + 256 - zero[i]) % 256);
|
||||
const id = Array.from(blake2(decodeAddress(value))).map((x, i) => (x + 256 - zero[i]) % 256);
|
||||
const d = Math.floor((id[30] + id[31] * 256) % total);
|
||||
const rot = (id[28] % 6) * 3;
|
||||
const sat = (Math.floor(id[29] * 70 / 256 + 26) % 80) + 30;
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
"styled-components": "^4.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^0.40.1",
|
||||
"@polkadot/types": "^0.50.1",
|
||||
"@polkadot/util": "^0.40.1"
|
||||
"@polkadot/keyring": "^0.42.0-beta.1",
|
||||
"@polkadot/types": "^0.52.0-beta.1",
|
||||
"@polkadot/util": "^0.42.0-beta.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/keyring": "*",
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.3.4",
|
||||
"@polkadot/util": "^0.40.1",
|
||||
"@polkadot/util": "^0.42.0-beta.1",
|
||||
"@types/store": "^2.0.1",
|
||||
"store": "^2.0.12"
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"@babel/runtime": "^7.3.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/types": "^0.50.1"
|
||||
"@polkadot/types": "^0.52.0-beta.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/types": "*"
|
||||
|
||||
Reference in New Issue
Block a user