### In web
```html
-<script src="https://unpkg.com/nanocurrency-web@1.3.3" type="text/javascript"></script>
+<script src="https://unpkg.com/nanocurrency-web@1.3.5" type="text/javascript"></script>
<script type="text/javascript">
NanocurrencyWeb.wallet.generate(...);
</script>
return Convert.ab2hex(publicKeyBytes).slice(0, 64)
},
+ /**
+ * Convert a public key to a Nano address
+ *
+ * @param {string} input Public key to convert
+ * @returns {string} the nano address
+ */
+ publicKeyToAddress: (input: string): string => {
+ return nanoAddress.deriveAddress(input)
+ },
+
+ /**
+ * Hash a string or array of strings with blake2b
+ *
+ * @param {string | string[]} input string to hash
+ * @returns {string} hashed string
+ */
+ blake2b: (input: string | string[]): string => {
+ if (Array.isArray(input)) {
+ return Convert.ab2hex(signer.generateHash(input.map(Convert.stringToHex)))
+ } else {
+ return Convert.ab2hex(signer.generateHash([Convert.stringToHex(input)]))
+ }
+ },
+
}
export {
{
"name": "nanocurrency-web",
- "version": "1.3.4",
+ "version": "1.3.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
{
"name": "nanocurrency-web",
- "version": "1.3.4",
+ "version": "1.3.5",
"description": "Toolkit for Nano cryptocurrency client side offline integrations",
"author": "Miro Metsänheimo <miro@metsanheimo.fi>",
"license": "MIT",
expect(publicKey).to.equal('5b65b0e8173ee0802c2c3e6c9080d1a16b06de1176c938a924f58670904e82c4')
})
+ it('should convert a public key to a Nano address', () => {
+ const address = tools.publicKeyToAddress('5b65b0e8173ee0802c2c3e6c9080d1a16b06de1176c938a924f58670904e82c4')
+ expect(address).to.equal('nano_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d')
+ })
+
+ it('should create a blake2b hash', () => {
+ let hash = tools.blake2b('asd')
+ expect(hash).to.equal('f787fbcdd2b4c6f6447921d6f163e8fddfb83d08432430cacaaab1bbedd723fe')
+
+ hash = tools.blake2b(['asd'])
+ expect(hash).to.equal('f787fbcdd2b4c6f6447921d6f163e8fddfb83d08432430cacaaab1bbedd723fe')
+ })
+
})