]> zoso.dev Git - libnemo.git/commitdiff
Attach export keyword directly to applicable functions and adjust property chain...
authorChris Duncan <chris@zoso.dev>
Mon, 25 Nov 2024 05:49:37 +0000 (21:49 -0800)
committerChris Duncan <chris@zoso.dev>
Mon, 25 Nov 2024 05:49:37 +0000 (21:49 -0800)
src/lib/account.ts
src/lib/tools.ts
src/lib/workers/nano25519.ts

index a98a5be9eb8c8f834d562b46cd3dd1670c3deee7..ffc2f38635913324512cea56e24c3b83748ba913 100644 (file)
@@ -87,7 +87,7 @@ export class Account {
        */\r
        static async fromPrivateKey (key: string, index?: number): Promise<Account> {\r
                Account.#validateKey(key)\r
-               const { publicKey } = Ed25519.sign.keyPair.fromSeed(hex.toBytes(key))\r
+               const { publicKey } = Ed25519.keyPair.fromSeed(hex.toBytes(key))\r
                const account = await Account.fromPublicKey(bytes.toHex(publicKey), index)\r
                account.#prv = key.toUpperCase()\r
                return account\r
index c6bdbe27ab814e22597ba4a672b68c0814f0fa86..510eb11fd5dfa53547cb6f40c20b9505cd5cfb1b 100644 (file)
@@ -160,8 +160,8 @@ export async function verify (key: string, signature: string, ...input: string[]
        const data = await hash(input)
        return Ed25519.verify(
                hex.toBytes(data),
-               hex.toBytes(key),
-               hex.toBytes(signature))
+               hex.toBytes(signature),
+               hex.toBytes(key))
 }
 
 export default { convert, hash, sign, sweep, verify }
index 37dbcb95e70e83f71f89170bb4c6948b6f5d4a98..aa6aa919c2d4a40f4694c069c7fcb32172407c2f 100644 (file)
@@ -2182,7 +2182,7 @@ import blake2b from 'blake2b'
                for (var i = 0; i < arr.length; i++) arr[i] = 0;\r
        }\r
 \r
-       const sign = function(msg, secretKey) {\r
+       export const sign = function(msg, secretKey) {\r
                        checkArrayTypes(msg, secretKey);\r
                        if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\r
                                throw new Error('bad secret key size');\r
@@ -2191,7 +2191,7 @@ import blake2b from 'blake2b'
                        return signedMsg;\r
        };\r
 \r
-       sign.open = function(signedMsg, publicKey) {\r
+       export const open = function(signedMsg, publicKey) {\r
                        checkArrayTypes(signedMsg, publicKey);\r
                        if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\r
                                throw new Error('bad public key size');\r
@@ -2203,14 +2203,14 @@ import blake2b from 'blake2b'
                        return m;\r
        };\r
 \r
-       sign.detached = function(msg, secretKey) {\r
+       export const detached = function(msg, secretKey) {\r
                        var signedMsg = sign(msg, secretKey);\r
                        var sig = new Uint8Array(crypto_sign_BYTES);\r
                        for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\r
                        return sig;\r
        };\r
 \r
-       sign.detached.verify = function(msg, sig, publicKey) {\r
+       export const verify = function(msg, sig, publicKey) {\r
                        checkArrayTypes(msg, sig, publicKey);\r
                        if (sig.length !== crypto_sign_BYTES)\r
                                throw new Error('bad signature size');\r
@@ -2224,14 +2224,14 @@ import blake2b from 'blake2b'
                        return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\r
        };\r
 \r
-       sign.keyPair = function() {\r
+       export const keyPair = function() {\r
                        var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\r
                        var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\r
                        crypto_sign_keypair(pk, sk);\r
                        return {publicKey: pk, secretKey: sk};\r
        };\r
 \r
-       sign.keyPair.fromSecretKey = function(secretKey) {\r
+       keyPair.fromSecretKey = function(secretKey) {\r
                        checkArrayTypes(secretKey);\r
                        if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\r
                        throw new Error('bad secret key size');\r
@@ -2240,7 +2240,7 @@ import blake2b from 'blake2b'
                        return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\r
        };\r
 \r
-       sign.keyPair.fromSeed = function(seed) {\r
+       keyPair.fromSeed = function(seed) {\r
                        checkArrayTypes(seed);\r
                        if (seed.length !== crypto_sign_SEEDBYTES)\r
                                throw new Error('bad seed size');\r
@@ -2251,10 +2251,10 @@ import blake2b from 'blake2b'
                        return {publicKey: pk, secretKey: sk};\r
        };\r
 \r
-       sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\r
-       sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\r
-       sign.seedLength = crypto_sign_SEEDBYTES;\r
-       sign.signatureLength = crypto_sign_BYTES;\r
+       export const publicKeyLength = crypto_sign_PUBLICKEYBYTES;\r
+       export const secretKeyLength = crypto_sign_SECRETKEYBYTES;\r
+       export const seedLength = crypto_sign_SEEDBYTES;\r
+       export const signatureLength = crypto_sign_BYTES;\r
 \r
        const setPRNG = function(fn) {\r
                randombytes = fn;\r
@@ -2287,5 +2287,3 @@ import blake2b from 'blake2b'
                        }\r
                }\r
        })();\r
-\r
-       export { sign }\r