@invisi-labs/primitives 1.2.4 → 1.2.6
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.
- package/LICENSE +201 -0
- package/README.md +15 -1
- package/dist/address.cjs +45 -3
- package/dist/address.cjs.map +1 -1
- package/dist/address.js +2 -2
- package/dist/{chunk-C5QNE2WF.js → chunk-5KF55DN7.js} +2 -2
- package/dist/{chunk-QAC5T4S5.js → chunk-JRPMFP3G.js} +2 -2
- package/dist/{chunk-XM4B6K37.js → chunk-QLGXGUSB.js} +2 -2
- package/dist/{chunk-Q3NNEKKR.js → chunk-VXBZSY4Y.js} +55 -10
- package/dist/chunk-VXBZSY4Y.js.map +1 -0
- package/dist/credit.cjs +45 -3
- package/dist/credit.cjs.map +1 -1
- package/dist/credit.js +2 -2
- package/dist/index.cjs +53 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -5
- package/dist/index.d.ts +1 -5
- package/dist/index.js +4 -4
- package/dist/note.cjs +45 -3
- package/dist/note.cjs.map +1 -1
- package/dist/note.js +3 -3
- package/package.json +3 -2
- package/dist/chunk-Q3NNEKKR.js.map +0 -1
- /package/dist/{chunk-C5QNE2WF.js.map → chunk-5KF55DN7.js.map} +0 -0
- /package/dist/{chunk-QAC5T4S5.js.map → chunk-JRPMFP3G.js.map} +0 -0
- /package/dist/{chunk-XM4B6K37.js.map → chunk-QLGXGUSB.js.map} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -2,4 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Invisi Protocol pure cryptographic primitives.
|
|
4
4
|
|
|
5
|
-
Install with `npm install @invisi-labs/primitives@1.2.
|
|
5
|
+
Install with `npm install @invisi-labs/primitives@1.2.6`. API documentation and runnable examples are in the [SDK repository](https://github.com/invisi-labs/invisi-sdk-ts).
|
|
6
|
+
|
|
7
|
+
## Contributing
|
|
8
|
+
|
|
9
|
+
See the [contribution guidelines](../../README.md#contributing) for issues, pull requests, validation, and handling sensitive material.
|
|
10
|
+
|
|
11
|
+
## Hermes FMD performance
|
|
12
|
+
|
|
13
|
+
FMD clue creation shares the receiving-key scalar multiplication across the 24 bits, uses a fixed-field inverse square root, and retains at most eight public receiving-key precomputations. Random seeds and secret shared points are never cached. Clue bytes and canonical encoding are unchanged.
|
|
14
|
+
|
|
15
|
+
The [simulator comparison](../../test-support/performance/hermes-preview-comparison-20261117.json) and its adjacent raw reports record development Hermes measurements against 1.2.4. Paired warm clue generation fell from approximately 660 ms to 127 ms with identical keys and seeds. The full synthetic preparation and live broadcaster quote retained change creation, fee iterations and signed-quote checks. These measurements exclude real App storage and UI overhead; they do not establish device release performance or Node parity.
|
|
16
|
+
|
|
17
|
+
Correctness coverage includes independent Rust clue and canonical-key vectors, inverse-square-root comparisons with the generic field implementation, fresh randomness, mutable input buffers and public-key cache eviction. Run `pnpm --filter @invisi-labs/primitives test` after building workspace dependencies.
|
|
18
|
+
|
|
19
|
+
The recorded branch comparison exceeded the browser eager-entry budget before and after optimization (1,051,806 and 1,053,330 bytes against 1 MiB). The current combined build measures 1,053,178 bytes; the budget check remains failing and its threshold is unchanged.
|
package/dist/address.cjs
CHANGED
|
@@ -65,6 +65,33 @@ function readLE(bytes) {
|
|
|
65
65
|
for (let i = bytes.length - 1; i >= 0; i--) n = n << 8n | BigInt(bytes[i]);
|
|
66
66
|
return n;
|
|
67
67
|
}
|
|
68
|
+
var sqrtOddOrder = FQ - 1n >> 47n;
|
|
69
|
+
var sqrtRootOfUnity = field.pow(11n, sqrtOddOrder);
|
|
70
|
+
function inverseSquareRoot(denominator) {
|
|
71
|
+
if (denominator <= 0n || denominator >= FQ)
|
|
72
|
+
throw new Error("Invalid Decaf377 square root input");
|
|
73
|
+
let root = field.pow(denominator, sqrtOddOrder - 1n >> 1n);
|
|
74
|
+
let residue = f(root * root * denominator);
|
|
75
|
+
let unity = sqrtRootOfUnity;
|
|
76
|
+
let order = 47;
|
|
77
|
+
while (residue !== 1n) {
|
|
78
|
+
let index = 0;
|
|
79
|
+
let power = residue;
|
|
80
|
+
while (power !== 1n && index < order) {
|
|
81
|
+
power = f(power * power);
|
|
82
|
+
index++;
|
|
83
|
+
}
|
|
84
|
+
if (index >= order) throw new Error("Invalid Decaf377 square root");
|
|
85
|
+
let adjustment = unity;
|
|
86
|
+
for (let i = 0; i < order - index - 1; i++) adjustment = f(adjustment * adjustment);
|
|
87
|
+
root = f(root * adjustment);
|
|
88
|
+
unity = f(adjustment * adjustment);
|
|
89
|
+
residue = f(residue * unity);
|
|
90
|
+
order = index;
|
|
91
|
+
}
|
|
92
|
+
if (f(root * root * denominator) !== 1n) throw new Error("Invalid Decaf377 square root");
|
|
93
|
+
return root;
|
|
94
|
+
}
|
|
68
95
|
function decodePoint(bytes) {
|
|
69
96
|
if (!(bytes instanceof Uint8Array) || bytes.length !== 32)
|
|
70
97
|
throw new Error("Invalid Decaf377 encoding length");
|
|
@@ -78,7 +105,7 @@ function decodePoint(bytes) {
|
|
|
78
105
|
if (denominator === 0n) throw new Error("Invalid Decaf377 encoding");
|
|
79
106
|
let v;
|
|
80
107
|
try {
|
|
81
|
-
v =
|
|
108
|
+
v = inverseSquareRoot(denominator);
|
|
82
109
|
} catch {
|
|
83
110
|
throw new Error("Invalid Decaf377 encoding");
|
|
84
111
|
}
|
|
@@ -97,9 +124,24 @@ function requireBytes(value, length, name) {
|
|
|
97
124
|
if (!(value instanceof Uint8Array) || value.length !== length)
|
|
98
125
|
throw new TypeError(`${name} must be a ${length}-byte Uint8Array`);
|
|
99
126
|
}
|
|
100
|
-
|
|
127
|
+
var clueKeys = /* @__PURE__ */ new Map();
|
|
128
|
+
function expandedClueKey(clueKey) {
|
|
101
129
|
requireBytes(clueKey, 32, "Clue key");
|
|
102
|
-
|
|
130
|
+
const key = (0, import_utils.bytesToHex)(clueKey);
|
|
131
|
+
let expanded = clueKeys.get(key);
|
|
132
|
+
if (expanded) clueKeys.delete(key);
|
|
133
|
+
else {
|
|
134
|
+
const root = decodePoint(clueKey);
|
|
135
|
+
if (isIdentity(root)) throw new Error("Clue key must not be the identity");
|
|
136
|
+
root._setWindowSize(4);
|
|
137
|
+
expanded = { root };
|
|
138
|
+
}
|
|
139
|
+
clueKeys.set(key, expanded);
|
|
140
|
+
if (clueKeys.size > 8) clueKeys.delete(clueKeys.keys().next().value);
|
|
141
|
+
return expanded;
|
|
142
|
+
}
|
|
143
|
+
function validateClueKey(clueKey) {
|
|
144
|
+
expandedClueKey(clueKey);
|
|
103
145
|
}
|
|
104
146
|
|
|
105
147
|
// src/address/address.ts
|
package/dist/address.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/address-entry.ts","../src/address/address.ts","../src/fmd/fmd.ts","../src/fmd/decaf377.ts","../src/errors.ts","../src/address/receiving-address.ts"],"sourcesContent":["/** Public receiving addresses without wallet key derivation or a hashing backend. */\nexport { decodeAddress } from \"./address/address\";\nexport type { DecodedAddress, ReceivingKeyLookup } from \"./address/address\";\nexport { ReceivingAddress } from \"./address/receiving-address\";\nexport type { ReceivingKeys } from \"./types\";\n","import { secp256k1 } from \"@noble/curves/secp256k1\";\nimport { keccak_256 } from \"@noble/hashes/sha3\";\nimport { bytesToHex, concatBytes, hexToBytes, utf8ToBytes } from \"@noble/hashes/utils\";\nimport { getAddress } from \"ethers\";\nimport { validateClueKey } from \"../fmd/fmd\";\n\nexport interface ReceivingAddress {\n ownerAddress: `0x${string}`;\n viewingPublicKey: Uint8Array;\n clueKey: Uint8Array;\n}\nexport type DecodedAddress =\n ({ kind: \"long\" } & ReceivingAddress) | { kind: \"short\"; ownerAddress: `0x${string}` };\nexport type ReceivingKeyLookup = (\n ownerAddress: `0x${string}`\n) => Promise<Pick<ReceivingAddress, \"viewingPublicKey\" | \"clueKey\"> | null | undefined>;\nconst ALPHABET = \"qpzry9x8gf2tvdw0s3jn54khce6mua7l\";\ntype Identity = bigint | `0x${string}`;\n\nfunction identityBytes(value: Identity): Uint8Array {\n if (\n typeof value !== \"bigint\" &&\n (typeof value !== \"string\" || !/^0x[0-9a-fA-F]{40}$/.test(value))\n )\n throw new Error(\"invalid owner address encoding\");\n const n = BigInt(value);\n if (n <= 0n || n >= 1n << 160n)\n throw new RangeError(\"owner address must be a nonzero EVM owner address\");\n return hexToBytes(n.toString(16).padStart(40, \"0\"));\n}\nfunction receivingKeys(keys: Pick<ReceivingAddress, \"viewingPublicKey\" | \"clueKey\">) {\n const publicKey = keys.viewingPublicKey;\n if (\n !(publicKey instanceof Uint8Array) ||\n publicKey.length !== 33 ||\n (publicKey[0] !== 2 && publicKey[0] !== 3)\n )\n throw new Error(\"invalid compressed viewing public key\");\n secp256k1.ProjectivePoint.fromHex(publicKey).assertValidity();\n validateClueKey(keys.clueKey);\n return { viewingPublicKey: Uint8Array.from(publicKey), clueKey: Uint8Array.from(keys.clueKey) };\n}\nfunction checkedText(prefix: string, data: string): string {\n const digest = keccak_256(utf8ToBytes(\"Invisi.AddressCaseChecksum.v1:\" + prefix + data));\n return (\n prefix +\n Array.from(data, (character, i) =>\n (digest[i >> 3]! >> (7 - (i & 7))) & 1 ? character.toUpperCase() : character\n ).join(\"\")\n );\n}\nfunction encode(prefix: string, payload: Uint8Array): string {\n let buffer = 0,\n bits = 0,\n data = \"\";\n for (const byte of payload) {\n buffer = (buffer << 8) | byte;\n bits += 8;\n while (bits >= 5) {\n bits -= 5;\n data += ALPHABET[(buffer >>> bits) & 31];\n }\n buffer &= (1 << bits) - 1;\n }\n if (bits) data += ALPHABET[(buffer << (5 - bits)) & 31];\n return checkedText(prefix, data);\n}\n\n/** 138 characters: 0i plus the complete offline receiving materials. */\nexport function encodeLongAddress(recipient: ReceivingAddress): string {\n const identity = identityBytes(recipient.ownerAddress),\n keys = receivingKeys(recipient);\n return encode(\"0i\", concatBytes(identity, keys.viewingPublicKey, keys.clueKey));\n}\n/** The owner's 42-character checksummed EVM address; receiving keys require a chosen registry. */\nexport function encodeShortAddress(ownerAddress: Identity): string {\n const identity = identityBytes(ownerAddress);\n return getAddress(\n typeof ownerAddress === \"string\" ? ownerAddress : `0x${bytesToHex(identity)}`\n );\n}\n\n/** Standard EVM short addresses or a full 0i address with a strict custom Base32 case checksum. */\nexport function decodeAddress(address: string): DecodedAddress {\n if (typeof address !== \"string\") throw new TypeError(\"address must be text\");\n if (address.startsWith(\"0x\")) {\n const owner = getAddress(address) as `0x${string}`;\n return { kind: \"short\", ownerAddress: `0x${bytesToHex(identityBytes(owner))}` };\n }\n if (!address.startsWith(\"0i\")) throw new Error(\"invalid Invisi address prefix\");\n const prefix = \"0i\";\n if (address.length !== 138) throw new Error(\"invalid address length\");\n const data = address.slice(prefix.length).toLowerCase();\n if (Array.from(data).some((character) => !ALPHABET.includes(character)))\n throw new Error(\"invalid address alphabet\");\n if (checkedText(prefix, data) !== address) throw new Error(\"invalid address case checksum\");\n let buffer = 0,\n bits = 0;\n const payload: number[] = [];\n for (const character of data) {\n buffer = (buffer << 5) | ALPHABET.indexOf(character);\n bits += 5;\n if (bits >= 8) {\n bits -= 8;\n payload.push((buffer >>> bits) & 255);\n }\n buffer &= (1 << bits) - 1;\n }\n if (bits !== 0 || buffer !== 0) throw new Error(\"noncanonical address padding\");\n const raw = Uint8Array.from(payload);\n const ownerAddress =\n `0x${bytesToHex(identityBytes(`0x${bytesToHex(raw.subarray(0, 20))}`))}` as const;\n return {\n kind: \"long\",\n ownerAddress,\n ...receivingKeys({ viewingPublicKey: raw.slice(20, 53), clueKey: raw.slice(53) }),\n };\n}\n\n/** Normalize either address into the same payment input. Long addresses never query. */\nexport async function resolveAddress(\n address: string,\n options: { lookup?: ReceivingKeyLookup } = {}\n): Promise<ReceivingAddress> {\n const decoded = decodeAddress(address);\n if (decoded.kind === \"long\")\n return {\n ownerAddress: decoded.ownerAddress,\n viewingPublicKey: decoded.viewingPublicKey,\n clueKey: decoded.clueKey,\n };\n if (!options.lookup) throw new Error(\"short address requires an explicit registry lookup\");\n const keys = await options.lookup(decoded.ownerAddress);\n if (!keys) throw new Error(\"owner address is not registered\");\n return { ownerAddress: decoded.ownerAddress, ...receivingKeys(keys) };\n}\n","/**\n * Frozen S-FMD profile: decaf377-fmd 2.1.1, 24-bit clues (68 bytes).\n * Only FMD detection keys belong here; these are not transaction ownership keys.\n *\n * SECURITY: the noble Edwards arithmetic and this exact Decaf codec port use\n * JavaScript BigInt. They do not provide constant-time execution or reliable\n * secret erasure. This new composition has not received an independent audit.\n */\nimport { blake2b } from \"@noble/hashes/blake2b\";\nimport { concatBytes, utf8ToBytes } from \"@noble/hashes/utils\";\nimport {\n FR,\n decodePoint,\n encodePoint,\n generator,\n inverseScalar,\n isIdentity,\n multiply,\n readLE,\n secureRandomBytes,\n writeLE,\n} from \"./decaf377.js\";\n\nconst PRECISION = 24;\nfunction requireBytes(value: Uint8Array, length: number, name: string): void {\n if (!(value instanceof Uint8Array) || value.length !== length)\n throw new TypeError(`${name} must be a ${length}-byte Uint8Array`);\n}\nfunction detectionScalar(key: Uint8Array): bigint {\n requireBytes(key, 32, \"Detection key\");\n const scalar = readLE(key);\n if (scalar === 0n || scalar >= FR)\n throw new Error(\"Detection key must be a canonical nonzero Decaf377 scalar\");\n return scalar;\n}\nfunction hash(domain: string, ...parts: Uint8Array[]): Uint8Array {\n // Rust blake2b_simd defaults to 64 output bytes and zero-pads personalization.\n const personalization = new Uint8Array(16);\n personalization.set(utf8ToBytes(`decaf377-fmd.${domain}`));\n return blake2b(concatBytes(...parts), { dkLen: 64, personalization });\n}\nconst hashScalar = (domain: string, ...parts: Uint8Array[]) => readLE(hash(domain, ...parts)) % FR;\nconst childOffset = (clueKey: Uint8Array, index: number) =>\n hashScalar(\"hkd\", clueKey, Uint8Array.of(index));\nconst hashBit = (p: Uint8Array, shared: Uint8Array, q: Uint8Array) =>\n hash(\"bit\", p, shared, q)[0]! & 1;\n\n/** Derive the canonical 32-byte Decaf377 clue key from a nonzero FMD scalar. */\nexport function deriveClueKey(detectionKey: Uint8Array): Uint8Array {\n return encodePoint(multiply(generator, detectionScalar(detectionKey)));\n}\n/** Reject malformed, noncanonical, or identity clue keys. */\nexport function validateClueKey(clueKey: Uint8Array): void {\n requireBytes(clueKey, 32, \"Clue key\");\n if (isIdentity(decodePoint(clueKey))) throw new Error(\"Clue key must not be the identity\");\n}\n/** Create a fixed 24-bit clue using a fresh WebCrypto random seed. */\nexport function createClue(clueKey: Uint8Array): Uint8Array {\n validateClueKey(clueKey);\n return createClueFromSeed(clueKey, secureRandomBytes(32));\n}\n/**\n * Deterministic interoperability/backend entry point. Seed must be independently\n * generated with a CSPRNG for every production clue; never reuse a fixed seed.\n */\nexport function createClueFromSeed(clueKey: Uint8Array, seed32: Uint8Array): Uint8Array {\n validateClueKey(clueKey);\n requireBytes(seed32, 32, \"Clue seed\");\n const root = decodePoint(clueKey);\n const r = hashScalar(\"rdv\", clueKey, seed32);\n const z = hashScalar(\"zdv\", clueKey, seed32);\n if (r === 0n) throw new Error(\"Degenerate clue seed\");\n const p = encodePoint(multiply(generator, r));\n const q = encodePoint(multiply(generator, z));\n const ciphertext = new Uint8Array(3);\n for (let i = 0; i < PRECISION; i++) {\n const child = root.add(multiply(generator, childOffset(clueKey, i)));\n const shared = encodePoint(multiply(child, r));\n ciphertext[i >> 3] = ciphertext[i >> 3]! | ((hashBit(p, shared, q) ^ 1) << (i & 7));\n }\n const m = hashScalar(\"sca\", p, Uint8Array.of(PRECISION), ciphertext);\n const y = ((z - m + FR) * inverseScalar(r)) % FR;\n if (y === 0n) throw new Error(\"Degenerate clue seed\");\n return concatBytes(p, writeLE(y), Uint8Array.of(PRECISION), ciphertext);\n}\n\n/** Check a full-precision clue locally without exporting the detection key. */\nexport function detectClue(detectionKey: Uint8Array, clue: Uint8Array): boolean {\n const scalar = detectionScalar(detectionKey);\n requireBytes(clue, 68, \"Clue\");\n if (clue[64] !== PRECISION) return false;\n const p = clue.slice(0, 32),\n y = readLE(clue.slice(32, 64));\n if (y === 0n || y >= FR) return false;\n let point;\n try {\n point = decodePoint(p);\n } catch {\n return false;\n }\n if (isIdentity(point)) return false;\n const ciphertext = clue.slice(65);\n const m = hashScalar(\"sca\", p, Uint8Array.of(PRECISION), ciphertext);\n const q = encodePoint(multiply(generator, m).add(multiply(point, y)));\n const clueKey = deriveClueKey(detectionKey);\n for (let i = 0; i < PRECISION; i++) {\n const child = (scalar + childOffset(clueKey, i)) % FR;\n const bit = hashBit(p, encodePoint(multiply(point, child)), q);\n if ((bit ^ ((ciphertext[i >> 3]! >> (i & 7)) & 1)) !== 1) return false;\n }\n return true;\n}\n","/**\n * Internal Decaf377 codec, ported from decaf377 0.10.1 min_curve/element.rs.\n * Edwards group/field arithmetic is supplied by @noble/curves 1.9.1. The\n * Montgomery constants below are converted to ordinary field integers.\n * This JavaScript BigInt backend is NOT constant-time and has not been audited.\n */\nimport { twistedEdwards, type ExtPointType } from \"@noble/curves/abstract/edwards\";\nimport { Field, mod } from \"@noble/curves/abstract/modular\";\nimport { blake2b } from \"@noble/hashes/blake2b\";\n\nexport const FQ = 8444461749428370424248824938781546531375899335154063827935233455917409239041n;\nexport const FR = 2111115437357092606062206234695386632838870926408408195193685246394721360383n;\nconst field = Field(FQ, 253, true);\nconst f = (n: bigint) => mod(n, FQ);\nconst abs = (n: bigint) => ((n & 1n) === 0n ? n : f(-n));\n\nexport function secureRandomBytes(length: number): Uint8Array {\n const webCrypto = (\n globalThis as { crypto?: { getRandomValues(array: Uint8Array): Uint8Array } }\n ).crypto;\n if (!webCrypto?.getRandomValues) throw new Error(\"WebCrypto secure randomness is unavailable\");\n return webCrypto.getRandomValues(new Uint8Array(length));\n}\n\nconst curve = twistedEdwards({\n a: FQ - 1n,\n d: 3021n,\n Fp: field,\n n: FR,\n h: 4n,\n Gx: 4959445789346820725352484487855828915252512307947624787834978378872129235627n,\n Gy: 6060471950081851567114691557659790004756535011754163002297540472747064943288n,\n hash: blake2b,\n randomBytes: (length = 32) => secureRandomBytes(length),\n});\nexport type DecafPoint = ExtPointType;\nexport const generator: DecafPoint = curve.ExtendedPoint.BASE;\n\nexport function readLE(bytes: Uint8Array): bigint {\n let n = 0n;\n for (let i = bytes.length - 1; i >= 0; i--) n = (n << 8n) | BigInt(bytes[i]!);\n return n;\n}\nexport function writeLE(n: bigint): Uint8Array {\n const bytes = new Uint8Array(32);\n for (let i = 0; i < 32; i++) {\n bytes[i] = Number(n & 255n);\n n >>= 8n;\n }\n return bytes;\n}\nexport function multiply(point: DecafPoint, scalar: bigint): DecafPoint {\n return scalar === 0n ? curve.ExtendedPoint.ZERO : point.multiply(scalar);\n}\nexport function inverseScalar(scalar: bigint): bigint {\n // Noble's field inversion uses Euclid. Neither this nor BigInt is constant-time.\n return Field(FR).inv(scalar);\n}\n\n/** Canonical Decaf decoding, including the low-bit sign convention. */\nexport function decodePoint(bytes: Uint8Array): DecafPoint {\n if (!(bytes instanceof Uint8Array) || bytes.length !== 32)\n throw new Error(\"Invalid Decaf377 encoding length\");\n const s = readLE(bytes);\n if (s >= FQ || (s & 1n) !== 0n || bytes[31]! >> 5 !== 0)\n throw new Error(\"Invalid Decaf377 encoding\");\n const ss = f(s * s);\n const u1 = f(1n - ss);\n const u2 = f(u1 * u1 - 4n * 3021n * ss);\n const denominator = f(u2 * u1 * u1);\n // This is the square branch of Rust sqrt_ratio_zeta(1, denominator).\n // Decompression rejects the nonsquare branch; root sign is fixed below.\n if (denominator === 0n) throw new Error(\"Invalid Decaf377 encoding\");\n let v: bigint;\n try {\n v = field.sqrt(field.inv(denominator));\n } catch {\n throw new Error(\"Invalid Decaf377 encoding\");\n }\n const twoSU1 = f(2n * s * u1);\n if ((f(twoSU1 * v) & 1n) !== 0n) v = f(-v);\n const x = f(twoSU1 * v * v * u2);\n const y = f((1n + ss) * v * u1);\n return curve.ExtendedPoint.fromAffine({ x, y });\n}\nexport function encodePoint(point: DecafPoint): Uint8Array {\n const { ex: x, ez: z, et: t } = point;\n if (x === 0n) return new Uint8Array(32);\n const aMinusD = -3022n;\n const u1 = f((x + t) * (x - t));\n const denominator = f(u1 * aMinusD * x * x);\n const v = field.sqrt(field.inv(denominator));\n const u2 = abs(f(v * u1));\n const u3 = f(u2 * z - t);\n return writeLE(abs(f(aMinusD * v * u3 * x)));\n}\nexport function isIdentity(point: DecafPoint): boolean {\n return point.ex === 0n;\n}\n","/** A requested permission was not explicitly supplied to this component. */\nexport class MissingCapabilityError extends Error {\n readonly code = \"MISSING_CAPABILITY\";\n constructor(readonly capability: string) {\n super(`Missing ${capability} capability`);\n this.name = \"MissingCapabilityError\";\n }\n}\n","import { MissingCapabilityError } from \"../errors\";\nimport type { ReceivingKeys } from \"../types\";\nimport {\n decodeAddress,\n encodeLongAddress,\n encodeShortAddress,\n type ReceivingAddress as ReceivingData,\n type ReceivingKeyLookup,\n} from \"./address\";\n\n/** Validated public receiving material. A short address requires an explicit resolver. */\nexport class ReceivingAddress {\n readonly #text: string;\n\n private constructor(text: string) {\n const decoded = decodeAddress(text);\n this.#text = decoded.kind === \"short\" ? encodeShortAddress(decoded.ownerAddress) : text;\n Object.freeze(this);\n }\n\n static parse(text: string): ReceivingAddress {\n return new ReceivingAddress(text);\n }\n\n static from(recipient: ReceivingData): ReceivingAddress {\n return new ReceivingAddress(encodeLongAddress(recipient));\n }\n\n static fromIdentity(identity: bigint | `0x${string}`): ReceivingAddress {\n return new ReceivingAddress(encodeShortAddress(identity));\n }\n\n get ownerAddress(): `0x${string}` {\n return decodeAddress(this.#text).ownerAddress;\n }\n\n get kind(): \"long\" | \"short\" {\n return decodeAddress(this.#text).kind;\n }\n\n getReceivingKeys(): ReceivingKeys {\n const decoded = decodeAddress(this.#text);\n if (decoded.kind === \"short\") {\n throw new MissingCapabilityError(\"resolved receiving keys\");\n }\n return { viewingPublicKey: decoded.viewingPublicKey, clueKey: decoded.clueKey };\n }\n\n async resolve(lookup?: ReceivingKeyLookup): Promise<ReceivingAddress> {\n if (this.kind === \"long\") {\n return this;\n }\n if (!lookup) {\n throw new MissingCapabilityError(\"explicit registry lookup\");\n }\n const keys = await lookup(this.ownerAddress);\n if (!keys) {\n throw new Error(\"owner address is not registered\");\n }\n return ReceivingAddress.from({\n ownerAddress: this.ownerAddress,\n viewingPublicKey: keys.viewingPublicKey,\n clueKey: keys.clueKey,\n });\n }\n\n get viewingPublicKey(): Uint8Array {\n return this.getReceivingKeys().viewingPublicKey;\n }\n\n get clueKey(): Uint8Array {\n return this.getReceivingKeys().clueKey;\n }\n\n toString(): string {\n return this.#text;\n }\n\n toJSON(): string {\n return this.#text;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAA0B;AAC1B,kBAA2B;AAC3B,IAAAA,gBAAiE;AACjE,oBAA2B;;;ACK3B,IAAAC,kBAAwB;AACxB,mBAAyC;;;ACHzC,qBAAkD;AAClD,qBAA2B;AAC3B,qBAAwB;AAEjB,IAAM,KAAK;AACX,IAAM,KAAK;AAClB,IAAM,YAAQ,sBAAM,IAAI,KAAK,IAAI;AACjC,IAAM,IAAI,CAAC,UAAc,oBAAI,GAAG,EAAE;AAG3B,SAAS,kBAAkB,QAA4B;AAC1D,QAAM,YACF,WACF;AACF,MAAI,CAAC,WAAW,gBAAiB,OAAM,IAAI,MAAM,4CAA4C;AAC7F,SAAO,UAAU,gBAAgB,IAAI,WAAW,MAAM,CAAC;AAC3D;AAEA,IAAM,YAAQ,+BAAe;AAAA,EACzB,GAAG,KAAK;AAAA,EACR,GAAG;AAAA,EACH,IAAI;AAAA,EACJ,GAAG;AAAA,E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UAAoD;AACpE,WAAO,IAAI,kBAAiB,mBAAmB,QAAQ,CAAC;AAAA,EAC5D;AAAA,EAEA,IAAI,eAA8B;AAC9B,WAAO,cAAc,KAAK,KAAK,EAAE;AAAA,EACrC;AAAA,EAEA,IAAI,OAAyB;AACzB,WAAO,cAAc,KAAK,KAAK,EAAE;AAAA,EACrC;AAAA,EAEA,mBAAkC;AAC9B,UAAM,UAAU,cAAc,KAAK,KAAK;AACxC,QAAI,QAAQ,SAAS,SAAS;AAC1B,YAAM,IAAI,uBAAuB,yBAAyB;AAAA,IAC9D;AACA,WAAO,EAAE,kBAAkB,QAAQ,kBAAkB,SAAS,QAAQ,QAAQ;AAAA,EAClF;AAAA,EAEA,MAAM,QAAQ,QAAwD;AAClE,QAAI,KAAK,SAAS,QAAQ;AACtB,aAAO;AAAA,IACX;AACA,QAAI,CAAC,QAAQ;AACT,YAAM,IAAI,uBAAuB,0BAA0B;AAAA,IAC/D;AACA,UAAM,OAAO,MAAM,OAAO,KAAK,YAAY;AAC3C,QAAI,CAAC,MAAM;AACP,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACrD;AACA,WAAO,kBAAiB,KAAK;AAAA,MACzB,cAAc,KAAK;AAAA,MACnB,kBAAkB,KAAK;AAAA,MACvB,SAAS,KAAK;AAAA,IAClB,CAAC;AAAA,EACL;AAAA,EAEA,IAAI,mBAA+B;AAC/B,WAAO,KAAK,iBAAiB,EAAE;AAAA,EACnC;AAAA,EAEA,IAAI,UAAsB;AACtB,WAAO,KAAK,iBAAiB,EAAE;AAAA,EACnC;AAAA,EAEA,WAAmB;AACf,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,SAAiB;AACb,WAAO,KAAK;AAAA,EAChB;AACJ;","names":["import_utils","import_blake2b"]}
|
|
1
|
+
{"version":3,"sources":["../src/address-entry.ts","../src/address/address.ts","../src/fmd/fmd.ts","../src/fmd/decaf377.ts","../src/errors.ts","../src/address/receiving-address.ts"],"sourcesContent":["/** Public receiving addresses without wallet key derivation or a hashing backend. */\nexport { decodeAddress } from \"./address/address\";\nexport type { DecodedAddress, ReceivingKeyLookup } from \"./address/address\";\nexport { ReceivingAddress } from \"./address/receiving-address\";\nexport type { ReceivingKeys } from \"./types\";\n","import { secp256k1 } from \"@noble/curves/secp256k1\";\nimport { keccak_256 } from \"@noble/hashes/sha3\";\nimport { bytesToHex, concatBytes, hexToBytes, utf8ToBytes } from \"@noble/hashes/utils\";\nimport { getAddress } from \"ethers\";\nimport { validateClueKey } from \"../fmd/fmd\";\n\nexport interface ReceivingAddress {\n ownerAddress: `0x${string}`;\n viewingPublicKey: Uint8Array;\n clueKey: Uint8Array;\n}\nexport type DecodedAddress =\n ({ kind: \"long\" } & ReceivingAddress) | { kind: \"short\"; ownerAddress: `0x${string}` };\nexport type ReceivingKeyLookup = (\n ownerAddress: `0x${string}`\n) => Promise<Pick<ReceivingAddress, \"viewingPublicKey\" | \"clueKey\"> | null | undefined>;\nconst ALPHABET = \"qpzry9x8gf2tvdw0s3jn54khce6mua7l\";\ntype Identity = bigint | `0x${string}`;\n\nfunction identityBytes(value: Identity): Uint8Array {\n if (\n typeof value !== \"bigint\" &&\n (typeof value !== \"string\" || !/^0x[0-9a-fA-F]{40}$/.test(value))\n )\n throw new Error(\"invalid owner address encoding\");\n const n = BigInt(value);\n if (n <= 0n || n >= 1n << 160n)\n throw new RangeError(\"owner address must be a nonzero EVM owner address\");\n return hexToBytes(n.toString(16).padStart(40, \"0\"));\n}\nfunction receivingKeys(keys: Pick<ReceivingAddress, \"viewingPublicKey\" | \"clueKey\">) {\n const publicKey = keys.viewingPublicKey;\n if (\n !(publicKey instanceof Uint8Array) ||\n publicKey.length !== 33 ||\n (publicKey[0] !== 2 && publicKey[0] !== 3)\n )\n throw new Error(\"invalid compressed viewing public key\");\n secp256k1.ProjectivePoint.fromHex(publicKey).assertValidity();\n validateClueKey(keys.clueKey);\n return { viewingPublicKey: Uint8Array.from(publicKey), clueKey: Uint8Array.from(keys.clueKey) };\n}\nfunction checkedText(prefix: string, data: string): string {\n const digest = keccak_256(utf8ToBytes(\"Invisi.AddressCaseChecksum.v1:\" + prefix + data));\n return (\n prefix +\n Array.from(data, (character, i) =>\n (digest[i >> 3]! >> (7 - (i & 7))) & 1 ? character.toUpperCase() : character\n ).join(\"\")\n );\n}\nfunction encode(prefix: string, payload: Uint8Array): string {\n let buffer = 0,\n bits = 0,\n data = \"\";\n for (const byte of payload) {\n buffer = (buffer << 8) | byte;\n bits += 8;\n while (bits >= 5) {\n bits -= 5;\n data += ALPHABET[(buffer >>> bits) & 31];\n }\n buffer &= (1 << bits) - 1;\n }\n if (bits) data += ALPHABET[(buffer << (5 - bits)) & 31];\n return checkedText(prefix, data);\n}\n\n/** 138 characters: 0i plus the complete offline receiving materials. */\nexport function encodeLongAddress(recipient: ReceivingAddress): string {\n const identity = identityBytes(recipient.ownerAddress),\n keys = receivingKeys(recipient);\n return encode(\"0i\", concatBytes(identity, keys.viewingPublicKey, keys.clueKey));\n}\n/** The owner's 42-character checksummed EVM address; receiving keys require a chosen registry. */\nexport function encodeShortAddress(ownerAddress: Identity): string {\n const identity = identityBytes(ownerAddress);\n return getAddress(\n typeof ownerAddress === \"string\" ? ownerAddress : `0x${bytesToHex(identity)}`\n );\n}\n\n/** Standard EVM short addresses or a full 0i address with a strict custom Base32 case checksum. */\nexport function decodeAddress(address: string): DecodedAddress {\n if (typeof address !== \"string\") throw new TypeError(\"address must be text\");\n if (address.startsWith(\"0x\")) {\n const owner = getAddress(address) as `0x${string}`;\n return { kind: \"short\", ownerAddress: `0x${bytesToHex(identityBytes(owner))}` };\n }\n if (!address.startsWith(\"0i\")) throw new Error(\"invalid Invisi address prefix\");\n const prefix = \"0i\";\n if (address.length !== 138) throw new Error(\"invalid address length\");\n const data = address.slice(prefix.length).toLowerCase();\n if (Array.from(data).some((character) => !ALPHABET.includes(character)))\n throw new Error(\"invalid address alphabet\");\n if (checkedText(prefix, data) !== address) throw new Error(\"invalid address case checksum\");\n let buffer = 0,\n bits = 0;\n const payload: number[] = [];\n for (const character of data) {\n buffer = (buffer << 5) | ALPHABET.indexOf(character);\n bits += 5;\n if (bits >= 8) {\n bits -= 8;\n payload.push((buffer >>> bits) & 255);\n }\n buffer &= (1 << bits) - 1;\n }\n if (bits !== 0 || buffer !== 0) throw new Error(\"noncanonical address padding\");\n const raw = Uint8Array.from(payload);\n const ownerAddress =\n `0x${bytesToHex(identityBytes(`0x${bytesToHex(raw.subarray(0, 20))}`))}` as const;\n return {\n kind: \"long\",\n ownerAddress,\n ...receivingKeys({ viewingPublicKey: raw.slice(20, 53), clueKey: raw.slice(53) }),\n };\n}\n\n/** Normalize either address into the same payment input. Long addresses never query. */\nexport async function resolveAddress(\n address: string,\n options: { lookup?: ReceivingKeyLookup } = {}\n): Promise<ReceivingAddress> {\n const decoded = decodeAddress(address);\n if (decoded.kind === \"long\")\n return {\n ownerAddress: decoded.ownerAddress,\n viewingPublicKey: decoded.viewingPublicKey,\n clueKey: decoded.clueKey,\n };\n if (!options.lookup) throw new Error(\"short address requires an explicit registry lookup\");\n const keys = await options.lookup(decoded.ownerAddress);\n if (!keys) throw new Error(\"owner address is not registered\");\n return { ownerAddress: decoded.ownerAddress, ...receivingKeys(keys) };\n}\n","/**\n * Frozen S-FMD profile: decaf377-fmd 2.1.1, 24-bit clues (68 bytes).\n * Only FMD detection keys belong here; these are not transaction ownership keys.\n *\n * SECURITY: the noble Edwards arithmetic and this exact Decaf codec port use\n * JavaScript BigInt. They do not provide constant-time execution or reliable\n * secret erasure. This new composition has not received an independent audit.\n */\nimport { blake2b } from \"@noble/hashes/blake2b\";\nimport { bytesToHex, concatBytes, utf8ToBytes } from \"@noble/hashes/utils\";\nimport {\n FR,\n type DecafPoint,\n decodePoint,\n encodePoint,\n generator,\n inverseScalar,\n isIdentity,\n multiply,\n readLE,\n secureRandomBytes,\n writeLE,\n} from \"./decaf377.js\";\n\nconst PRECISION = 24;\nfunction requireBytes(value: Uint8Array, length: number, name: string): void {\n if (!(value instanceof Uint8Array) || value.length !== length)\n throw new TypeError(`${name} must be a ${length}-byte Uint8Array`);\n}\nfunction detectionScalar(key: Uint8Array): bigint {\n requireBytes(key, 32, \"Detection key\");\n const scalar = readLE(key);\n if (scalar === 0n || scalar >= FR)\n throw new Error(\"Detection key must be a canonical nonzero Decaf377 scalar\");\n return scalar;\n}\nfunction hash(domain: string, ...parts: Uint8Array[]): Uint8Array {\n // Rust blake2b_simd defaults to 64 output bytes and zero-pads personalization.\n const personalization = new Uint8Array(16);\n personalization.set(utf8ToBytes(`decaf377-fmd.${domain}`));\n return blake2b(concatBytes(...parts), { dkLen: 64, personalization });\n}\nconst hashScalar = (domain: string, ...parts: Uint8Array[]) => readLE(hash(domain, ...parts)) % FR;\nconst childOffset = (clueKey: Uint8Array, index: number) =>\n hashScalar(\"hkd\", clueKey, Uint8Array.of(index));\nconst hashBit = (p: Uint8Array, shared: Uint8Array, q: Uint8Array) =>\n hash(\"bit\", p, shared, q)[0]! & 1;\n\n/** Derive the canonical 32-byte Decaf377 clue key from a nonzero FMD scalar. */\nexport function deriveClueKey(detectionKey: Uint8Array): Uint8Array {\n return encodePoint(multiply(generator, detectionScalar(detectionKey)));\n}\nconst clueKeys = new Map<string, { root: DecafPoint; offsets?: bigint[] }>();\nfunction expandedClueKey(clueKey: Uint8Array) {\n requireBytes(clueKey, 32, \"Clue key\");\n const key = bytesToHex(clueKey);\n let expanded = clueKeys.get(key);\n if (expanded) clueKeys.delete(key);\n else {\n const root = decodePoint(clueKey);\n if (isIdentity(root)) throw new Error(\"Clue key must not be the identity\");\n root._setWindowSize(4);\n expanded = { root };\n }\n clueKeys.set(key, expanded);\n if (clueKeys.size > 8) clueKeys.delete(clueKeys.keys().next().value!);\n return expanded;\n}\nexport function validateClueKey(clueKey: Uint8Array): void {\n expandedClueKey(clueKey);\n}\n/** Create a fixed 24-bit clue using a fresh WebCrypto random seed. */\nexport function createClue(clueKey: Uint8Array): Uint8Array {\n validateClueKey(clueKey);\n return createClueFromSeed(clueKey, secureRandomBytes(32));\n}\n/** Production callers must supply a fresh cryptographically random seed for each clue. */\nexport function createClueFromSeed(clueKey: Uint8Array, seed32: Uint8Array): Uint8Array {\n const expanded = expandedClueKey(clueKey);\n requireBytes(seed32, 32, \"Clue seed\");\n const offsets = (expanded.offsets ??= Array.from({ length: PRECISION }, (_, i) =>\n childOffset(clueKey, i)\n ));\n const r = hashScalar(\"rdv\", clueKey, seed32);\n const z = hashScalar(\"zdv\", clueKey, seed32);\n if (r === 0n) throw new Error(\"Degenerate clue seed\");\n const p = encodePoint(multiply(generator, r));\n const q = encodePoint(multiply(generator, z));\n const ciphertext = new Uint8Array(3);\n const rootShared = multiply(expanded.root, r);\n for (let i = 0; i < PRECISION; i++) {\n const shared = encodePoint(rootShared.add(multiply(generator, (offsets[i]! * r) % FR)));\n ciphertext[i >> 3] = ciphertext[i >> 3]! | ((hashBit(p, shared, q) ^ 1) << (i & 7));\n }\n const m = hashScalar(\"sca\", p, Uint8Array.of(PRECISION), ciphertext);\n const y = ((z - m + FR) * inverseScalar(r)) % FR;\n if (y === 0n) throw new Error(\"Degenerate clue seed\");\n return concatBytes(p, writeLE(y), Uint8Array.of(PRECISION), ciphertext);\n}\n\n/** Check a full-precision clue locally without exporting the detection key. */\nexport function detectClue(detectionKey: Uint8Array, clue: Uint8Array): boolean {\n const scalar = detectionScalar(detectionKey);\n requireBytes(clue, 68, \"Clue\");\n if (clue[64] !== PRECISION) return false;\n const p = clue.slice(0, 32),\n y = readLE(clue.slice(32, 64));\n if (y === 0n || y >= FR) return false;\n let point;\n try {\n point = decodePoint(p);\n } catch {\n return false;\n }\n if (isIdentity(point)) return false;\n const ciphertext = clue.slice(65);\n const m = hashScalar(\"sca\", p, Uint8Array.of(PRECISION), ciphertext);\n const q = encodePoint(multiply(generator, m).add(multiply(point, y)));\n const clueKey = deriveClueKey(detectionKey);\n for (let i = 0; i < PRECISION; i++) {\n const child = (scalar + childOffset(clueKey, i)) % FR;\n const bit = hashBit(p, encodePoint(multiply(point, child)), q);\n if ((bit ^ ((ciphertext[i >> 3]! >> (i & 7)) & 1)) !== 1) return false;\n }\n return true;\n}\n","/**\n * Internal Decaf377 codec, ported from decaf377 0.10.1 min_curve/element.rs.\n * Edwards group/field arithmetic is supplied by @noble/curves 1.9.1. The\n * Montgomery constants below are converted to ordinary field integers.\n * This JavaScript BigInt backend is NOT constant-time and has not been audited.\n */\nimport { twistedEdwards, type ExtPointType } from \"@noble/curves/abstract/edwards\";\nimport { Field, mod } from \"@noble/curves/abstract/modular\";\nimport { blake2b } from \"@noble/hashes/blake2b\";\n\nexport const FQ = 8444461749428370424248824938781546531375899335154063827935233455917409239041n;\nexport const FR = 2111115437357092606062206234695386632838870926408408195193685246394721360383n;\nconst field = Field(FQ, 253, true);\nconst f = (n: bigint) => mod(n, FQ);\nconst abs = (n: bigint) => ((n & 1n) === 0n ? n : f(-n));\n\nexport function secureRandomBytes(length: number): Uint8Array {\n const webCrypto = (\n globalThis as { crypto?: { getRandomValues(array: Uint8Array): Uint8Array } }\n ).crypto;\n if (!webCrypto?.getRandomValues) throw new Error(\"WebCrypto secure randomness is unavailable\");\n return webCrypto.getRandomValues(new Uint8Array(length));\n}\n\nconst curve = twistedEdwards({\n a: FQ - 1n,\n d: 3021n,\n Fp: field,\n n: FR,\n h: 4n,\n Gx: 4959445789346820725352484487855828915252512307947624787834978378872129235627n,\n Gy: 6060471950081851567114691557659790004756535011754163002297540472747064943288n,\n hash: blake2b,\n randomBytes: (length = 32) => secureRandomBytes(length),\n});\nexport type DecafPoint = ExtPointType;\nexport const generator: DecafPoint = curve.ExtendedPoint.BASE;\n\nexport function readLE(bytes: Uint8Array): bigint {\n let n = 0n;\n for (let i = bytes.length - 1; i >= 0; i--) n = (n << 8n) | BigInt(bytes[i]!);\n return n;\n}\nexport function writeLE(n: bigint): Uint8Array {\n const bytes = new Uint8Array(32);\n for (let i = 0; i < 32; i++) {\n bytes[i] = Number(n & 255n);\n n >>= 8n;\n }\n return bytes;\n}\nexport function multiply(point: DecafPoint, scalar: bigint): DecafPoint {\n return scalar === 0n ? curve.ExtendedPoint.ZERO : point.multiply(scalar);\n}\nexport function inverseScalar(scalar: bigint): bigint {\n // Noble's field inversion uses Euclid. Neither this nor BigInt is constant-time.\n return Field(FR).inv(scalar);\n}\n\nconst sqrtOddOrder = (FQ - 1n) >> 47n;\nconst sqrtRootOfUnity = field.pow(11n, sqrtOddOrder);\n\nexport function inverseSquareRoot(denominator: bigint): bigint {\n if (denominator <= 0n || denominator >= FQ)\n throw new Error(\"Invalid Decaf377 square root input\");\n let root = field.pow(denominator, (sqrtOddOrder - 1n) >> 1n);\n let residue = f(root * root * denominator);\n let unity = sqrtRootOfUnity;\n let order = 47;\n while (residue !== 1n) {\n let index = 0;\n let power = residue;\n while (power !== 1n && index < order) {\n power = f(power * power);\n index++;\n }\n if (index >= order) throw new Error(\"Invalid Decaf377 square root\");\n let adjustment = unity;\n for (let i = 0; i < order - index - 1; i++) adjustment = f(adjustment * adjustment);\n root = f(root * adjustment);\n unity = f(adjustment * adjustment);\n residue = f(residue * unity);\n order = index;\n }\n if (f(root * root * denominator) !== 1n) throw new Error(\"Invalid Decaf377 square root\");\n return root;\n}\n\nexport function decodePoint(bytes: Uint8Array): DecafPoint {\n if (!(bytes instanceof Uint8Array) || bytes.length !== 32)\n throw new Error(\"Invalid Decaf377 encoding length\");\n const s = readLE(bytes);\n if (s >= FQ || (s & 1n) !== 0n || bytes[31]! >> 5 !== 0)\n throw new Error(\"Invalid Decaf377 encoding\");\n const ss = f(s * s);\n const u1 = f(1n - ss);\n const u2 = f(u1 * u1 - 4n * 3021n * ss);\n const denominator = f(u2 * u1 * u1);\n if (denominator === 0n) throw new Error(\"Invalid Decaf377 encoding\");\n let v: bigint;\n try {\n v = inverseSquareRoot(denominator);\n } catch {\n throw new Error(\"Invalid Decaf377 encoding\");\n }\n const twoSU1 = f(2n * s * u1);\n if ((f(twoSU1 * v) & 1n) !== 0n) v = f(-v);\n const x = f(twoSU1 * v * v * u2);\n const y = f((1n + ss) * v * u1);\n return curve.ExtendedPoint.fromAffine({ x, y });\n}\nexport function encodePoint(point: DecafPoint): Uint8Array {\n const { ex: x, ez: z, et: t } = point;\n if (x === 0n) return new Uint8Array(32);\n const aMinusD = -3022n;\n const u1 = f((x + t) * (x - t));\n const denominator = f(u1 * aMinusD * x * x);\n const v = inverseSquareRoot(denominator);\n const u2 = abs(f(v * u1));\n const u3 = f(u2 * z - t);\n return writeLE(abs(f(aMinusD * v * u3 * x)));\n}\nexport function isIdentity(point: DecafPoint): boolean {\n return point.ex === 0n;\n}\n","/** A requested permission was not explicitly supplied to this component. */\nexport class MissingCapabilityError extends Error {\n readonly code = \"MISSING_CAPABILITY\";\n constructor(readonly capability: string) {\n super(`Missing ${capability} capability`);\n this.name = \"MissingCapabilityError\";\n }\n}\n","import { MissingCapabilityError } from \"../errors\";\nimport type { ReceivingKeys } from \"../types\";\nimport {\n decodeAddress,\n encodeLongAddress,\n encodeShortAddress,\n type ReceivingAddress as ReceivingData,\n type ReceivingKeyLookup,\n} from \"./address\";\n\n/** Validated public receiving material. A short address requires an explicit resolver. */\nexport class ReceivingAddress {\n readonly #text: string;\n\n private constructor(text: string) {\n const decoded = decodeAddress(text);\n this.#text = decoded.kind === \"short\" ? encodeShortAddress(decoded.ownerAddress) : text;\n Object.freeze(this);\n }\n\n static parse(text: string): ReceivingAddress {\n return new ReceivingAddress(text);\n }\n\n static from(recipient: ReceivingData): ReceivingAddress {\n return new ReceivingAddress(encodeLongAddress(recipient));\n }\n\n static fromIdentity(identity: bigint | `0x${string}`): ReceivingAddress {\n return new ReceivingAddress(encodeShortAddress(identity));\n }\n\n get ownerAddress(): `0x${string}` {\n return decodeAddress(this.#text).ownerAddress;\n }\n\n get kind(): \"long\" | \"short\" {\n return decodeAddress(this.#text).kind;\n }\n\n getReceivingKeys(): ReceivingKeys {\n const decoded = decodeAddress(this.#text);\n if (decoded.kind === \"short\") {\n throw new MissingCapabilityError(\"resolved receiving keys\");\n }\n return { viewingPublicKey: decoded.viewingPublicKey, clueKey: decoded.clueKey };\n }\n\n async resolve(lookup?: ReceivingKeyLookup): Promise<ReceivingAddress> {\n if (this.kind === \"long\") {\n return this;\n }\n if (!lookup) {\n throw new MissingCapabilityError(\"explicit registry lookup\");\n }\n const keys = await lookup(this.ownerAddress);\n if (!keys) {\n throw new Error(\"owner address is not registered\");\n }\n return ReceivingAddress.from({\n ownerAddress: this.ownerAddress,\n viewingPublicKey: keys.viewingPublicKey,\n clueKey: keys.clueKey,\n });\n }\n\n get viewingPublicKey(): Uint8Array {\n return this.getReceivingKeys().viewingPublicKey;\n }\n\n get clueKey(): Uint8Array {\n return this.getReceivingKeys().clueKey;\n }\n\n toString(): string {\n return this.#text;\n }\n\n toJSON(): string {\n return this.#text;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAA0B;AAC1B,kBAA2B;AAC3B,IAAAA,gBAAiE;AACjE,oBAA2B;;;ACK3B,IAAAC,kBAAwB;AACxB,mBAAqD;;;ACHrD,qBAAkD;AAClD,qBAA2B;AAC3B,qBAAwB;AAEjB,IAAM,KAAK;AACX,IAAM,KAAK;AAClB,IAAM,YAAQ,sBAAM,IAAI,KAAK,IAAI;AACjC,IAAM,IAAI,CAAC,UAAc,oBAAI,GAAG,EAAE;AAG3B,SAAS,kBAAkB,QAA4B;AAC1D,QAAM,YACF,WACF;AACF,MAAI,CAAC,WAAW,gBAAiB,OAAM,IAAI,MAAM,4CAA4C;AAC7F,SAAO,UAAU,gBAAgB,IAAI,WAAW,MAAM,CAAC;AAC3D;AAEA,IAAM,YAAQ,+BAAe;AAAA,EACzB,GAAG,KAAK;AAAA,EACR,GAAG;AAAA,EACH,IAAI;AAAA,EACJ,GAAG;AAAA,EACH,GAAG;AAAA,EACH,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa,CAAC,SAAS,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;AAAA,EACrC;AAAA,EAEA,IAAI,OAAyB;AACzB,WAAO,cAAc,KAAK,KAAK,EAAE;AAAA,EACrC;AAAA,EAEA,mBAAkC;AAC9B,UAAM,UAAU,cAAc,KAAK,KAAK;AACxC,QAAI,QAAQ,SAAS,SAAS;AAC1B,YAAM,IAAI,uBAAuB,yBAAyB;AAAA,IAC9D;AACA,WAAO,EAAE,kBAAkB,QAAQ,kBAAkB,SAAS,QAAQ,QAAQ;AAAA,EAClF;AAAA,EAEA,MAAM,QAAQ,QAAwD;AAClE,QAAI,KAAK,SAAS,QAAQ;AACtB,aAAO;AAAA,IACX;AACA,QAAI,CAAC,QAAQ;AACT,YAAM,IAAI,uBAAuB,0BAA0B;AAAA,IAC/D;AACA,UAAM,OAAO,MAAM,OAAO,KAAK,YAAY;AAC3C,QAAI,CAAC,MAAM;AACP,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACrD;AACA,WAAO,kBAAiB,KAAK;AAAA,MACzB,cAAc,KAAK;AAAA,MACnB,kBAAkB,KAAK;AAAA,MACvB,SAAS,KAAK;AAAA,IAClB,CAAC;AAAA,EACL;AAAA,EAEA,IAAI,mBAA+B;AAC/B,WAAO,KAAK,iBAAiB,EAAE;AAAA,EACnC;AAAA,EAEA,IAAI,UAAsB;AACtB,WAAO,KAAK,iBAAiB,EAAE;AAAA,EACnC;AAAA,EAEA,WAAmB;AACf,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,SAAiB;AACb,WAAO,KAAK;AAAA,EAChB;AACJ;","names":["import_utils","import_blake2b"]}
|
package/dist/address.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
validateClueKey
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VXBZSY4Y.js";
|
|
4
4
|
|
|
5
5
|
// src/address/address.ts
|
|
6
6
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
@@ -166,4 +166,4 @@ export {
|
|
|
166
166
|
MissingCapabilityError,
|
|
167
167
|
ReceivingAddress
|
|
168
168
|
};
|
|
169
|
-
//# sourceMappingURL=chunk-
|
|
169
|
+
//# sourceMappingURL=chunk-5KF55DN7.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
validateClueKey
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VXBZSY4Y.js";
|
|
4
4
|
|
|
5
5
|
// src/crypto/domains.ts
|
|
6
6
|
var D_IDENT = 2n;
|
|
@@ -1159,4 +1159,4 @@ export {
|
|
|
1159
1159
|
decryptNotePayload,
|
|
1160
1160
|
decryptCreditPayload
|
|
1161
1161
|
};
|
|
1162
|
-
//# sourceMappingURL=chunk-
|
|
1162
|
+
//# sourceMappingURL=chunk-JRPMFP3G.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
D_NULL,
|
|
3
3
|
FIELD_MODULUS,
|
|
4
4
|
poseidonHash
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-JRPMFP3G.js";
|
|
6
6
|
|
|
7
7
|
// src/notes/nullifier.ts
|
|
8
8
|
async function computeNoteNullifier(chainId, protocolAddress, nonce, commitment) {
|
|
@@ -18,4 +18,4 @@ async function computeNoteNullifier(chainId, protocolAddress, nonce, commitment)
|
|
|
18
18
|
export {
|
|
19
19
|
computeNoteNullifier
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-QLGXGUSB.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/fmd/fmd.ts
|
|
2
2
|
import { blake2b as blake2b2 } from "@noble/hashes/blake2b";
|
|
3
|
-
import { concatBytes, utf8ToBytes } from "@noble/hashes/utils";
|
|
3
|
+
import { bytesToHex, concatBytes, utf8ToBytes } from "@noble/hashes/utils";
|
|
4
4
|
|
|
5
5
|
// src/fmd/decaf377.ts
|
|
6
6
|
import { twistedEdwards } from "@noble/curves/abstract/edwards";
|
|
@@ -47,6 +47,33 @@ function multiply(point, scalar) {
|
|
|
47
47
|
function inverseScalar(scalar) {
|
|
48
48
|
return Field(FR).inv(scalar);
|
|
49
49
|
}
|
|
50
|
+
var sqrtOddOrder = FQ - 1n >> 47n;
|
|
51
|
+
var sqrtRootOfUnity = field.pow(11n, sqrtOddOrder);
|
|
52
|
+
function inverseSquareRoot(denominator) {
|
|
53
|
+
if (denominator <= 0n || denominator >= FQ)
|
|
54
|
+
throw new Error("Invalid Decaf377 square root input");
|
|
55
|
+
let root = field.pow(denominator, sqrtOddOrder - 1n >> 1n);
|
|
56
|
+
let residue = f(root * root * denominator);
|
|
57
|
+
let unity = sqrtRootOfUnity;
|
|
58
|
+
let order = 47;
|
|
59
|
+
while (residue !== 1n) {
|
|
60
|
+
let index = 0;
|
|
61
|
+
let power = residue;
|
|
62
|
+
while (power !== 1n && index < order) {
|
|
63
|
+
power = f(power * power);
|
|
64
|
+
index++;
|
|
65
|
+
}
|
|
66
|
+
if (index >= order) throw new Error("Invalid Decaf377 square root");
|
|
67
|
+
let adjustment = unity;
|
|
68
|
+
for (let i = 0; i < order - index - 1; i++) adjustment = f(adjustment * adjustment);
|
|
69
|
+
root = f(root * adjustment);
|
|
70
|
+
unity = f(adjustment * adjustment);
|
|
71
|
+
residue = f(residue * unity);
|
|
72
|
+
order = index;
|
|
73
|
+
}
|
|
74
|
+
if (f(root * root * denominator) !== 1n) throw new Error("Invalid Decaf377 square root");
|
|
75
|
+
return root;
|
|
76
|
+
}
|
|
50
77
|
function decodePoint(bytes) {
|
|
51
78
|
if (!(bytes instanceof Uint8Array) || bytes.length !== 32)
|
|
52
79
|
throw new Error("Invalid Decaf377 encoding length");
|
|
@@ -60,7 +87,7 @@ function decodePoint(bytes) {
|
|
|
60
87
|
if (denominator === 0n) throw new Error("Invalid Decaf377 encoding");
|
|
61
88
|
let v;
|
|
62
89
|
try {
|
|
63
|
-
v =
|
|
90
|
+
v = inverseSquareRoot(denominator);
|
|
64
91
|
} catch {
|
|
65
92
|
throw new Error("Invalid Decaf377 encoding");
|
|
66
93
|
}
|
|
@@ -76,7 +103,7 @@ function encodePoint(point) {
|
|
|
76
103
|
const aMinusD = -3022n;
|
|
77
104
|
const u1 = f((x + t) * (x - t));
|
|
78
105
|
const denominator = f(u1 * aMinusD * x * x);
|
|
79
|
-
const v =
|
|
106
|
+
const v = inverseSquareRoot(denominator);
|
|
80
107
|
const u2 = abs(f(v * u1));
|
|
81
108
|
const u3 = f(u2 * z - t);
|
|
82
109
|
return writeLE(abs(f(aMinusD * v * u3 * x)));
|
|
@@ -109,27 +136,45 @@ var hashBit = (p, shared, q) => hash("bit", p, shared, q)[0] & 1;
|
|
|
109
136
|
function deriveClueKey(detectionKey) {
|
|
110
137
|
return encodePoint(multiply(generator, detectionScalar(detectionKey)));
|
|
111
138
|
}
|
|
112
|
-
|
|
139
|
+
var clueKeys = /* @__PURE__ */ new Map();
|
|
140
|
+
function expandedClueKey(clueKey) {
|
|
113
141
|
requireBytes(clueKey, 32, "Clue key");
|
|
114
|
-
|
|
142
|
+
const key = bytesToHex(clueKey);
|
|
143
|
+
let expanded = clueKeys.get(key);
|
|
144
|
+
if (expanded) clueKeys.delete(key);
|
|
145
|
+
else {
|
|
146
|
+
const root = decodePoint(clueKey);
|
|
147
|
+
if (isIdentity(root)) throw new Error("Clue key must not be the identity");
|
|
148
|
+
root._setWindowSize(4);
|
|
149
|
+
expanded = { root };
|
|
150
|
+
}
|
|
151
|
+
clueKeys.set(key, expanded);
|
|
152
|
+
if (clueKeys.size > 8) clueKeys.delete(clueKeys.keys().next().value);
|
|
153
|
+
return expanded;
|
|
154
|
+
}
|
|
155
|
+
function validateClueKey(clueKey) {
|
|
156
|
+
expandedClueKey(clueKey);
|
|
115
157
|
}
|
|
116
158
|
function createClue(clueKey) {
|
|
117
159
|
validateClueKey(clueKey);
|
|
118
160
|
return createClueFromSeed(clueKey, secureRandomBytes(32));
|
|
119
161
|
}
|
|
120
162
|
function createClueFromSeed(clueKey, seed32) {
|
|
121
|
-
|
|
163
|
+
const expanded = expandedClueKey(clueKey);
|
|
122
164
|
requireBytes(seed32, 32, "Clue seed");
|
|
123
|
-
const
|
|
165
|
+
const offsets = expanded.offsets ??= Array.from(
|
|
166
|
+
{ length: PRECISION },
|
|
167
|
+
(_, i) => childOffset(clueKey, i)
|
|
168
|
+
);
|
|
124
169
|
const r = hashScalar("rdv", clueKey, seed32);
|
|
125
170
|
const z = hashScalar("zdv", clueKey, seed32);
|
|
126
171
|
if (r === 0n) throw new Error("Degenerate clue seed");
|
|
127
172
|
const p = encodePoint(multiply(generator, r));
|
|
128
173
|
const q = encodePoint(multiply(generator, z));
|
|
129
174
|
const ciphertext = new Uint8Array(3);
|
|
175
|
+
const rootShared = multiply(expanded.root, r);
|
|
130
176
|
for (let i = 0; i < PRECISION; i++) {
|
|
131
|
-
const
|
|
132
|
-
const shared = encodePoint(multiply(child, r));
|
|
177
|
+
const shared = encodePoint(rootShared.add(multiply(generator, offsets[i] * r % FR)));
|
|
133
178
|
ciphertext[i >> 3] = ciphertext[i >> 3] | (hashBit(p, shared, q) ^ 1) << (i & 7);
|
|
134
179
|
}
|
|
135
180
|
const m = hashScalar("sca", p, Uint8Array.of(PRECISION), ciphertext);
|
|
@@ -144,4 +189,4 @@ export {
|
|
|
144
189
|
createClue,
|
|
145
190
|
createClueFromSeed
|
|
146
191
|
};
|
|
147
|
-
//# sourceMappingURL=chunk-
|
|
192
|
+
//# sourceMappingURL=chunk-VXBZSY4Y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/fmd/fmd.ts","../src/fmd/decaf377.ts"],"sourcesContent":["/**\n * Frozen S-FMD profile: decaf377-fmd 2.1.1, 24-bit clues (68 bytes).\n * Only FMD detection keys belong here; these are not transaction ownership keys.\n *\n * SECURITY: the noble Edwards arithmetic and this exact Decaf codec port use\n * JavaScript BigInt. They do not provide constant-time execution or reliable\n * secret erasure. This new composition has not received an independent audit.\n */\nimport { blake2b } from \"@noble/hashes/blake2b\";\nimport { bytesToHex, concatBytes, utf8ToBytes } from \"@noble/hashes/utils\";\nimport {\n FR,\n type DecafPoint,\n decodePoint,\n encodePoint,\n generator,\n inverseScalar,\n isIdentity,\n multiply,\n readLE,\n secureRandomBytes,\n writeLE,\n} from \"./decaf377.js\";\n\nconst PRECISION = 24;\nfunction requireBytes(value: Uint8Array, length: number, name: string): void {\n if (!(value instanceof Uint8Array) || value.length !== length)\n throw new TypeError(`${name} must be a ${length}-byte Uint8Array`);\n}\nfunction detectionScalar(key: Uint8Array): bigint {\n requireBytes(key, 32, \"Detection key\");\n const scalar = readLE(key);\n if (scalar === 0n || scalar >= FR)\n throw new Error(\"Detection key must be a canonical nonzero Decaf377 scalar\");\n return scalar;\n}\nfunction hash(domain: string, ...parts: Uint8Array[]): Uint8Array {\n // Rust blake2b_simd defaults to 64 output bytes and zero-pads personalization.\n const personalization = new Uint8Array(16);\n personalization.set(utf8ToBytes(`decaf377-fmd.${domain}`));\n return blake2b(concatBytes(...parts), { dkLen: 64, personalization });\n}\nconst hashScalar = (domain: string, ...parts: Uint8Array[]) => readLE(hash(domain, ...parts)) % FR;\nconst childOffset = (clueKey: Uint8Array, index: number) =>\n hashScalar(\"hkd\", clueKey, Uint8Array.of(index));\nconst hashBit = (p: Uint8Array, shared: Uint8Array, q: Uint8Array) =>\n hash(\"bit\", p, shared, q)[0]! & 1;\n\n/** Derive the canonical 32-byte Decaf377 clue key from a nonzero FMD scalar. */\nexport function deriveClueKey(detectionKey: Uint8Array): Uint8Array {\n return encodePoint(multiply(generator, detectionScalar(detectionKey)));\n}\nconst clueKeys = new Map<string, { root: DecafPoint; offsets?: bigint[] }>();\nfunction expandedClueKey(clueKey: Uint8Array) {\n requireBytes(clueKey, 32, \"Clue key\");\n const key = bytesToHex(clueKey);\n let expanded = clueKeys.get(key);\n if (expanded) clueKeys.delete(key);\n else {\n const root = decodePoint(clueKey);\n if (isIdentity(root)) throw new Error(\"Clue key must not be the identity\");\n root._setWindowSize(4);\n expanded = { root };\n }\n clueKeys.set(key, expanded);\n if (clueKeys.size > 8) clueKeys.delete(clueKeys.keys().next().value!);\n return expanded;\n}\nexport function validateClueKey(clueKey: Uint8Array): void {\n expandedClueKey(clueKey);\n}\n/** Create a fixed 24-bit clue using a fresh WebCrypto random seed. */\nexport function createClue(clueKey: Uint8Array): Uint8Array {\n validateClueKey(clueKey);\n return createClueFromSeed(clueKey, secureRandomBytes(32));\n}\n/** Production callers must supply a fresh cryptographically random seed for each clue. */\nexport function createClueFromSeed(clueKey: Uint8Array, seed32: Uint8Array): Uint8Array {\n const expanded = expandedClueKey(clueKey);\n requireBytes(seed32, 32, \"Clue seed\");\n const offsets = (expanded.offsets ??= Array.from({ length: PRECISION }, (_, i) =>\n childOffset(clueKey, i)\n ));\n const r = hashScalar(\"rdv\", clueKey, seed32);\n const z = hashScalar(\"zdv\", clueKey, seed32);\n if (r === 0n) throw new Error(\"Degenerate clue seed\");\n const p = encodePoint(multiply(generator, r));\n const q = encodePoint(multiply(generator, z));\n const ciphertext = new Uint8Array(3);\n const rootShared = multiply(expanded.root, r);\n for (let i = 0; i < PRECISION; i++) {\n const shared = encodePoint(rootShared.add(multiply(generator, (offsets[i]! * r) % FR)));\n ciphertext[i >> 3] = ciphertext[i >> 3]! | ((hashBit(p, shared, q) ^ 1) << (i & 7));\n }\n const m = hashScalar(\"sca\", p, Uint8Array.of(PRECISION), ciphertext);\n const y = ((z - m + FR) * inverseScalar(r)) % FR;\n if (y === 0n) throw new Error(\"Degenerate clue seed\");\n return concatBytes(p, writeLE(y), Uint8Array.of(PRECISION), ciphertext);\n}\n\n/** Check a full-precision clue locally without exporting the detection key. */\nexport function detectClue(detectionKey: Uint8Array, clue: Uint8Array): boolean {\n const scalar = detectionScalar(detectionKey);\n requireBytes(clue, 68, \"Clue\");\n if (clue[64] !== PRECISION) return false;\n const p = clue.slice(0, 32),\n y = readLE(clue.slice(32, 64));\n if (y === 0n || y >= FR) return false;\n let point;\n try {\n point = decodePoint(p);\n } catch {\n return false;\n }\n if (isIdentity(point)) return false;\n const ciphertext = clue.slice(65);\n const m = hashScalar(\"sca\", p, Uint8Array.of(PRECISION), ciphertext);\n const q = encodePoint(multiply(generator, m).add(multiply(point, y)));\n const clueKey = deriveClueKey(detectionKey);\n for (let i = 0; i < PRECISION; i++) {\n const child = (scalar + childOffset(clueKey, i)) % FR;\n const bit = hashBit(p, encodePoint(multiply(point, child)), q);\n if ((bit ^ ((ciphertext[i >> 3]! >> (i & 7)) & 1)) !== 1) return false;\n }\n return true;\n}\n","/**\n * Internal Decaf377 codec, ported from decaf377 0.10.1 min_curve/element.rs.\n * Edwards group/field arithmetic is supplied by @noble/curves 1.9.1. The\n * Montgomery constants below are converted to ordinary field integers.\n * This JavaScript BigInt backend is NOT constant-time and has not been audited.\n */\nimport { twistedEdwards, type ExtPointType } from \"@noble/curves/abstract/edwards\";\nimport { Field, mod } from \"@noble/curves/abstract/modular\";\nimport { blake2b } from \"@noble/hashes/blake2b\";\n\nexport const FQ = 8444461749428370424248824938781546531375899335154063827935233455917409239041n;\nexport const FR = 2111115437357092606062206234695386632838870926408408195193685246394721360383n;\nconst field = Field(FQ, 253, true);\nconst f = (n: bigint) => mod(n, FQ);\nconst abs = (n: bigint) => ((n & 1n) === 0n ? n : f(-n));\n\nexport function secureRandomBytes(length: number): Uint8Array {\n const webCrypto = (\n globalThis as { crypto?: { getRandomValues(array: Uint8Array): Uint8Array } }\n ).crypto;\n if (!webCrypto?.getRandomValues) throw new Error(\"WebCrypto secure randomness is unavailable\");\n return webCrypto.getRandomValues(new Uint8Array(length));\n}\n\nconst curve = twistedEdwards({\n a: FQ - 1n,\n d: 3021n,\n Fp: field,\n n: FR,\n h: 4n,\n Gx: 4959445789346820725352484487855828915252512307947624787834978378872129235627n,\n Gy: 6060471950081851567114691557659790004756535011754163002297540472747064943288n,\n hash: blake2b,\n randomBytes: (length = 32) => secureRandomBytes(length),\n});\nexport type DecafPoint = ExtPointType;\nexport const generator: DecafPoint = curve.ExtendedPoint.BASE;\n\nexport function readLE(bytes: Uint8Array): bigint {\n let n = 0n;\n for (let i = bytes.length - 1; i >= 0; i--) n = (n << 8n) | BigInt(bytes[i]!);\n return n;\n}\nexport function writeLE(n: bigint): Uint8Array {\n const bytes = new Uint8Array(32);\n for (let i = 0; i < 32; i++) {\n bytes[i] = Number(n & 255n);\n n >>= 8n;\n }\n return bytes;\n}\nexport function multiply(point: DecafPoint, scalar: bigint): DecafPoint {\n return scalar === 0n ? curve.ExtendedPoint.ZERO : point.multiply(scalar);\n}\nexport function inverseScalar(scalar: bigint): bigint {\n // Noble's field inversion uses Euclid. Neither this nor BigInt is constant-time.\n return Field(FR).inv(scalar);\n}\n\nconst sqrtOddOrder = (FQ - 1n) >> 47n;\nconst sqrtRootOfUnity = field.pow(11n, sqrtOddOrder);\n\nexport function inverseSquareRoot(denominator: bigint): bigint {\n if (denominator <= 0n || denominator >= FQ)\n throw new Error(\"Invalid Decaf377 square root input\");\n let root = field.pow(denominator, (sqrtOddOrder - 1n) >> 1n);\n let residue = f(root * root * denominator);\n let unity = sqrtRootOfUnity;\n let order = 47;\n while (residue !== 1n) {\n let index = 0;\n let power = residue;\n while (power !== 1n && index < order) {\n power = f(power * power);\n index++;\n }\n if (index >= order) throw new Error(\"Invalid Decaf377 square root\");\n let adjustment = unity;\n for (let i = 0; i < order - index - 1; i++) adjustment = f(adjustment * adjustment);\n root = f(root * adjustment);\n unity = f(adjustment * adjustment);\n residue = f(residue * unity);\n order = index;\n }\n if (f(root * root * denominator) !== 1n) throw new Error(\"Invalid Decaf377 square root\");\n return root;\n}\n\nexport function decodePoint(bytes: Uint8Array): DecafPoint {\n if (!(bytes instanceof Uint8Array) || bytes.length !== 32)\n throw new Error(\"Invalid Decaf377 encoding length\");\n const s = readLE(bytes);\n if (s >= FQ || (s & 1n) !== 0n || bytes[31]! >> 5 !== 0)\n throw new Error(\"Invalid Decaf377 encoding\");\n const ss = f(s * s);\n const u1 = f(1n - ss);\n const u2 = f(u1 * u1 - 4n * 3021n * ss);\n const denominator = f(u2 * u1 * u1);\n if (denominator === 0n) throw new Error(\"Invalid Decaf377 encoding\");\n let v: bigint;\n try {\n v = inverseSquareRoot(denominator);\n } catch {\n throw new Error(\"Invalid Decaf377 encoding\");\n }\n const twoSU1 = f(2n * s * u1);\n if ((f(twoSU1 * v) & 1n) !== 0n) v = f(-v);\n const x = f(twoSU1 * v * v * u2);\n const y = f((1n + ss) * v * u1);\n return curve.ExtendedPoint.fromAffine({ x, y });\n}\nexport function encodePoint(point: DecafPoint): Uint8Array {\n const { ex: x, ez: z, et: t } = point;\n if (x === 0n) return new Uint8Array(32);\n const aMinusD = -3022n;\n const u1 = f((x + t) * (x - t));\n const denominator = f(u1 * aMinusD * x * x);\n const v = inverseSquareRoot(denominator);\n const u2 = abs(f(v * u1));\n const u3 = f(u2 * z - t);\n return writeLE(abs(f(aMinusD * v * u3 * x)));\n}\nexport function isIdentity(point: DecafPoint): boolean {\n return point.ex === 0n;\n}\n"],"mappings":";AAQA,SAAS,WAAAA,gBAAe;AACxB,SAAS,YAAY,aAAa,mBAAmB;;;ACHrD,SAAS,sBAAyC;AAClD,SAAS,OAAO,WAAW;AAC3B,SAAS,eAAe;AAEjB,IAAM,KAAK;AACX,IAAM,KAAK;AAClB,IAAM,QAAQ,MAAM,IAAI,KAAK,IAAI;AACjC,IAAM,IAAI,CAAC,MAAc,IAAI,GAAG,EAAE;AAClC,IAAM,MAAM,CAAC,OAAgB,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC,CAAC;AAE/C,SAAS,kBAAkB,QAA4B;AAC1D,QAAM,YACF,WACF;AACF,MAAI,CAAC,WAAW,gBAAiB,OAAM,IAAI,MAAM,4CAA4C;AAC7F,SAAO,UAAU,gBAAgB,IAAI,WAAW,MAAM,CAAC;AAC3D;AAEA,IAAM,QAAQ,eAAe;AAAA,EACzB,GAAG,KAAK;AAAA,EACR,GAAG;AAAA,EACH,IAAI;A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