]> zoso.dev Git - libnemo.git/commitdiff
Start testing new tweetnacl rewrite in Account.
authorChris Duncan <chris@zoso.dev>
Sat, 23 Nov 2024 09:48:11 +0000 (01:48 -0800)
committerChris Duncan <chris@zoso.dev>
Sat, 23 Nov 2024 09:48:11 +0000 (01:48 -0800)
src/lib/account.ts

index 1f54c92b166ca5208996603c5a6a3a469ae6b1a4..3e9be666b4c6dfb4debe98e7e258d4d1dab330b1 100644 (file)
@@ -4,7 +4,7 @@
 import blake2b from 'blake2b'\r
 import { ACCOUNT_KEY_LENGTH, ALPHABET, PREFIX, PREFIX_LEGACY } from './constants.js'\r
 import { base32, bytes, hex } from './convert.js'\r
-import Ed25519 from './ed25519.js'\r
+import { keyPair, secretKeyLength } from './workers/nano25519.js'\r
 import { Rpc } from './rpc.js'\r
 import { Safe } from './safe.js'\r
 \r
@@ -87,8 +87,8 @@ export class Account {
        */\r
        static async fromPrivateKey (key: string, index?: number): Promise<Account> {\r
                Account.#validateKey(key)\r
-               const publicKey = Ed25519.getPublicKey(key)\r
-               const account = await Account.fromPublicKey(publicKey, index)\r
+               const { publicKey } = keyPair.fromSecretKey(hex.toBytes(key))\r
+               const account = await Account.fromPublicKey(bytes.toHex(publicKey), index)\r
                account.#prv = key.toUpperCase()\r
                return account\r
        }\r