@sig-net/midnight 0.20.0-rc.1 → 0.21.0-rc.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.
- package/README.md +17 -325
- package/dist/compact-descriptors.d.ts +10 -0
- package/dist/compact-descriptors.d.ts.map +1 -1
- package/dist/compact-descriptors.js +27 -4
- package/dist/compact-descriptors.js.map +1 -1
- package/dist/ecdsa-attestation.d.ts +23 -7
- package/dist/ecdsa-attestation.d.ts.map +1 -1
- package/dist/ecdsa-attestation.js +50 -8
- package/dist/ecdsa-attestation.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/managed/compiler/contract-manifest.json +4 -4
- package/dist/managed/contract/index.js +86 -185
- package/dist/managed/contract/index.js.map +1 -1
- package/dist/signet-contract-events.d.ts +12 -3
- package/dist/signet-contract-events.d.ts.map +1 -1
- package/dist/signet-contract-events.js +11 -4
- package/dist/signet-contract-events.js.map +1 -1
- package/dist/signet-request-id.d.ts +2 -4
- package/dist/signet-request-id.d.ts.map +1 -1
- package/dist/signet-request-id.js +4 -6
- package/dist/signet-request-id.js.map +1 -1
- package/dist/signet-requests.d.ts +2 -2
- package/dist/signet-requests.d.ts.map +1 -1
- package/dist/signet-requests.js +7 -8
- package/dist/signet-requests.js.map +1 -1
- package/package.json +2 -2
- package/src/Signet.compact +66 -45
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
// signet-requests.ts). Chain-agnostic entry point that resolves each
|
|
4
4
|
// record's tx-params descriptor by its `txParamType` tag, so every
|
|
5
5
|
// decomposition mints ids through this one function.
|
|
6
|
-
import {
|
|
6
|
+
import { transientHash, upgradeFromTransient } from "@midnight-ntwrk/compact-runtime";
|
|
7
7
|
import { evmType2TxParamsDescriptorOf } from "./signet-evtype2tx-requests.js";
|
|
8
8
|
import { signBidirectionalEventDescriptorWith, TxParamType, } from "./signet-requests.js";
|
|
9
9
|
/**
|
|
10
|
-
* Canonical id of a signet request: the
|
|
11
|
-
*
|
|
12
|
-
* record exactly as the ledger stores it, unused slots included and schemas
|
|
13
|
-
* at their declared widths.
|
|
10
|
+
* Canonical id of a signet request: the transientHash (Poseidon) of the
|
|
11
|
+
* entire event record over its field-aligned representation.
|
|
14
12
|
*
|
|
15
13
|
* @param request - The full event record (contract-shaped, all slots).
|
|
16
14
|
* @returns The 32-byte request id, the record's ledger map key.
|
|
@@ -22,6 +20,6 @@ export function calculateRequestId(request) {
|
|
|
22
20
|
throw new Error(`unsupported txParamType ${String(request.txParamType)}: this id computation ` +
|
|
23
21
|
`understands evmType2 (${String(TxParamType.evmType2)})`);
|
|
24
22
|
}
|
|
25
|
-
return
|
|
23
|
+
return upgradeFromTransient(transientHash(signBidirectionalEventDescriptorWith(evmType2TxParamsDescriptorOf(request.txParams), request.outputDeserializationSchema.length, request.respondSerializationSchema.length), request));
|
|
26
24
|
}
|
|
27
25
|
//# sourceMappingURL=signet-request-id.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-request-id.js","sourceRoot":"","sources":["../src/signet-request-id.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,0DAA0D;AAC1D,qEAAqE;AACrE,mEAAmE;AACnE,qDAAqD;AAErD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"signet-request-id.js","sourceRoot":"","sources":["../src/signet-request-id.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,0DAA0D;AAC1D,qEAAqE;AACrE,mEAAmE;AACnE,qDAAqD;AAErD,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAGL,oCAAoC,EACpC,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA+B;IAChE,IAAI,OAAO,CAAC,WAAW,KAAK,WAAW,CAAC,QAAQ,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CACb,2BAA2B,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,wBAAwB;YAC5E,yBAAyB,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAC3D,CAAC;IACJ,CAAC;IACD,OAAO,oBAAoB,CACzB,aAAa,CACX,oCAAoC,CAClC,4BAA4B,CAAC,OAAO,CAAC,QAAQ,CAAC,EAC9C,OAAO,CAAC,2BAA2B,CAAC,MAAM,EAC1C,OAAO,CAAC,0BAA0B,CAAC,MAAM,CAC1C,EACD,OAAO,CACR,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -24,8 +24,8 @@ export declare const TxParamType: {
|
|
|
24
24
|
readonly evmType2: 0;
|
|
25
25
|
/**
|
|
26
26
|
* Never emitted: the Compact-side padding variant that keeps the enum at
|
|
27
|
-
* >= 2 variants
|
|
28
|
-
* cannot parse inside
|
|
27
|
+
* >= 2 variants, so it compiles to a one-byte value rather than a
|
|
28
|
+
* zero-byte one the proof server cannot parse inside a hash preimage.
|
|
29
29
|
*/
|
|
30
30
|
readonly reserved: 1;
|
|
31
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-requests.d.ts","sourceRoot":"","sources":["../src/signet-requests.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAKL,KAAK,eAAe,EAGrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGvE,YAAY,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAEvE;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,SAAS,CAAY,C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BAAsB,CAAC,CAAC,GACzD,2BAA2B,CAM7B"}
|
package/dist/signet-requests.js
CHANGED
|
@@ -28,8 +28,8 @@ export const TxParamType = {
|
|
|
28
28
|
evmType2: 0,
|
|
29
29
|
/**
|
|
30
30
|
* Never emitted: the Compact-side padding variant that keeps the enum at
|
|
31
|
-
* >= 2 variants
|
|
32
|
-
* cannot parse inside
|
|
31
|
+
* >= 2 variants, so it compiles to a one-byte value rather than a
|
|
32
|
+
* zero-byte one the proof server cannot parse inside a hash preimage.
|
|
33
33
|
*/
|
|
34
34
|
reserved: 1,
|
|
35
35
|
};
|
|
@@ -60,16 +60,15 @@ export const MPCDestination = {
|
|
|
60
60
|
// tx-params type and schema lengths, and the Compact compiler cannot export
|
|
61
61
|
// type-parameterised circuits from the top level, so the record descriptor
|
|
62
62
|
// (and `calculateRequestId` built on it, see signet-request-id.ts) gets a TS
|
|
63
|
-
// twin here. Ids come from the same
|
|
64
|
-
//
|
|
65
|
-
// Signet.compact is enforced by test-caller-contract's
|
|
63
|
+
// twin here. Ids come from the same `transientHash` runtime builtin compiled
|
|
64
|
+
// circuits call. Lockstep with Signet.compact is enforced by test-caller-contract's
|
|
66
65
|
// "submitSignatureRequest round-trip" test, which asserts the id computed
|
|
67
66
|
// here equals the ledger map key minted by the compiled contract.
|
|
68
67
|
// Runtime descriptors of the signet enums, at the literals the compiler
|
|
69
68
|
// emits. NOTE: a 1-variant enum would compile to `CompactTypeEnum(0, 0)`,
|
|
70
|
-
// zero bytes, which the proof server cannot parse inside
|
|
71
|
-
//
|
|
72
|
-
//
|
|
69
|
+
// zero bytes, which the proof server cannot parse inside a hash preimage.
|
|
70
|
+
// Every enum therefore carries a padding `reserved` variant so it stays at
|
|
71
|
+
// (1, 1). The Compact-generic base descriptors live in
|
|
73
72
|
// compact-descriptors.ts.
|
|
74
73
|
const TX_PARAM_TYPE = new CompactTypeEnum(1, 1);
|
|
75
74
|
const MPC_SIGNATURE_ALGORITHM = new CompactTypeEnum(1, 1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-requests.js","sourceRoot":"","sources":["../src/signet-requests.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,qCAAqC;AACrC,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,8CAA8C;AAC9C,yDAAyD;AAEzD,OAAO,EAEL,gBAAgB,EAChB,eAAe,GAChB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,uBAAuB,EACvB,gBAAgB,EAEhB,MAAM,EACN,OAAO,GACR,MAAM,0BAA0B,CAAC;AAYlC;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAA2B,QAAQ,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,sFAAsF;IACtF,QAAQ,EAAE,CAAC;IACX;;;;OAIG;IACH,QAAQ,EAAE,CAAC;CACH,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,4BAA4B;IAC5B,KAAK,EAAE,CAAC;IACR,0EAA0E;IAC1E,QAAQ,EAAE,CAAC;CACH,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,sCAAsC;IACtC,MAAM,EAAE,CAAC;IACT,0EAA0E;IAC1E,QAAQ,EAAE,CAAC;CACH,CAAC;AAqCX,+EAA+E;AAC/E,EAAE;AACF,0EAA0E;AAC1E,0EAA0E;AAC1E,4EAA4E;AAC5E,2EAA2E;AAC3E,6EAA6E;AAC7E,
|
|
1
|
+
{"version":3,"file":"signet-requests.js","sourceRoot":"","sources":["../src/signet-requests.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2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BAA6B,CAC3C,WAA0D;IAE1D,MAAM,KAAK,GAAgC,IAAI,GAAG,EAAE,CAAC;IACrD,KAAK,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,WAAW,EAAE,CAAC;QAC/C,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sig-net/midnight",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0-rc.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sig-net/midnight-integration",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@midnight-ntwrk/compact-runtime": "0.18.0-rc.1",
|
|
49
49
|
"@midnight-ntwrk/midnight-js-types": "5.0.0-beta.6",
|
|
50
50
|
"@noble/curves": "^2.2.0",
|
|
51
|
-
"@sig-net/midnight-serde": "^0.
|
|
51
|
+
"@sig-net/midnight-serde": "^0.21.0-rc.2",
|
|
52
52
|
"ethers": "^6.17.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
package/src/Signet.compact
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
//
|
|
20
20
|
// Key types at a glance (each declaration below carries the full contract):
|
|
21
21
|
// - SignBidirectionalEvent: a client contract's structured request for a signature on a transaction.
|
|
22
|
-
// - RequestId: 32-byte id of a request, the
|
|
22
|
+
// - RequestId: 32-byte id of a request, the transientHash of the whole SignBidirectionalEvent record.
|
|
23
23
|
// - SignBidirectionalEventMap: the RequestId -> SignBidirectionalEvent map a client contract
|
|
24
24
|
// declares in its own ledger for the MPC to read requests from.
|
|
25
25
|
// - SignetSigner: the contract interface client contracts call to notify the Signet singleton.
|
|
@@ -166,17 +166,26 @@ module Signet {
|
|
|
166
166
|
|
|
167
167
|
// ---- SignBidirectionalEvent RequestId --------------------------------------------------------------
|
|
168
168
|
|
|
169
|
-
// 32 byte chain agnostic nominal id, calculated as
|
|
169
|
+
// 32 byte chain agnostic nominal id, calculated as the transientHash of the whole
|
|
170
170
|
// SignBidirectionalEvent record (see calculateRequestId).
|
|
171
171
|
export new type RequestId = Bytes<32>;
|
|
172
172
|
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
// the field-aligned
|
|
173
|
+
// transientHash (Poseidon over the record's field-aligned representation) upgraded
|
|
174
|
+
// to Bytes<32>: the id commits to every field, including the sender, and carries no
|
|
175
|
+
// domain-separation tag. Off-chain twins must reproduce the field-aligned layout
|
|
176
|
+
// exactly.
|
|
177
|
+
//
|
|
178
|
+
// Two properties follow from the field-aligned representation and matter to anyone
|
|
179
|
+
// reasoning about these ids:
|
|
180
|
+
// - byte 31 is always zero. upgradeFromTransient writes the field element's 31
|
|
181
|
+
// little-endian bytes into bytes 0..30, so an id carries ~248 bits of entropy.
|
|
182
|
+
// - a Bytes<N> field packs into ceil(N/31) field elements, so trailing zero bytes
|
|
183
|
+
// within a chunk do not change the hash. Widths here are fixed at compile time
|
|
184
|
+
// and every id commits to its sender, so requests cannot collide in practice.
|
|
176
185
|
export pure circuit calculateRequestId<TxParams, #LenOutputDeserialization, #LenRespondSerialization>(
|
|
177
186
|
request: SignBidirectionalEvent<TxParams, LenOutputDeserialization, LenRespondSerialization>
|
|
178
187
|
): RequestId {
|
|
179
|
-
return
|
|
188
|
+
return upgradeFromTransient(transientHash<SignBidirectionalEvent<TxParams, LenOutputDeserialization, LenRespondSerialization>>(request)) as RequestId;
|
|
180
189
|
}
|
|
181
190
|
|
|
182
191
|
// ---- Client Contract: SignBidirectionalEvent Map ---------------------------------------------------
|
|
@@ -278,7 +287,7 @@ module Signet {
|
|
|
278
287
|
// RespondBidirectionalEvent: the MPC's attestation of a foreign execution, the
|
|
279
288
|
// final step of the sign bidirectional flow.
|
|
280
289
|
//
|
|
281
|
-
// attestationDigest =
|
|
290
|
+
// attestationDigest = upgradeFromTransient(transientHash([requestId, serializedOutput]))
|
|
282
291
|
// signature = signSECP256k1(mpcResponseKey, attestationDigest)
|
|
283
292
|
//
|
|
284
293
|
// mpcResponseKey is derived like request signing keys, with the path set to the
|
|
@@ -296,34 +305,29 @@ module Signet {
|
|
|
296
305
|
}
|
|
297
306
|
|
|
298
307
|
// The 32-byte attestation digest of a remote execution output:
|
|
299
|
-
// attestationDigest =
|
|
300
|
-
//
|
|
301
|
-
//
|
|
308
|
+
// attestationDigest = upgradeFromTransient(transientHash([requestId, serializedOutput]))
|
|
309
|
+
// Off-chain code uses the TypeScript twin:
|
|
310
|
+
// import { calculateSignetAttestationDigest } from "@sig-net/midnight";
|
|
302
311
|
export pure circuit calculateSignetAttestationDigest<#serializedOutputLength>(
|
|
303
312
|
requestId: RequestId,
|
|
304
313
|
serializedOutput: Bytes<serializedOutputLength>,
|
|
305
314
|
): Bytes<32> {
|
|
306
|
-
return
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// Byte-order adapter: stored records are big-endian, the scalar casts read
|
|
310
|
-
// little-endian.
|
|
311
|
-
pure circuit reverseBytes32(b: Bytes<32>): Bytes<32> {
|
|
312
|
-
const v = b as Vector<32, Uint<8>>;
|
|
313
|
-
return Bytes[v[31], v[30], v[29], v[28], v[27], v[26], v[25], v[24],
|
|
314
|
-
v[23], v[22], v[21], v[20], v[19], v[18], v[17], v[16],
|
|
315
|
-
v[15], v[14], v[13], v[12], v[11], v[10], v[9], v[8],
|
|
316
|
-
v[7], v[6], v[5], v[4], v[3], v[2], v[1], v[0]];
|
|
315
|
+
return upgradeFromTransient(transientHash<[RequestId, Bytes<serializedOutputLength>]>([requestId, serializedOutput]));
|
|
317
316
|
}
|
|
318
317
|
|
|
319
318
|
// Verifies a RespondBidirectionalEvent against its execution output and MPC
|
|
320
319
|
// response key: recomputes the attestation digest and checks the ECDSA
|
|
321
320
|
// signature over it. Client contracts run this before consuming outputs, as
|
|
322
321
|
// the singleton emits responses unverified. The caller supplies
|
|
323
|
-
// serializedOutput at its exact unpadded width and the event record
|
|
324
|
-
//
|
|
325
|
-
//
|
|
326
|
-
//
|
|
322
|
+
// serializedOutput at its exact unpadded width, and the event record with
|
|
323
|
+
// signature.bigR.x and signature.s byte-reversed into LITTLE-endian: the
|
|
324
|
+
// scalar casts below read little-endian bytes, and the wire/ledger records
|
|
325
|
+
// are big-endian, so the reversal happens off-chain where it costs nothing
|
|
326
|
+
// (the TS SDK's respondBidirectionalEventToCircuitInput does it). A wrong
|
|
327
|
+
// byte order fails verification, never a false accept. Only bigR.x and s
|
|
328
|
+
// enter verification. An s that reduces to 0 mod the curve order aborts the
|
|
329
|
+
// circuit rather than returning false, so sift candidate posts off chain
|
|
330
|
+
// first (verifyRespondBidirectionalSignature).
|
|
327
331
|
export pure circuit verifyRespondBidirectionalEvent<#serializedOutputLength>(
|
|
328
332
|
requestId: RequestId,
|
|
329
333
|
serializedOutput: Bytes<serializedOutputLength>,
|
|
@@ -338,8 +342,8 @@ module Signet {
|
|
|
338
342
|
return secp256k1EcdsaVerify(
|
|
339
343
|
digest,
|
|
340
344
|
Secp256k1EcdsaSignature {
|
|
341
|
-
r:
|
|
342
|
-
s:
|
|
345
|
+
r: respondBidirectionalEvent.signature.bigR.x as Secp256k1Scalar,
|
|
346
|
+
s: respondBidirectionalEvent.signature.s as Secp256k1Scalar,
|
|
343
347
|
},
|
|
344
348
|
mpcResponseKey
|
|
345
349
|
);
|
|
@@ -433,25 +437,42 @@ module Signet {
|
|
|
433
437
|
|
|
434
438
|
// Read a numeric ABI word back into a Uint<128>: the inverse of
|
|
435
439
|
// numericAbiWord. Asserts the leading 16 bytes are zero (a canonical
|
|
436
|
-
// Uint<128> word).
|
|
440
|
+
// Uint<128> word). Decomposes the word into bytes exactly once (each
|
|
441
|
+
// slice would redecompose the whole word) and folds v[16..31] by Horner.
|
|
437
442
|
export pure circuit abiWordToUint128(word: Bytes<32>): Uint<128> {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
443
|
+
const v = word as Vector<32, Uint<8>>;
|
|
444
|
+
assert(v[0] == 0, "ABI word exceeds Uint<128>");
|
|
445
|
+
assert(v[1] == 0, "ABI word exceeds Uint<128>");
|
|
446
|
+
assert(v[2] == 0, "ABI word exceeds Uint<128>");
|
|
447
|
+
assert(v[3] == 0, "ABI word exceeds Uint<128>");
|
|
448
|
+
assert(v[4] == 0, "ABI word exceeds Uint<128>");
|
|
449
|
+
assert(v[5] == 0, "ABI word exceeds Uint<128>");
|
|
450
|
+
assert(v[6] == 0, "ABI word exceeds Uint<128>");
|
|
451
|
+
assert(v[7] == 0, "ABI word exceeds Uint<128>");
|
|
452
|
+
assert(v[8] == 0, "ABI word exceeds Uint<128>");
|
|
453
|
+
assert(v[9] == 0, "ABI word exceeds Uint<128>");
|
|
454
|
+
assert(v[10] == 0, "ABI word exceeds Uint<128>");
|
|
455
|
+
assert(v[11] == 0, "ABI word exceeds Uint<128>");
|
|
456
|
+
assert(v[12] == 0, "ABI word exceeds Uint<128>");
|
|
457
|
+
assert(v[13] == 0, "ABI word exceeds Uint<128>");
|
|
458
|
+
assert(v[14] == 0, "ABI word exceeds Uint<128>");
|
|
459
|
+
assert(v[15] == 0, "ABI word exceeds Uint<128>");
|
|
460
|
+
const b0 = v[16] as Field;
|
|
461
|
+
const b1 = b0 * 256 + (v[17] as Field);
|
|
462
|
+
const b2 = b1 * 256 + (v[18] as Field);
|
|
463
|
+
const b3 = b2 * 256 + (v[19] as Field);
|
|
464
|
+
const b4 = b3 * 256 + (v[20] as Field);
|
|
465
|
+
const b5 = b4 * 256 + (v[21] as Field);
|
|
466
|
+
const b6 = b5 * 256 + (v[22] as Field);
|
|
467
|
+
const b7 = b6 * 256 + (v[23] as Field);
|
|
468
|
+
const b8 = b7 * 256 + (v[24] as Field);
|
|
469
|
+
const b9 = b8 * 256 + (v[25] as Field);
|
|
470
|
+
const b10 = b9 * 256 + (v[26] as Field);
|
|
471
|
+
const b11 = b10 * 256 + (v[27] as Field);
|
|
472
|
+
const b12 = b11 * 256 + (v[28] as Field);
|
|
473
|
+
const b13 = b12 * 256 + (v[29] as Field);
|
|
474
|
+
const b14 = b13 * 256 + (v[30] as Field);
|
|
475
|
+
const b15 = b14 * 256 + (v[31] as Field);
|
|
455
476
|
return b15 as Uint<128>;
|
|
456
477
|
}
|
|
457
478
|
|