@haneullabs/haneul 2.5.1 → 2.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/cryptography/publickey.d.mts +1 -1
  2. package/dist/cryptography/publickey.d.mts.map +1 -1
  3. package/dist/cryptography/publickey.mjs +3 -3
  4. package/dist/cryptography/publickey.mjs.map +1 -1
  5. package/dist/grpc/proto/haneul/rpc/v2/signature_verification_service.client.d.mts +4 -4
  6. package/dist/grpc/proto/haneul/rpc/v2/state_service.client.d.mts +4 -4
  7. package/dist/grpc/proto/haneul/rpc/v2/transaction.d.mts.map +1 -1
  8. package/dist/multisig/publickey.mjs +1 -1
  9. package/dist/multisig/publickey.mjs.map +1 -1
  10. package/dist/transactions/Transaction.d.mts +6 -6
  11. package/dist/transactions/data/internal.d.mts +109 -109
  12. package/dist/transactions/data/internal.d.mts.map +1 -1
  13. package/dist/transactions/data/v1.d.mts +220 -220
  14. package/dist/transactions/data/v1.d.mts.map +1 -1
  15. package/dist/transactions/data/v2.d.mts +16 -16
  16. package/dist/transactions/data/v2.d.mts.map +1 -1
  17. package/dist/verify/index.d.mts +2 -2
  18. package/dist/verify/index.mjs +2 -2
  19. package/dist/verify/verify.d.mts +2 -2
  20. package/dist/verify/verify.d.mts.map +1 -1
  21. package/dist/verify/verify.mjs +2 -2
  22. package/dist/verify/verify.mjs.map +1 -1
  23. package/dist/version.mjs +1 -1
  24. package/dist/version.mjs.map +1 -1
  25. package/dist/zklogin/nonce.mjs +1 -1
  26. package/dist/zklogin/nonce.mjs.map +1 -1
  27. package/package.json +1 -1
  28. package/src/cryptography/publickey.ts +3 -3
  29. package/src/multisig/publickey.ts +1 -1
  30. package/src/verify/index.ts +1 -1
  31. package/src/verify/verify.ts +1 -1
  32. package/src/version.ts +1 -1
  33. package/src/zklogin/nonce.ts +1 -1
@@ -19,10 +19,10 @@ declare function publicKeyFromRawBytes(signatureScheme: SignatureScheme, bytes:
19
19
  client?: ClientWithCoreApi;
20
20
  address?: string;
21
21
  }): PublicKey;
22
- declare function publicKeyFromSuiBytes(publicKey: string | Uint8Array, options?: {
22
+ declare function publicKeyFromHaneulBytes(publicKey: string | Uint8Array, options?: {
23
23
  client?: ClientWithCoreApi;
24
24
  address?: string;
25
25
  }): PublicKey;
26
26
  //#endregion
27
- export { publicKeyFromRawBytes, publicKeyFromSuiBytes, verifyPersonalMessageSignature, verifySignature, verifyTransactionSignature };
27
+ export { publicKeyFromHaneulBytes, publicKeyFromRawBytes, verifyPersonalMessageSignature, verifySignature, verifyTransactionSignature };
28
28
  //# sourceMappingURL=verify.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"verify.d.mts","names":[],"sources":["../../src/verify/verify.ts"],"sourcesContent":[],"mappings":";;;;;;iBAesB,eAAA,QACd;;IAKL,QAAQ;iBAcW,8BAAA,UACZ,sCAfC;EANW,MAAA,CAAA,EAuBD,iBAvBgB;EAC7B,OAAA,CAAA,EAAA,MAAA;CAKG,CAAA,EAkBR,OAlBQ,CAkBA,SAlBA,CAAA;AAAR,iBAqCmB,0BAAA,CArCnB,WAAA,EAsCW,UAtCX,EAAA,SAAA,EAAA,MAAA,EAAA,OAeO,CAfP,EAAA;EAAO,MAAA,CAAA,EAwCW,iBAxCX;EAcY,OAAA,CAAA,EAAA,MAAA;CACZ,CAAA,EA0BP,OA1BO,CA0BC,SA1BD,CAAA;AAEW,iBAgEL,qBAAA,CAhEK,eAAA,EAiEH,eAjEG,EAAA,KAAA,EAkEb,UAlEa,EAAA,OACX,CADW,EAAA;EACV,MAAA,CAAA,EAkEU,iBAlEV;EAAR,OAAA,CAAA,EAAA,MAAA;CAAO,CAAA,EAmEP,SAnEO;AAmBY,iBAgFN,qBAAA,CAhFgC,SAAA,EAAA,MAAA,GAiF3B,UAjF2B,EAAA,OAIrC,CAJqC,EAAA;EAClC,MAAA,CAAA,EAiFO,iBAjFP;EAEO,OAAA,CAAA,EAAA,MAAA;CACV,CAAA,EA8EoD,SA9EpD"}
1
+ {"version":3,"file":"verify.d.mts","names":[],"sources":["../../src/verify/verify.ts"],"sourcesContent":[],"mappings":";;;;;;iBAesB,eAAA,QACd;;IAKL,QAAQ;iBAcW,8BAAA,UACZ,sCAfC;EANW,MAAA,CAAA,EAuBD,iBAvBgB;EAC7B,OAAA,CAAA,EAAA,MAAA;CAKG,CAAA,EAkBR,OAlBQ,CAkBA,SAlBA,CAAA;AAAR,iBAqCmB,0BAAA,CArCnB,WAAA,EAsCW,UAtCX,EAAA,SAAA,EAAA,MAAA,EAAA,OAeO,CAfP,EAAA;EAAO,MAAA,CAAA,EAwCW,iBAxCX;EAcY,OAAA,CAAA,EAAA,MAAA;CACZ,CAAA,EA0BP,OA1BO,CA0BC,SA1BD,CAAA;AAEW,iBAgEL,qBAAA,CAhEK,eAAA,EAiEH,eAjEG,EAAA,KAAA,EAkEb,UAlEa,EAAA,OACX,CADW,EAAA;EACV,MAAA,CAAA,EAkEU,iBAlEV;EAAR,OAAA,CAAA,EAAA,MAAA;CAAO,CAAA,EAmEP,SAnEO;AAmBY,iBAgFN,wBAAA,CAhFgC,SAAA,EAAA,MAAA,GAiF3B,UAjF2B,EAAA,OAIrC,CAJqC,EAAA;EAClC,MAAA,CAAA,EAiFO,iBAjFP;EAEO,OAAA,CAAA,EAAA,MAAA;CACV,CAAA,EA8EoD,SA9EpD"}
@@ -65,12 +65,12 @@ function publicKeyFromRawBytes(signatureScheme, bytes, options = {}) {
65
65
  if (options.address && publicKey.toHaneulAddress() !== options.address) throw new Error(`Public key bytes do not match the provided address`);
66
66
  return publicKey;
67
67
  }
68
- function publicKeyFromSuiBytes(publicKey, options = {}) {
68
+ function publicKeyFromHaneulBytes(publicKey, options = {}) {
69
69
  const bytes = typeof publicKey === "string" ? fromBase64(publicKey) : publicKey;
70
70
  const signatureScheme = SIGNATURE_FLAG_TO_SCHEME[bytes[0]];
71
71
  return publicKeyFromRawBytes(signatureScheme, bytes.slice(1), options);
72
72
  }
73
73
 
74
74
  //#endregion
75
- export { publicKeyFromRawBytes, publicKeyFromSuiBytes, verifyPersonalMessageSignature, verifySignature, verifyTransactionSignature };
75
+ export { publicKeyFromHaneulBytes, publicKeyFromRawBytes, verifyPersonalMessageSignature, verifySignature, verifyTransactionSignature };
76
76
  //# sourceMappingURL=verify.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"verify.mjs","names":[],"sources":["../../src/verify/verify.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64 } from '@haneullabs/bcs';\n\nimport type { PublicKey, SignatureFlag, SignatureScheme } from '../cryptography/index.js';\nimport { parseSerializedSignature, SIGNATURE_FLAG_TO_SCHEME } from '../cryptography/index.js';\nimport { Ed25519PublicKey } from '../keypairs/ed25519/publickey.js';\nimport { PasskeyPublicKey } from '../keypairs/passkey/publickey.js';\nimport { Secp256k1PublicKey } from '../keypairs/secp256k1/publickey.js';\nimport { Secp256r1PublicKey } from '../keypairs/secp256r1/publickey.js';\nimport { MultiSigPublicKey } from '../multisig/publickey.js';\nimport { ZkLoginPublicIdentifier } from '../zklogin/publickey.js';\nimport type { ClientWithCoreApi } from '../client/core.js';\n\nexport async function verifySignature(\n\tbytes: Uint8Array,\n\tsignature: string,\n\toptions?: {\n\t\taddress?: string;\n\t},\n): Promise<PublicKey> {\n\tconst parsedSignature = parseSignature(signature);\n\n\tif (!(await parsedSignature.publicKey.verify(bytes, parsedSignature.serializedSignature))) {\n\t\tthrow new Error(`Signature is not valid for the provided data`);\n\t}\n\n\tif (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\n\treturn parsedSignature.publicKey;\n}\n\nexport async function verifyPersonalMessageSignature(\n\tmessage: Uint8Array,\n\tsignature: string,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): Promise<PublicKey> {\n\tconst parsedSignature = parseSignature(signature, options);\n\n\tif (\n\t\t!(await parsedSignature.publicKey.verifyPersonalMessage(\n\t\t\tmessage,\n\t\t\tparsedSignature.serializedSignature,\n\t\t))\n\t) {\n\t\tthrow new Error(`Signature is not valid for the provided message`);\n\t}\n\n\tif (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\n\treturn parsedSignature.publicKey;\n}\n\nexport async function verifyTransactionSignature(\n\ttransaction: Uint8Array,\n\tsignature: string,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): Promise<PublicKey> {\n\tconst parsedSignature = parseSignature(signature, options);\n\n\tif (\n\t\t!(await parsedSignature.publicKey.verifyTransaction(\n\t\t\ttransaction,\n\t\t\tparsedSignature.serializedSignature,\n\t\t))\n\t) {\n\t\tthrow new Error(`Signature is not valid for the provided Transaction`);\n\t}\n\n\tif (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\n\treturn parsedSignature.publicKey;\n}\n\nfunction parseSignature(signature: string, options: { client?: ClientWithCoreApi } = {}) {\n\tconst parsedSignature = parseSerializedSignature(signature);\n\n\tif (parsedSignature.signatureScheme === 'MultiSig') {\n\t\treturn {\n\t\t\t...parsedSignature,\n\t\t\tpublicKey: new MultiSigPublicKey(parsedSignature.multisig.multisig_pk),\n\t\t};\n\t}\n\n\tconst publicKey = publicKeyFromRawBytes(\n\t\tparsedSignature.signatureScheme,\n\t\tparsedSignature.publicKey,\n\t\toptions,\n\t);\n\treturn {\n\t\t...parsedSignature,\n\t\tpublicKey,\n\t};\n}\n\nexport function publicKeyFromRawBytes(\n\tsignatureScheme: SignatureScheme,\n\tbytes: Uint8Array,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): PublicKey {\n\tlet publicKey: PublicKey;\n\tswitch (signatureScheme) {\n\t\tcase 'ED25519':\n\t\t\tpublicKey = new Ed25519PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'Secp256k1':\n\t\t\tpublicKey = new Secp256k1PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'Secp256r1':\n\t\t\tpublicKey = new Secp256r1PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'MultiSig':\n\t\t\tpublicKey = new MultiSigPublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'ZkLogin':\n\t\t\tpublicKey = ZkLoginPublicIdentifier.fromBytes(bytes, options);\n\t\t\tbreak;\n\t\tcase 'Passkey':\n\t\t\tpublicKey = new PasskeyPublicKey(bytes);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported signature scheme ${signatureScheme}`);\n\t}\n\n\tif (options.address && publicKey.toHaneulAddress() !== options.address) {\n\t\tthrow new Error(`Public key bytes do not match the provided address`);\n\t}\n\n\treturn publicKey;\n}\n\nexport function publicKeyFromSuiBytes(\n\tpublicKey: string | Uint8Array,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n) {\n\tconst bytes = typeof publicKey === 'string' ? fromBase64(publicKey) : publicKey;\n\n\tconst signatureScheme = SIGNATURE_FLAG_TO_SCHEME[bytes[0] as SignatureFlag];\n\n\treturn publicKeyFromRawBytes(signatureScheme, bytes.slice(1), options);\n}\n"],"mappings":";;;;;;;;;;;AAeA,eAAsB,gBACrB,OACA,WACA,SAGqB;CACrB,MAAM,kBAAkB,eAAe,UAAU;AAEjD,KAAI,CAAE,MAAM,gBAAgB,UAAU,OAAO,OAAO,gBAAgB,oBAAoB,CACvF,OAAM,IAAI,MAAM,+CAA+C;AAGhE,KAAI,SAAS,WAAW,CAAC,gBAAgB,UAAU,cAAc,QAAQ,QAAQ,CAChF,OAAM,IAAI,MAAM,kDAAkD;AAGnE,QAAO,gBAAgB;;AAGxB,eAAsB,+BACrB,SACA,WACA,UAA4D,EAAE,EACzC;CACrB,MAAM,kBAAkB,eAAe,WAAW,QAAQ;AAE1D,KACC,CAAE,MAAM,gBAAgB,UAAU,sBACjC,SACA,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K,QAAQ,QAC9D,OAAM,IAAI,MAAM,qDAAqD;AAGtE,QAAO;;AAGR,SAAgB,sBACf,WACA,UAA4D,EAAE,EAC7D;CACD,MAAM,QAAQ,OAAO,cAAc,WAAW,WAAW,UAAU,GAAG;CAEtE,MAAM,kBAAkB,yBAAyB,MAAM;AAEvD,QAAO,sBAAsB,iBAAiB,MAAM,MAAM,EAAE,EAAE,QAAQ"}
1
+ {"version":3,"file":"verify.mjs","names":[],"sources":["../../src/verify/verify.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64 } from '@haneullabs/bcs';\n\nimport type { PublicKey, SignatureFlag, SignatureScheme } from '../cryptography/index.js';\nimport { parseSerializedSignature, SIGNATURE_FLAG_TO_SCHEME } from '../cryptography/index.js';\nimport { Ed25519PublicKey } from '../keypairs/ed25519/publickey.js';\nimport { PasskeyPublicKey } from '../keypairs/passkey/publickey.js';\nimport { Secp256k1PublicKey } from '../keypairs/secp256k1/publickey.js';\nimport { Secp256r1PublicKey } from '../keypairs/secp256r1/publickey.js';\nimport { MultiSigPublicKey } from '../multisig/publickey.js';\nimport { ZkLoginPublicIdentifier } from '../zklogin/publickey.js';\nimport type { ClientWithCoreApi } from '../client/core.js';\n\nexport async function verifySignature(\n\tbytes: Uint8Array,\n\tsignature: string,\n\toptions?: {\n\t\taddress?: string;\n\t},\n): Promise<PublicKey> {\n\tconst parsedSignature = parseSignature(signature);\n\n\tif (!(await parsedSignature.publicKey.verify(bytes, parsedSignature.serializedSignature))) {\n\t\tthrow new Error(`Signature is not valid for the provided data`);\n\t}\n\n\tif (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\n\treturn parsedSignature.publicKey;\n}\n\nexport async function verifyPersonalMessageSignature(\n\tmessage: Uint8Array,\n\tsignature: string,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): Promise<PublicKey> {\n\tconst parsedSignature = parseSignature(signature, options);\n\n\tif (\n\t\t!(await parsedSignature.publicKey.verifyPersonalMessage(\n\t\t\tmessage,\n\t\t\tparsedSignature.serializedSignature,\n\t\t))\n\t) {\n\t\tthrow new Error(`Signature is not valid for the provided message`);\n\t}\n\n\tif (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\n\treturn parsedSignature.publicKey;\n}\n\nexport async function verifyTransactionSignature(\n\ttransaction: Uint8Array,\n\tsignature: string,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): Promise<PublicKey> {\n\tconst parsedSignature = parseSignature(signature, options);\n\n\tif (\n\t\t!(await parsedSignature.publicKey.verifyTransaction(\n\t\t\ttransaction,\n\t\t\tparsedSignature.serializedSignature,\n\t\t))\n\t) {\n\t\tthrow new Error(`Signature is not valid for the provided Transaction`);\n\t}\n\n\tif (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\n\treturn parsedSignature.publicKey;\n}\n\nfunction parseSignature(signature: string, options: { client?: ClientWithCoreApi } = {}) {\n\tconst parsedSignature = parseSerializedSignature(signature);\n\n\tif (parsedSignature.signatureScheme === 'MultiSig') {\n\t\treturn {\n\t\t\t...parsedSignature,\n\t\t\tpublicKey: new MultiSigPublicKey(parsedSignature.multisig.multisig_pk),\n\t\t};\n\t}\n\n\tconst publicKey = publicKeyFromRawBytes(\n\t\tparsedSignature.signatureScheme,\n\t\tparsedSignature.publicKey,\n\t\toptions,\n\t);\n\treturn {\n\t\t...parsedSignature,\n\t\tpublicKey,\n\t};\n}\n\nexport function publicKeyFromRawBytes(\n\tsignatureScheme: SignatureScheme,\n\tbytes: Uint8Array,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): PublicKey {\n\tlet publicKey: PublicKey;\n\tswitch (signatureScheme) {\n\t\tcase 'ED25519':\n\t\t\tpublicKey = new Ed25519PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'Secp256k1':\n\t\t\tpublicKey = new Secp256k1PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'Secp256r1':\n\t\t\tpublicKey = new Secp256r1PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'MultiSig':\n\t\t\tpublicKey = new MultiSigPublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'ZkLogin':\n\t\t\tpublicKey = ZkLoginPublicIdentifier.fromBytes(bytes, options);\n\t\t\tbreak;\n\t\tcase 'Passkey':\n\t\t\tpublicKey = new PasskeyPublicKey(bytes);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported signature scheme ${signatureScheme}`);\n\t}\n\n\tif (options.address && publicKey.toHaneulAddress() !== options.address) {\n\t\tthrow new Error(`Public key bytes do not match the provided address`);\n\t}\n\n\treturn publicKey;\n}\n\nexport function publicKeyFromHaneulBytes(\n\tpublicKey: string | Uint8Array,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n) {\n\tconst bytes = typeof publicKey === 'string' ? fromBase64(publicKey) : publicKey;\n\n\tconst signatureScheme = SIGNATURE_FLAG_TO_SCHEME[bytes[0] as SignatureFlag];\n\n\treturn publicKeyFromRawBytes(signatureScheme, bytes.slice(1), options);\n}\n"],"mappings":";;;;;;;;;;;AAeA,eAAsB,gBACrB,OACA,WACA,SAGqB;CACrB,MAAM,kBAAkB,eAAe,UAAU;AAEjD,KAAI,CAAE,MAAM,gBAAgB,UAAU,OAAO,OAAO,gBAAgB,oBAAoB,CACvF,OAAM,IAAI,MAAM,+CAA+C;AAGhE,KAAI,SAAS,WAAW,CAAC,gBAAgB,UAAU,cAAc,QAAQ,QAAQ,CAChF,OAAM,IAAI,MAAM,kDAAkD;AAGnE,QAAO,gBAAgB;;AAGxB,eAAsB,+BACrB,SACA,WACA,UAA4D,EAAE,EACzC;CACrB,MAAM,kBAAkB,eAAe,WAAW,QAAQ;AAE1D,KACC,C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KAAI,QAAQ,WAAW,UAAU,iBAAiB,KAAK,QAAQ,QAC9D,OAAM,IAAI,MAAM,qDAAqD;AAGtE,QAAO;;AAGR,SAAgB,yBACf,WACA,UAA4D,EAAE,EAC7D;CACD,MAAM,QAAQ,OAAO,cAAc,WAAW,WAAW,UAAU,GAAG;CAEtE,MAAM,kBAAkB,yBAAyB,MAAM;AAEvD,QAAO,sBAAsB,iBAAiB,MAAM,MAAM,EAAE,EAAE,QAAQ"}
package/dist/version.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region src/version.ts
2
- const PACKAGE_VERSION = "2.5.1";
2
+ const PACKAGE_VERSION = "2.5.2";
3
3
  const TARGETED_RPC_VERSION = "1.0.0";
4
4
 
5
5
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// This file is generated by genversion.mjs. Do not edit it directly.\n\nexport const PACKAGE_VERSION = '2.5.1';\nexport const TARGETED_RPC_VERSION = '1.0.0';\n"],"mappings":";AAKA,MAAa,kBAAkB;AAC/B,MAAa,uBAAuB"}
1
+ {"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// This file is generated by genversion.mjs. Do not edit it directly.\n\nexport const PACKAGE_VERSION = '2.5.2';\nexport const TARGETED_RPC_VERSION = '1.0.0';\n"],"mappings":";AAKA,MAAa,kBAAkB;AAC/B,MAAa,uBAAuB"}
@@ -15,7 +15,7 @@ function generateRandomness() {
15
15
  return String(toBigIntBE(randomBytes(16)));
16
16
  }
17
17
  function generateNonce(publicKey, maxEpoch, randomness) {
18
- const publicKeyBytes = toBigIntBE(publicKey.toSuiBytes());
18
+ const publicKeyBytes = toBigIntBE(publicKey.toHaneulBytes());
19
19
  const Z = toPaddedBigEndianBytes(poseidonHash([
20
20
  publicKeyBytes / 2n ** 128n,
21
21
  publicKeyBytes % 2n ** 128n,
@@ -1 +1 @@
1
- {"version":3,"file":"nonce.mjs","names":[],"sources":["../../src/zklogin/nonce.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { toHex } from '@haneullabs/bcs';\nimport { randomBytes } from '@noble/hashes/utils.js';\nimport { base64urlnopad } from '@scure/base';\n\nimport type { PublicKey } from '../cryptography/publickey.js';\nimport { poseidonHash } from './poseidon.js';\nimport { toPaddedBigEndianBytes } from './utils.js';\n\nexport const NONCE_LENGTH = 27;\n\nfunction toBigIntBE(bytes: Uint8Array) {\n\tconst hex = toHex(bytes);\n\tif (hex.length === 0) {\n\t\treturn BigInt(0);\n\t}\n\treturn BigInt(`0x${hex}`);\n}\n\nexport function generateRandomness() {\n\t// Once Node 20 enters LTS, we can just use crypto.getRandomValues(new Uint8Array(16)), but until then we use `randomBytes` to improve compatibility:\n\treturn String(toBigIntBE(randomBytes(16)));\n}\n\nexport function generateNonce(publicKey: PublicKey, maxEpoch: number, randomness: bigint | string) {\n\tconst publicKeyBytes = toBigIntBE(publicKey.toSuiBytes());\n\tconst eph_public_key_0 = publicKeyBytes / 2n ** 128n;\n\tconst eph_public_key_1 = publicKeyBytes % 2n ** 128n;\n\tconst bigNum = poseidonHash([eph_public_key_0, eph_public_key_1, maxEpoch, BigInt(randomness)]);\n\tconst Z = toPaddedBigEndianBytes(bigNum, 20);\n\tconst nonce = base64urlnopad.encode(Z);\n\n\tif (nonce.length !== NONCE_LENGTH) {\n\t\tthrow new Error(`Length of nonce ${nonce} (${nonce.length}) is not equal to ${NONCE_LENGTH}`);\n\t}\n\treturn nonce;\n}\n"],"mappings":";;;;;;;AAWA,MAAa,eAAe;AAE5B,SAAS,WAAW,OAAmB;CACtC,MAAM,MAAM,MAAM,MAAM;AACxB,KAAI,IAAI,WAAW,EAClB,QAAO,OAAO,EAAE;AAEjB,QAAO,OAAO,KAAK,MAAM;;AAG1B,SAAgB,qBAAqB;AAEpC,QAAO,OAAO,WAAW,YAAY,GAAG,CAAC,CAAC;;AAG3C,SAAgB,cAAc,WAAsB,UAAkB,YAA6B;CAClG,MAAM,iBAAiB,WAAW,UAAU,YAAY,CAAC;CAIzD,MAAM,IAAI,uBADK,aAAa;EAFH,iBAAiB,MAAM;EACvB,iBAAiB,MAAM;EACiB;EAAU,OAAO,WAAW;EAAC,CAAC,EACtD,GAAG;CAC5C,MAAM,QAAQ,eAAe,OAAO,EAAE;AAEtC,KAAI,MAAM,WAAW,aACpB,OAAM,IAAI,MAAM,mBAAmB,MAAM,IAAI,MAAM,OAAO,oBAAoB,eAAe;AAE9F,QAAO"}
1
+ {"version":3,"file":"nonce.mjs","names":[],"sources":["../../src/zklogin/nonce.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { toHex } from '@haneullabs/bcs';\nimport { randomBytes } from '@noble/hashes/utils.js';\nimport { base64urlnopad } from '@scure/base';\n\nimport type { PublicKey } from '../cryptography/publickey.js';\nimport { poseidonHash } from './poseidon.js';\nimport { toPaddedBigEndianBytes } from './utils.js';\n\nexport const NONCE_LENGTH = 27;\n\nfunction toBigIntBE(bytes: Uint8Array) {\n\tconst hex = toHex(bytes);\n\tif (hex.length === 0) {\n\t\treturn BigInt(0);\n\t}\n\treturn BigInt(`0x${hex}`);\n}\n\nexport function generateRandomness() {\n\t// Once Node 20 enters LTS, we can just use crypto.getRandomValues(new Uint8Array(16)), but until then we use `randomBytes` to improve compatibility:\n\treturn String(toBigIntBE(randomBytes(16)));\n}\n\nexport function generateNonce(publicKey: PublicKey, maxEpoch: number, randomness: bigint | string) {\n\tconst publicKeyBytes = toBigIntBE(publicKey.toHaneulBytes());\n\tconst eph_public_key_0 = publicKeyBytes / 2n ** 128n;\n\tconst eph_public_key_1 = publicKeyBytes % 2n ** 128n;\n\tconst bigNum = poseidonHash([eph_public_key_0, eph_public_key_1, maxEpoch, BigInt(randomness)]);\n\tconst Z = toPaddedBigEndianBytes(bigNum, 20);\n\tconst nonce = base64urlnopad.encode(Z);\n\n\tif (nonce.length !== NONCE_LENGTH) {\n\t\tthrow new Error(`Length of nonce ${nonce} (${nonce.length}) is not equal to ${NONCE_LENGTH}`);\n\t}\n\treturn nonce;\n}\n"],"mappings":";;;;;;;AAWA,MAAa,eAAe;AAE5B,SAAS,WAAW,OAAmB;CACtC,MAAM,MAAM,MAAM,MAAM;AACxB,KAAI,IAAI,WAAW,EAClB,QAAO,OAAO,EAAE;AAEjB,QAAO,OAAO,KAAK,MAAM;;AAG1B,SAAgB,qBAAqB;AAEpC,QAAO,OAAO,WAAW,YAAY,GAAG,CAAC,CAAC;;AAG3C,SAAgB,cAAc,WAAsB,UAAkB,YAA6B;CAClG,MAAM,iBAAiB,WAAW,UAAU,eAAe,CAAC;CAI5D,MAAM,IAAI,uBADK,aAAa;EAFH,iBAAiB,MAAM;EACvB,iBAAiB,MAAM;EACiB;EAAU,OAAO,WAAW;EAAC,CAAC,EACtD,GAAG;CAC5C,MAAM,QAAQ,eAAe,OAAO,EAAE;AAEtC,KAAI,MAAM,WAAW,aACpB,OAAM,IAAI,MAAM,mBAAmB,MAAM,IAAI,MAAM,OAAO,oBAAoB,eAAe;AAE9F,QAAO"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Haneul Labs <build@haneul-labs.com>",
4
4
  "description": "Haneul TypeScript API",
5
5
  "homepage": "https://sdk.haneul-labs.com",
6
- "version": "2.5.1",
6
+ "version": "2.5.2",
7
7
  "license": "Apache-2.0",
8
8
  "sideEffects": false,
9
9
  "files": [
@@ -61,7 +61,7 @@ export abstract class PublicKey {
61
61
  * of the scheme flag with the raw bytes of the public key
62
62
  */
63
63
  toSuiPublicKey(): string {
64
- const bytes = this.toSuiBytes();
64
+ const bytes = this.toHaneulBytes();
65
65
  return toBase64(bytes);
66
66
  }
67
67
 
@@ -105,7 +105,7 @@ export abstract class PublicKey {
105
105
  * Returns the bytes representation of the public key
106
106
  * prefixed with the signature scheme flag
107
107
  */
108
- toSuiBytes(): Uint8Array<ArrayBuffer> {
108
+ toHaneulBytes(): Uint8Array<ArrayBuffer> {
109
109
  const rawBytes = this.toRawBytes();
110
110
  const suiBytes = new Uint8Array(rawBytes.length + 1);
111
111
  suiBytes.set([this.flag()]);
@@ -120,7 +120,7 @@ export abstract class PublicKey {
120
120
  toHaneulAddress(): string {
121
121
  // Each hex char represents half a byte, hence hex address doubles the length
122
122
  return normalizeHaneulAddress(
123
- bytesToHex(blake2b(this.toSuiBytes(), { dkLen: 32 })).slice(0, HANEUL_ADDRESS_LENGTH * 2),
123
+ bytesToHex(blake2b(this.toHaneulBytes(), { dkLen: 32 })).slice(0, HANEUL_ADDRESS_LENGTH * 2),
124
124
  );
125
125
  }
126
126
 
@@ -197,7 +197,7 @@ export class MultiSigPublicKey extends PublicKey {
197
197
  // The initial value 3 ensures that following data will be after the flag byte and threshold bytes
198
198
  let i = 3;
199
199
  for (const { publicKey, weight } of this.publicKeys) {
200
- const bytes = publicKey.toSuiBytes();
200
+ const bytes = publicKey.toHaneulBytes();
201
201
  tmp.set(bytes, i);
202
202
  i += bytes.length;
203
203
  tmp.set([weight], i++);
@@ -6,5 +6,5 @@ export {
6
6
  verifyPersonalMessageSignature,
7
7
  verifyTransactionSignature,
8
8
  publicKeyFromRawBytes,
9
- publicKeyFromSuiBytes,
9
+ publicKeyFromHaneulBytes,
10
10
  } from './verify.js';
@@ -136,7 +136,7 @@ export function publicKeyFromRawBytes(
136
136
  return publicKey;
137
137
  }
138
138
 
139
- export function publicKeyFromSuiBytes(
139
+ export function publicKeyFromHaneulBytes(
140
140
  publicKey: string | Uint8Array,
141
141
  options: { client?: ClientWithCoreApi; address?: string } = {},
142
142
  ) {
package/src/version.ts CHANGED
@@ -3,5 +3,5 @@
3
3
 
4
4
  // This file is generated by genversion.mjs. Do not edit it directly.
5
5
 
6
- export const PACKAGE_VERSION = '2.5.1';
6
+ export const PACKAGE_VERSION = '2.5.2';
7
7
  export const TARGETED_RPC_VERSION = '1.0.0';
@@ -25,7 +25,7 @@ export function generateRandomness() {
25
25
  }
26
26
 
27
27
  export function generateNonce(publicKey: PublicKey, maxEpoch: number, randomness: bigint | string) {
28
- const publicKeyBytes = toBigIntBE(publicKey.toSuiBytes());
28
+ const publicKeyBytes = toBigIntBE(publicKey.toHaneulBytes());
29
29
  const eph_public_key_0 = publicKeyBytes / 2n ** 128n;
30
30
  const eph_public_key_1 = publicKeyBytes % 2n ** 128n;
31
31
  const bigNum = poseidonHash([eph_public_key_0, eph_public_key_1, maxEpoch, BigInt(randomness)]);