@sig-net/midnight-signer 0.0.0-stage → 0.26.0-rc.11
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 +31 -2
- package/dist/contract-surface.d.ts +20 -0
- package/dist/contract-surface.d.ts.map +1 -0
- package/dist/contract-surface.js +15 -0
- package/dist/contract-surface.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/managed/compiler/contract-info.json +60 -0
- package/dist/managed/compiler/contract-manifest.json +59 -0
- package/dist/managed/contract/index.d.ts +43 -0
- package/dist/managed/contract/index.js +286 -0
- package/dist/managed/contract/index.js.map +8 -0
- package/dist/managed/keys/signBidirectional.prover +4 -0
- package/dist/managed/keys/signBidirectional.verifier +0 -0
- package/dist/managed/zkir/signBidirectional.bzkir +0 -0
- package/dist/managed/zkir/signBidirectional.zkir +710 -0
- package/dist/witnesses.d.ts +15 -0
- package/dist/witnesses.d.ts.map +1 -0
- package/dist/witnesses.js +15 -0
- package/dist/witnesses.js.map +1 -0
- package/package.json +51 -3
package/README.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @sig-net/midnight-signer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The central [Sig Network](https://sig.network) signet signer on the [Midnight blockchain](https://midnight.network): the contract that exposes the MPC's [sign bidirectional flow](https://github.com/sig-net/midnight-integration/blob/main/README.md#sign-bidirectional-protocol-flow) to other Midnight contracts. Integrating contracts notify it of their requests through `signBidirectional`, which emits a named contract event the MPC polls. The MPC posts its responses to the [signet responder](https://www.npmjs.com/package/@sig-net/midnight-responder), and clients poll that contract's events.
|
|
4
|
+
|
|
5
|
+
## What is in it
|
|
6
|
+
|
|
7
|
+
- The curated export surface (package root): the generated contract module (`Contract`), the handwritten witnesses, and the platform-agnostic contract surface (circuit ids and the provider type).
|
|
8
|
+
- The `./managed/*` subpath export: the compiled contract assets (compiler output, `zkir/`, prover/verifier `keys/`) so runtimes can fetch them as files. The published package always carries the proving keys.
|
|
9
|
+
|
|
10
|
+
Consumers import the package root. The `./managed/*` paths exist only for runtimes that load zk assets.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install @sig-net/midnight-signer
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Documentation
|
|
19
|
+
|
|
20
|
+
The protocol and integration documentation lives in the [sig-net/midnight-integration README](https://github.com/sig-net/midnight-integration/blob/main/README.md):
|
|
21
|
+
|
|
22
|
+
- [Sign Bidirectional Flow](https://github.com/sig-net/midnight-integration/blob/main/README.md#sign-bidirectional-protocol-flow): the 5-step protocol this contract starts, with diagram, failure handling and output recovery: which circuit each step calls and which event it emits.
|
|
23
|
+
- [Integrator Guide](https://github.com/sig-net/midnight-integration/blob/main/README.md#integrator-guide): how client contracts and dApps drive this contract's `signBidirectional` and read the responder's events per request.
|
|
24
|
+
- [Handling Failure](https://github.com/sig-net/midnight-integration/blob/main/README.md#handling-failure): how a failed foreign transaction still completes the flow, attested through the responder's `respondBidirectional` circuit as an empty output under a failure output kind.
|
|
25
|
+
|
|
26
|
+
## Related packages
|
|
27
|
+
|
|
28
|
+
- [`@sig-net/midnight-contract-deploy`](https://www.npmjs.com/package/@sig-net/midnight-contract-deploy): deploys this contract (it takes no constructor arguments: the MPC derives a response key per client contract, and each client pins its own).
|
|
29
|
+
- [`@sig-net/midnight`](https://www.npmjs.com/package/@sig-net/midnight): the client-agnostic protocol library for decoding this contract's events and verifying the MPC's responses.
|
|
30
|
+
- [`@sig-net/midnight-responder`](https://www.npmjs.com/package/@sig-net/midnight-responder): the contract the MPC posts its responses to.
|
|
31
|
+
|
|
32
|
+
Developed in [sig-net/midnight-integration](https://github.com/sig-net/midnight-integration). Example applications live in [sig-net/midnight-examples](https://github.com/sig-net/midnight-examples).
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { MidnightProviders } from "@midnight-ntwrk/midnight-js/types";
|
|
2
|
+
import type { Contract } from "./managed/contract/index.js";
|
|
3
|
+
import type { SignetSignerPrivateState } from "./witnesses.ts";
|
|
4
|
+
/** The contract's provable circuit ids, straight from the generated contract. */
|
|
5
|
+
export type SignetSignerCircuitId = keyof InstanceType<typeof Contract>["provableCircuits"];
|
|
6
|
+
/**
|
|
7
|
+
* Literal of the private-state storage key. Just a string, but a single-value
|
|
8
|
+
* union so the providers/`findDeployedContract` pairing is enforced by the
|
|
9
|
+
* type system.
|
|
10
|
+
*/
|
|
11
|
+
export type SignetSignerPrivateStateId = "signet-signer";
|
|
12
|
+
/**
|
|
13
|
+
* Key under which midnight-js persists this contract's private state locally
|
|
14
|
+
* (in whatever private-state store the consumer's provider set uses).
|
|
15
|
+
* Distinct per contract so two clients don't share an entry.
|
|
16
|
+
*/
|
|
17
|
+
export declare const SIGNET_SIGNER_PRIVATE_STATE_ID: SignetSignerPrivateStateId;
|
|
18
|
+
/** The full midnight-js provider set, typed to the signet signer. */
|
|
19
|
+
export type SignetSignerProviders = MidnightProviders<SignetSignerCircuitId, SignetSignerPrivateStateId, SignetSignerPrivateState>;
|
|
20
|
+
//# sourceMappingURL=contract-surface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-surface.d.ts","sourceRoot":"","sources":["../src/contract-surface.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,iFAAiF;AACjF,MAAM,MAAM,qBAAqB,GAAG,MAAM,YAAY,CAAC,OAAO,QAAQ,CAAC,CAAC,kBAAkB,CAAC,CAAC;AAE5F;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG,eAAe,CAAC;AAEzD;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,EAAE,0BAA4C,CAAC;AAE1F,qEAAqE;AACrE,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,CAEnD,qBAAqB,EAErB,0BAA0B,EAE1B,wBAAwB,CACzB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// The contract's platform-agnostic client surface: the circuit-id union, the
|
|
2
|
+
// private-state store key, and the provider-set TYPE. Deliberately nothing
|
|
3
|
+
// runnable — no wallet flavor, no zk-config source, no state store, no proof
|
|
4
|
+
// provider. Composing a live midnight-js provider set is CONSUMER territory
|
|
5
|
+
// (it differs per environment: Node fs vs browser fetch, LevelDB vs
|
|
6
|
+
// IndexedDB, WalletFacade vs a connector API), so each consumer declares its
|
|
7
|
+
// own — see this monorepo's signet-contract-deploy package for the Node
|
|
8
|
+
// operator composition.
|
|
9
|
+
/**
|
|
10
|
+
* Key under which midnight-js persists this contract's private state locally
|
|
11
|
+
* (in whatever private-state store the consumer's provider set uses).
|
|
12
|
+
* Distinct per contract so two clients don't share an entry.
|
|
13
|
+
*/
|
|
14
|
+
export const SIGNET_SIGNER_PRIVATE_STATE_ID = "signet-signer";
|
|
15
|
+
//# sourceMappingURL=contract-surface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-surface.js","sourceRoot":"","sources":["../src/contract-surface.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,2EAA2E;AAC3E,6EAA6E;AAC7E,4EAA4E;AAC5E,oEAAoE;AACpE,6EAA6E;AAC7E,wEAAwE;AACxE,wBAAwB;AAiBxB;;;;GAIG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAA+B,eAAe,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Curated export surface — this IS the "sdk" face of the package.
|
|
2
|
+
// Everything the compiler emitted, the handwritten witnesses, and the
|
|
3
|
+
// platform-agnostic contract surface (ids + provider TYPE). Environment
|
|
4
|
+
// bindings (zk-config source, state store, wallet adapter) deliberately
|
|
5
|
+
// live with each consumer, not here.
|
|
6
|
+
export * from "./contract-surface.js";
|
|
7
|
+
export * from "./managed/contract/index.js";
|
|
8
|
+
export * from "./witnesses.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,sEAAsE;AACtE,wEAAwE;AACxE,wEAAwE;AACxE,qCAAqC;AAErC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compiler-version": "0.36.0",
|
|
3
|
+
"compiler-commit": "b5d9e4dfc532fe47011c4f6296e254f4853eb469",
|
|
4
|
+
"language-version": "0.28.0",
|
|
5
|
+
"runtime-version": "0.21.0",
|
|
6
|
+
"circuits": [
|
|
7
|
+
{
|
|
8
|
+
"name": "signBidirectional",
|
|
9
|
+
"pure": false,
|
|
10
|
+
"proof": true,
|
|
11
|
+
"arguments": [
|
|
12
|
+
{
|
|
13
|
+
"name": "requestId",
|
|
14
|
+
"type": {
|
|
15
|
+
"type-name": "Alias",
|
|
16
|
+
"name": "RequestId",
|
|
17
|
+
"type": {
|
|
18
|
+
"type-name": "Bytes",
|
|
19
|
+
"length": 32
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "notification",
|
|
25
|
+
"type": {
|
|
26
|
+
"type-name": "Struct",
|
|
27
|
+
"name": "SignBidirectionalEventNotification",
|
|
28
|
+
"elements": [
|
|
29
|
+
{
|
|
30
|
+
"name": "version",
|
|
31
|
+
"type": {
|
|
32
|
+
"type-name": "Uint",
|
|
33
|
+
"maxval": 255
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "payload",
|
|
38
|
+
"type": {
|
|
39
|
+
"type-name": "Bytes",
|
|
40
|
+
"length": 128
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"result-type": {
|
|
48
|
+
"type-name": "Tuple",
|
|
49
|
+
"types": [
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"witnesses": [
|
|
55
|
+
],
|
|
56
|
+
"contracts": [
|
|
57
|
+
],
|
|
58
|
+
"ledger": [
|
|
59
|
+
]
|
|
60
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest-version": "1",
|
|
3
|
+
"compiler-version": "0.36.0",
|
|
4
|
+
"compiler-commit": "b5d9e4dfc532fe47011c4f6296e254f4853eb469",
|
|
5
|
+
"language-version": "0.28.0",
|
|
6
|
+
"runtime-version": "0.21.0",
|
|
7
|
+
"compiler": {
|
|
8
|
+
"type": "directory",
|
|
9
|
+
"contract-info.json": {
|
|
10
|
+
"type": "file",
|
|
11
|
+
"size": 1291,
|
|
12
|
+
"hash": "087c93a19c421556ce1d17601d27a5d128fab0ccf7328783df68ac176dd14d12"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"contract": {
|
|
16
|
+
"type": "directory",
|
|
17
|
+
"index.d.ts": {
|
|
18
|
+
"type": "file",
|
|
19
|
+
"size": 1716,
|
|
20
|
+
"hash": "5fd38aac1491b656058ecee302c1ab63a5b439e5a163e4b02774c62a583b4ee8"
|
|
21
|
+
},
|
|
22
|
+
"index.js": {
|
|
23
|
+
"type": "file",
|
|
24
|
+
"size": 17916,
|
|
25
|
+
"hash": "b8e43aff8fb0405a0708c0c023c54c229c8003cbfcaa1e820049eee69c24dd9c"
|
|
26
|
+
},
|
|
27
|
+
"index.js.map": {
|
|
28
|
+
"type": "file",
|
|
29
|
+
"size": 644,
|
|
30
|
+
"hash": "5d27c2335f2e59e917d1dd551aece8bf201616bf6a4c36f404aea4f2435efb1e"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"zkir": {
|
|
34
|
+
"type": "directory",
|
|
35
|
+
"signBidirectional.bzkir": {
|
|
36
|
+
"type": "file",
|
|
37
|
+
"size": 20006,
|
|
38
|
+
"hash": "01bd6e0a8ff44f0cb831cc9559e83bdf3faed31f247eecc11926ecf9f9c8f4f4"
|
|
39
|
+
},
|
|
40
|
+
"signBidirectional.zkir": {
|
|
41
|
+
"type": "file",
|
|
42
|
+
"size": 74419,
|
|
43
|
+
"hash": "a73e482939c4ba3f88ba204bdd0140a83f480d720f09be7801c46daefbe0dae0"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"keys": {
|
|
47
|
+
"type": "directory",
|
|
48
|
+
"signBidirectional.prover": {
|
|
49
|
+
"type": "file",
|
|
50
|
+
"size": 113268984,
|
|
51
|
+
"hash": "9c7a528f2eefbf2491f1ad2036f289271d178e5ff6eac967381a70e3b938cb62"
|
|
52
|
+
},
|
|
53
|
+
"signBidirectional.verifier": {
|
|
54
|
+
"type": "file",
|
|
55
|
+
"size": 1353,
|
|
56
|
+
"hash": "db4268c2740ee34ea5c1297b9fdf21c9eab5cd4f95b1d692ccab981520db71e7"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type * as __compactRuntime from '@midnight-ntwrk/compact-runtime';
|
|
2
|
+
|
|
3
|
+
export type Witnesses<PS> = {
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export type ImpureCircuits<PS> = {
|
|
7
|
+
signBidirectional(context: __compactRuntime.CircuitContext<PS>,
|
|
8
|
+
requestId_0: Uint8Array,
|
|
9
|
+
notification_0: { version: bigint, payload: Uint8Array }): Promise<__compactRuntime.CircuitResults<PS, []>>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type ProvableCircuits<PS> = {
|
|
13
|
+
signBidirectional(context: __compactRuntime.CircuitContext<PS>,
|
|
14
|
+
requestId_0: Uint8Array,
|
|
15
|
+
notification_0: { version: bigint, payload: Uint8Array }): Promise<__compactRuntime.CircuitResults<PS, []>>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type PureCircuits = {
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type Circuits<PS> = {
|
|
22
|
+
signBidirectional(context: __compactRuntime.CircuitContext<PS>,
|
|
23
|
+
requestId_0: Uint8Array,
|
|
24
|
+
notification_0: { version: bigint, payload: Uint8Array }): Promise<__compactRuntime.CircuitResults<PS, []>>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type Ledger = {
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export declare class Contract<PS = any, W extends Witnesses<PS> = Witnesses<PS>> {
|
|
31
|
+
witnesses: W;
|
|
32
|
+
circuits: Circuits<PS>;
|
|
33
|
+
impureCircuits: ImpureCircuits<PS>;
|
|
34
|
+
provableCircuits: ProvableCircuits<PS>;
|
|
35
|
+
constructor(witnesses: W);
|
|
36
|
+
initialState(context: __compactRuntime.ConstructorContext<PS>): Promise<__compactRuntime.ConstructorResult<PS>>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export declare function ledger(state: __compactRuntime.StateValue | __compactRuntime.ChargedState): Ledger;
|
|
40
|
+
export declare const pureCircuits: PureCircuits;
|
|
41
|
+
export declare const expectedVk: Record<string, string>;
|
|
42
|
+
export declare const circuitSignatures: __compactRuntime.CircuitSignatures;
|
|
43
|
+
export declare const declaredInterfaces: __compactRuntime.DeclaredInterfaces;
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import * as __compactRuntime from '@midnight-ntwrk/compact-runtime';
|
|
2
|
+
__compactRuntime.checkRuntimeVersion('0.21.0');
|
|
3
|
+
|
|
4
|
+
const _descriptor_0 = new __compactRuntime.CompactTypeBytes(288);
|
|
5
|
+
|
|
6
|
+
const _descriptor_1 = new __compactRuntime.CompactTypeBytes(32);
|
|
7
|
+
|
|
8
|
+
const _descriptor_2 = new __compactRuntime.CompactTypeUnsignedInteger(255n, 1);
|
|
9
|
+
|
|
10
|
+
const _descriptor_3 = new __compactRuntime.CompactTypeBytes(128);
|
|
11
|
+
|
|
12
|
+
class _SignBidirectionalEventNotification_0 {
|
|
13
|
+
alignment() {
|
|
14
|
+
return _descriptor_2.alignment().concat(_descriptor_3.alignment());
|
|
15
|
+
}
|
|
16
|
+
fromValue(value_0) {
|
|
17
|
+
return {
|
|
18
|
+
version: _descriptor_2.fromValue(value_0),
|
|
19
|
+
payload: _descriptor_3.fromValue(value_0)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
toValue(value_0) {
|
|
23
|
+
return _descriptor_2.toValue(value_0.version).concat(_descriptor_3.toValue(value_0.payload));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const _descriptor_4 = new _SignBidirectionalEventNotification_0();
|
|
28
|
+
|
|
29
|
+
const _descriptor_5 = new __compactRuntime.CompactTypeUnsignedInteger(18446744073709551615n, 8);
|
|
30
|
+
|
|
31
|
+
const _descriptor_6 = __compactRuntime.CompactTypeBoolean;
|
|
32
|
+
|
|
33
|
+
class _Either_0 {
|
|
34
|
+
alignment() {
|
|
35
|
+
return _descriptor_6.alignment().concat(_descriptor_1.alignment().concat(_descriptor_1.alignment()));
|
|
36
|
+
}
|
|
37
|
+
fromValue(value_0) {
|
|
38
|
+
return {
|
|
39
|
+
is_left: _descriptor_6.fromValue(value_0),
|
|
40
|
+
left: _descriptor_1.fromValue(value_0),
|
|
41
|
+
right: _descriptor_1.fromValue(value_0)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
toValue(value_0) {
|
|
45
|
+
return _descriptor_6.toValue(value_0.is_left).concat(_descriptor_1.toValue(value_0.left).concat(_descriptor_1.toValue(value_0.right)));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const _descriptor_7 = new _Either_0();
|
|
50
|
+
|
|
51
|
+
const _descriptor_8 = new __compactRuntime.CompactTypeUnsignedInteger(340282366920938463463374607431768211455n, 16);
|
|
52
|
+
|
|
53
|
+
class _ContractAddress_0 {
|
|
54
|
+
alignment() {
|
|
55
|
+
return _descriptor_1.alignment();
|
|
56
|
+
}
|
|
57
|
+
fromValue(value_0) {
|
|
58
|
+
return {
|
|
59
|
+
bytes: _descriptor_1.fromValue(value_0)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
toValue(value_0) {
|
|
63
|
+
return _descriptor_1.toValue(value_0.bytes);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const _descriptor_9 = new _ContractAddress_0();
|
|
68
|
+
|
|
69
|
+
class _UserAddress_0 {
|
|
70
|
+
alignment() {
|
|
71
|
+
return _descriptor_1.alignment();
|
|
72
|
+
}
|
|
73
|
+
fromValue(value_0) {
|
|
74
|
+
return {
|
|
75
|
+
bytes: _descriptor_1.fromValue(value_0)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
toValue(value_0) {
|
|
79
|
+
return _descriptor_1.toValue(value_0.bytes);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const _descriptor_10 = new _UserAddress_0();
|
|
84
|
+
|
|
85
|
+
class _Either_1 {
|
|
86
|
+
alignment() {
|
|
87
|
+
return _descriptor_6.alignment().concat(_descriptor_9.alignment().concat(_descriptor_10.alignment()));
|
|
88
|
+
}
|
|
89
|
+
fromValue(value_0) {
|
|
90
|
+
return {
|
|
91
|
+
is_left: _descriptor_6.fromValue(value_0),
|
|
92
|
+
left: _descriptor_9.fromValue(value_0),
|
|
93
|
+
right: _descriptor_10.fromValue(value_0)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
toValue(value_0) {
|
|
97
|
+
return _descriptor_6.toValue(value_0.is_left).concat(_descriptor_9.toValue(value_0.left).concat(_descriptor_10.toValue(value_0.right)));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const _descriptor_11 = new _Either_1();
|
|
102
|
+
|
|
103
|
+
class _Maybe_0 {
|
|
104
|
+
alignment() {
|
|
105
|
+
return _descriptor_6.alignment().concat(_descriptor_11.alignment());
|
|
106
|
+
}
|
|
107
|
+
fromValue(value_0) {
|
|
108
|
+
return {
|
|
109
|
+
is_some: _descriptor_6.fromValue(value_0),
|
|
110
|
+
value: _descriptor_11.fromValue(value_0)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
toValue(value_0) {
|
|
114
|
+
return _descriptor_6.toValue(value_0.is_some).concat(_descriptor_11.toValue(value_0.value));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const _descriptor_12 = new _Maybe_0();
|
|
119
|
+
|
|
120
|
+
const _descriptor_13 = new __compactRuntime.CompactTypeUnsignedInteger(4294967295n, 4);
|
|
121
|
+
|
|
122
|
+
export class Contract {
|
|
123
|
+
witnesses;
|
|
124
|
+
constructor(...args_0) {
|
|
125
|
+
if (args_0.length !== 1) {
|
|
126
|
+
throw new __compactRuntime.CompactError(`Contract constructor: expected 1 argument, received ${args_0.length}`);
|
|
127
|
+
}
|
|
128
|
+
const witnesses_0 = args_0[0];
|
|
129
|
+
if (typeof(witnesses_0) !== 'object') {
|
|
130
|
+
throw new __compactRuntime.CompactError('first (witnesses) argument to Contract constructor is not an object');
|
|
131
|
+
}
|
|
132
|
+
this.witnesses = witnesses_0;
|
|
133
|
+
this.circuits = {
|
|
134
|
+
signBidirectional: async (...args_1) => {
|
|
135
|
+
if (args_1.length !== 3) {
|
|
136
|
+
throw new __compactRuntime.CompactError(`signBidirectional: expected 3 arguments (as invoked from Typescript), received ${args_1.length}`);
|
|
137
|
+
}
|
|
138
|
+
const contextOrig_0 = args_1[0];
|
|
139
|
+
const requestId_0 = args_1[1];
|
|
140
|
+
const notification_0 = args_1[2];
|
|
141
|
+
if (!(typeof(contextOrig_0) === 'object' && contextOrig_0.callContext.currentQueryContext != undefined)) {
|
|
142
|
+
__compactRuntime.typeError('signBidirectional',
|
|
143
|
+
'argument 1 (as invoked from Typescript)',
|
|
144
|
+
'signet-signer.compact line 30 char 1',
|
|
145
|
+
'CircuitContext',
|
|
146
|
+
contextOrig_0)
|
|
147
|
+
}
|
|
148
|
+
if (!(requestId_0.buffer instanceof ArrayBuffer && requestId_0.BYTES_PER_ELEMENT === 1 && requestId_0.length === 32)) {
|
|
149
|
+
__compactRuntime.typeError('signBidirectional',
|
|
150
|
+
'argument 1 (argument 2 as invoked from Typescript)',
|
|
151
|
+
'signet-signer.compact line 30 char 1',
|
|
152
|
+
'Bytes<32>',
|
|
153
|
+
requestId_0)
|
|
154
|
+
}
|
|
155
|
+
if (!(typeof(notification_0) === 'object' && typeof(notification_0.version) === 'bigint' && notification_0.version >= 0n && notification_0.version <= 255n && notification_0.payload.buffer instanceof ArrayBuffer && notification_0.payload.BYTES_PER_ELEMENT === 1 && notification_0.payload.length === 128)) {
|
|
156
|
+
__compactRuntime.typeError('signBidirectional',
|
|
157
|
+
'argument 2 (argument 3 as invoked from Typescript)',
|
|
158
|
+
'signet-signer.compact line 30 char 1',
|
|
159
|
+
'struct SignBidirectionalEventNotification<version: Uint<0..256>, payload: Bytes<128>>',
|
|
160
|
+
notification_0)
|
|
161
|
+
}
|
|
162
|
+
const context = __compactRuntime.copyCircuitContext(contextOrig_0);
|
|
163
|
+
const partialProofData = {
|
|
164
|
+
input: {
|
|
165
|
+
value: _descriptor_1.toValue(requestId_0).concat(_descriptor_4.toValue(notification_0)),
|
|
166
|
+
alignment: _descriptor_1.alignment().concat(_descriptor_4.alignment())
|
|
167
|
+
},
|
|
168
|
+
output: undefined,
|
|
169
|
+
publicTranscript: [],
|
|
170
|
+
privateTranscriptOutputs: []
|
|
171
|
+
};
|
|
172
|
+
const result_0 = await this._signBidirectional_0(context,
|
|
173
|
+
partialProofData,
|
|
174
|
+
requestId_0,
|
|
175
|
+
notification_0);
|
|
176
|
+
partialProofData.output = { value: [], alignment: [] };
|
|
177
|
+
__compactRuntime.finalizeCallProofData(context, partialProofData);
|
|
178
|
+
return { result: result_0, context: context, gasCost: context.callContext.currentGasCost };
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
this.impureCircuits = {
|
|
182
|
+
signBidirectional: this.circuits.signBidirectional
|
|
183
|
+
};
|
|
184
|
+
this.provableCircuits = {
|
|
185
|
+
signBidirectional: this.circuits.signBidirectional
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
async initialState(...args_0) {
|
|
189
|
+
if (args_0.length !== 1) {
|
|
190
|
+
throw new __compactRuntime.CompactError(`Contract state constructor: expected 1 argument (as invoked from Typescript), received ${args_0.length}`);
|
|
191
|
+
}
|
|
192
|
+
const constructorContext_0 = args_0[0];
|
|
193
|
+
if (typeof(constructorContext_0) !== 'object') {
|
|
194
|
+
throw new __compactRuntime.CompactError(`Contract state constructor: expected 'constructorContext' in argument 1 (as invoked from Typescript) to be an object`);
|
|
195
|
+
}
|
|
196
|
+
if (!('initialZswapLocalState' in constructorContext_0)) {
|
|
197
|
+
throw new __compactRuntime.CompactError(`Contract state constructor: expected 'initialZswapLocalState' in argument 1 (as invoked from Typescript)`);
|
|
198
|
+
}
|
|
199
|
+
if (typeof(constructorContext_0.initialZswapLocalState) !== 'object') {
|
|
200
|
+
throw new __compactRuntime.CompactError(`Contract state constructor: expected 'initialZswapLocalState' in argument 1 (as invoked from Typescript) to be an object`);
|
|
201
|
+
}
|
|
202
|
+
const state_0 = new __compactRuntime.ContractState();
|
|
203
|
+
let stateValue_0 = __compactRuntime.StateValue.newArray();
|
|
204
|
+
state_0.data = new __compactRuntime.ChargedState(stateValue_0);
|
|
205
|
+
state_0.setOperation('signBidirectional', new __compactRuntime.ContractOperation());
|
|
206
|
+
const context = __compactRuntime.createCircuitContext({circuitId: 'constructor', contractAddress: __compactRuntime.dummyContractAddress(), coinPublicKeyOrZswapState: constructorContext_0.initialZswapLocalState.coinPublicKey, contractState: state_0.data, privateState: constructorContext_0.initialPrivateState});
|
|
207
|
+
const partialProofData = {
|
|
208
|
+
input: { value: [], alignment: [] },
|
|
209
|
+
output: undefined,
|
|
210
|
+
publicTranscript: [],
|
|
211
|
+
privateTranscriptOutputs: []
|
|
212
|
+
};
|
|
213
|
+
state_0.data = new __compactRuntime.ChargedState(context.callContext.currentQueryContext.state.state);
|
|
214
|
+
return {
|
|
215
|
+
currentContractState: state_0,
|
|
216
|
+
currentPrivateState: context.callContext.currentPrivateState,
|
|
217
|
+
currentZswapLocalState: context.callContext.currentZswapLocalState
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
async _signBidirectional_0(context,
|
|
221
|
+
partialProofData,
|
|
222
|
+
requestId_0,
|
|
223
|
+
notification_0)
|
|
224
|
+
{
|
|
225
|
+
let t_0;
|
|
226
|
+
__compactRuntime.queryLedgerState(context,
|
|
227
|
+
partialProofData,
|
|
228
|
+
[
|
|
229
|
+
{ push: { storage: false,
|
|
230
|
+
value: __compactRuntime.StateValue.newArray()
|
|
231
|
+
.arrayPush(__compactRuntime.StateValue.newCell({ value: _descriptor_13.toValue(1n),
|
|
232
|
+
alignment: _descriptor_13.alignment() })).arrayPush(__compactRuntime.StateValue.newCell({ value: _descriptor_2.toValue(10n),
|
|
233
|
+
alignment: _descriptor_2.alignment() })).arrayPush(__compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue((t_0 = { name:
|
|
234
|
+
new Uint8Array([83, 105, 103, 110, 66, 105, 100, 105, 114, 101, 99, 116, 105, 111, 110, 97, 108, 69, 118, 101, 110, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
|
|
235
|
+
payload:
|
|
236
|
+
Uint8Array.from([notification_0.version,
|
|
237
|
+
...Array.from(requestId_0,
|
|
238
|
+
BigInt),
|
|
239
|
+
...Array.from(notification_0.payload,
|
|
240
|
+
BigInt),
|
|
241
|
+
...Array.from(new Uint8Array(95),
|
|
242
|
+
BigInt)],
|
|
243
|
+
Number) },
|
|
244
|
+
Uint8Array.from([...Array.from(t_0.name,
|
|
245
|
+
BigInt),
|
|
246
|
+
...Array.from(t_0.payload,
|
|
247
|
+
BigInt)],
|
|
248
|
+
Number))),
|
|
249
|
+
alignment: _descriptor_0.alignment() }))
|
|
250
|
+
.encode() } },
|
|
251
|
+
'log']);
|
|
252
|
+
return [];
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
export function ledger(stateOrChargedState) {
|
|
256
|
+
const state = stateOrChargedState instanceof __compactRuntime.StateValue ? stateOrChargedState : stateOrChargedState.state;
|
|
257
|
+
const chargedState = stateOrChargedState instanceof __compactRuntime.StateValue ? new __compactRuntime.ChargedState(stateOrChargedState) : stateOrChargedState;
|
|
258
|
+
const context = {
|
|
259
|
+
callContext: { currentQueryContext: new __compactRuntime.QueryContext(chargedState, __compactRuntime.dummyContractAddress()), currentGasCost: __compactRuntime.emptyRunningCost() },
|
|
260
|
+
costModel: __compactRuntime.CostModel.initialCostModel()
|
|
261
|
+
};
|
|
262
|
+
const partialProofData = {
|
|
263
|
+
input: { value: [], alignment: [] },
|
|
264
|
+
output: undefined,
|
|
265
|
+
publicTranscript: [],
|
|
266
|
+
privateTranscriptOutputs: []
|
|
267
|
+
};
|
|
268
|
+
return {
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
const _emptyContext = {
|
|
272
|
+
callContext: { currentQueryContext: new __compactRuntime.QueryContext(new __compactRuntime.ContractState().data, __compactRuntime.dummyContractAddress()), currentGasCost: __compactRuntime.emptyRunningCost() }
|
|
273
|
+
};
|
|
274
|
+
const _dummyContract = new Contract({ });
|
|
275
|
+
export const pureCircuits = {};
|
|
276
|
+
export const expectedVk = {
|
|
277
|
+
'signBidirectional': 'db4268c2740ee34ea5c1297b9fdf21c9eab5cd4f95b1d692ccab981520db71e7',
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
export const circuitSignatures = {
|
|
281
|
+
'signBidirectional': {pure: false, provable: true, argumentTypes: [{tag: 'Alias', name: 'RequestId', type: {tag: 'Bytes', length: 32}}, {tag: 'Struct', name: 'SignBidirectionalEventNotification', elements: [{name: 'version', type: {tag: 'Uint', maxval: '255'}}, {name: 'payload', type: {tag: 'Bytes', length: 128}}]}], resultType: {tag: 'Tuple', types: []}},
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
export const declaredInterfaces = {};
|
|
285
|
+
|
|
286
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "index.js",
|
|
4
|
+
"sourceRoot": "../../../",
|
|
5
|
+
"sources": ["src/signet-signer.compact"],
|
|
6
|
+
"names": [],
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;MA6BA,AAAA,iBAaC;;;;;cAZK,WAAoB;cACpB,cAAgD;;;;;;;;;;;;;;;;;;;;;;;;;yCADhD,WAAoB,+BACpB,cAAgD;;;;;;;;;yDADhD,WAAoB;yDACpB,cAAgD;;;;OAWrD;;;;;;;;GACA;EA3CD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CC;EAdD,AAAA,0BAaC;;6BAZK,WAAoB;6BACpB,cAAgD;;QAElD,GAQE;;;;;;;;;;;uVALe,cAAY;qWACT,WAAS;;qWACT,cAAY;;;;;2VALhC,GAQE;;2VARF,GAQE;;;;;;;GACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"
|
|
8
|
+
}
|
|
Binary file
|
|
Binary file
|