@rohan-protocol/sdk 0.3.1 → 0.5.1
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 +177 -152
- package/dist/client.d.ts +41 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +191 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +4 -47
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -134
- package/dist/index.js.map +1 -1
- package/dist/prover.d.ts +10 -12
- package/dist/prover.d.ts.map +1 -1
- package/dist/prover.js +29 -43
- package/dist/prover.js.map +1 -1
- package/dist/security/zeroize.d.ts +17 -0
- package/dist/security/zeroize.d.ts.map +1 -0
- package/dist/security/zeroize.js +49 -0
- package/dist/security/zeroize.js.map +1 -0
- package/dist/types.d.ts +48 -66
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -6
- package/dist/types.js.map +1 -1
- package/dist/verifier.d.ts +1 -1
- package/dist/verifier.js +1 -1
- package/package.json +33 -36
- package/src/generated/compiler/contract-info.json +70 -0
- package/src/generated/contract/index.d.ts +56 -0
- package/src/generated/contract/index.js +293 -0
- package/src/generated/contract/index.js.map +8 -0
- package/src/generated/keys/initial_setup.prover +0 -0
- package/src/generated/keys/initial_setup.verifier +0 -0
- package/src/generated/keys/verify_batched_handshakes.prover +0 -0
- package/src/generated/keys/verify_batched_handshakes.verifier +0 -0
- package/src/generated/zkir/initial_setup.bzkir +0 -0
- package/src/generated/zkir/initial_setup.zkir +30 -0
- package/src/generated/zkir/verify_batched_handshakes.bzkir +0 -0
- package/src/generated/zkir/verify_batched_handshakes.zkir +64 -0
- package/LICENSE +0 -21
- package/dist/adapters/langchain-tool.d.ts +0 -19
- package/dist/adapters/langchain-tool.d.ts.map +0 -1
- package/dist/adapters/langchain-tool.js +0 -40
- package/dist/adapters/langchain-tool.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,51 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rohan-protocol/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"description": "Zero-Knowledge Agent Handshake SDK for Midnight Blockchain",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
}
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./zk-assets": "./src/generated/*"
|
|
13
14
|
},
|
|
14
15
|
"files": [
|
|
15
16
|
"dist",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
17
|
+
"src/generated",
|
|
18
|
+
"README.md"
|
|
18
19
|
],
|
|
19
20
|
"scripts": {
|
|
20
|
-
"build": "tsc",
|
|
21
|
-
"
|
|
22
|
-
"prepublishOnly": "npm run build"
|
|
21
|
+
"build": "tsc && ln -sfn ../src/generated dist/generated",
|
|
22
|
+
"clean": "rm -rf dist"
|
|
23
23
|
},
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"midnight-
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
"url": "git+https://github.com/rohan-protocol/sdk.git"
|
|
41
|
-
},
|
|
42
|
-
"bugs": {
|
|
43
|
-
"url": "https://github.com/rohan-protocol/sdk/issues"
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@midnight-ntwrk/compact-js": "^3.0.0",
|
|
26
|
+
"@midnight-ntwrk/ledger-v8": "^3.0.0",
|
|
27
|
+
"@midnight-ntwrk/midnight-js-contracts": "^3.0.0",
|
|
28
|
+
"@midnight-ntwrk/midnight-js-http-client-proof-provider": "^3.0.0",
|
|
29
|
+
"@midnight-ntwrk/midnight-js-indexer-public-data-provider": "^3.0.0",
|
|
30
|
+
"@midnight-ntwrk/midnight-js-level-private-state-provider": "^3.0.0",
|
|
31
|
+
"@midnight-ntwrk/midnight-js-network-id": "^3.0.0",
|
|
32
|
+
"@midnight-ntwrk/midnight-js-node-zk-config-provider": "^3.0.0",
|
|
33
|
+
"@midnight-ntwrk/midnight-js-types": "^3.0.0",
|
|
34
|
+
"@midnight-ntwrk/wallet-sdk-facade": "^3.0.0",
|
|
35
|
+
"@midnight-ntwrk/wallet-sdk-hd": "^3.0.0",
|
|
36
|
+
"@midnight-ntwrk/wallet-sdk-shielded": "^3.0.0",
|
|
37
|
+
"@midnight-ntwrk/wallet-sdk-unshielded-wallet": "^3.0.0",
|
|
38
|
+
"@midnight-ntwrk/wallet-sdk-dust-wallet": "^3.0.0",
|
|
39
|
+
"rxjs": "^7.8.1"
|
|
44
40
|
},
|
|
45
|
-
"homepage": "https://github.com/rohan-protocol/sdk#readme",
|
|
46
|
-
"dependencies": {},
|
|
47
41
|
"devDependencies": {
|
|
48
|
-
"@types/node": "^22.
|
|
49
|
-
"typescript": "
|
|
42
|
+
"@types/node": "^22.0.0",
|
|
43
|
+
"typescript": "^5.5.0"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
50
47
|
}
|
|
51
48
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compiler-version": "0.30.0",
|
|
3
|
+
"language-version": "0.22.0",
|
|
4
|
+
"runtime-version": "0.15.0",
|
|
5
|
+
"circuits": [
|
|
6
|
+
{
|
|
7
|
+
"name": "verify_batched_handshakes",
|
|
8
|
+
"pure": false,
|
|
9
|
+
"proof": true,
|
|
10
|
+
"arguments": [
|
|
11
|
+
{
|
|
12
|
+
"name": "previous_root",
|
|
13
|
+
"type": {
|
|
14
|
+
"type-name": "Bytes",
|
|
15
|
+
"length": 32
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "new_root",
|
|
20
|
+
"type": {
|
|
21
|
+
"type-name": "Bytes",
|
|
22
|
+
"length": 32
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "batched_proof_data",
|
|
27
|
+
"type": {
|
|
28
|
+
"type-name": "Bytes",
|
|
29
|
+
"length": 128
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "total_toll_collected",
|
|
34
|
+
"type": {
|
|
35
|
+
"type-name": "Uint",
|
|
36
|
+
"maxval": 18446744073709551615
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"result-type": {
|
|
41
|
+
"type-name": "Tuple",
|
|
42
|
+
"types": [
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "initial_setup",
|
|
48
|
+
"pure": false,
|
|
49
|
+
"proof": true,
|
|
50
|
+
"arguments": [
|
|
51
|
+
{
|
|
52
|
+
"name": "initial_root",
|
|
53
|
+
"type": {
|
|
54
|
+
"type-name": "Bytes",
|
|
55
|
+
"length": 32
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"result-type": {
|
|
60
|
+
"type-name": "Tuple",
|
|
61
|
+
"types": [
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"witnesses": [
|
|
67
|
+
],
|
|
68
|
+
"contracts": [
|
|
69
|
+
]
|
|
70
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type * as __compactRuntime from '@midnight-ntwrk/compact-runtime';
|
|
2
|
+
|
|
3
|
+
export type Witnesses<PS> = {
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export type ImpureCircuits<PS> = {
|
|
7
|
+
verify_batched_handshakes(context: __compactRuntime.CircuitContext<PS>,
|
|
8
|
+
previous_root_0: Uint8Array,
|
|
9
|
+
new_root_0: Uint8Array,
|
|
10
|
+
batched_proof_data_0: Uint8Array,
|
|
11
|
+
total_toll_collected_0: bigint): __compactRuntime.CircuitResults<PS, []>;
|
|
12
|
+
initial_setup(context: __compactRuntime.CircuitContext<PS>,
|
|
13
|
+
initial_root_0: Uint8Array): __compactRuntime.CircuitResults<PS, []>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type ProvableCircuits<PS> = {
|
|
17
|
+
verify_batched_handshakes(context: __compactRuntime.CircuitContext<PS>,
|
|
18
|
+
previous_root_0: Uint8Array,
|
|
19
|
+
new_root_0: Uint8Array,
|
|
20
|
+
batched_proof_data_0: Uint8Array,
|
|
21
|
+
total_toll_collected_0: bigint): __compactRuntime.CircuitResults<PS, []>;
|
|
22
|
+
initial_setup(context: __compactRuntime.CircuitContext<PS>,
|
|
23
|
+
initial_root_0: Uint8Array): __compactRuntime.CircuitResults<PS, []>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type PureCircuits = {
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type Circuits<PS> = {
|
|
30
|
+
verify_batched_handshakes(context: __compactRuntime.CircuitContext<PS>,
|
|
31
|
+
previous_root_0: Uint8Array,
|
|
32
|
+
new_root_0: Uint8Array,
|
|
33
|
+
batched_proof_data_0: Uint8Array,
|
|
34
|
+
total_toll_collected_0: bigint): __compactRuntime.CircuitResults<PS, []>;
|
|
35
|
+
initial_setup(context: __compactRuntime.CircuitContext<PS>,
|
|
36
|
+
initial_root_0: Uint8Array): __compactRuntime.CircuitResults<PS, []>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type Ledger = {
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type ContractReferenceLocations = any;
|
|
43
|
+
|
|
44
|
+
export declare const contractReferenceLocations : ContractReferenceLocations;
|
|
45
|
+
|
|
46
|
+
export declare class Contract<PS = any, W extends Witnesses<PS> = Witnesses<PS>> {
|
|
47
|
+
witnesses: W;
|
|
48
|
+
circuits: Circuits<PS>;
|
|
49
|
+
impureCircuits: ImpureCircuits<PS>;
|
|
50
|
+
provableCircuits: ProvableCircuits<PS>;
|
|
51
|
+
constructor(witnesses: W);
|
|
52
|
+
initialState(context: __compactRuntime.ConstructorContext<PS>): __compactRuntime.ConstructorResult<PS>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export declare function ledger(state: __compactRuntime.StateValue | __compactRuntime.ChargedState): Ledger;
|
|
56
|
+
export declare const pureCircuits: PureCircuits;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import * as __compactRuntime from '@midnight-ntwrk/compact-runtime';
|
|
2
|
+
__compactRuntime.checkRuntimeVersion('0.14.0');
|
|
3
|
+
|
|
4
|
+
const _descriptor_0 = new __compactRuntime.CompactTypeBytes(32);
|
|
5
|
+
|
|
6
|
+
const _descriptor_1 = new __compactRuntime.CompactTypeBytes(128);
|
|
7
|
+
|
|
8
|
+
const _descriptor_2 = new __compactRuntime.CompactTypeUnsignedInteger(18446744073709551615n, 8);
|
|
9
|
+
|
|
10
|
+
const _descriptor_3 = __compactRuntime.CompactTypeBoolean;
|
|
11
|
+
|
|
12
|
+
class _Either_0 {
|
|
13
|
+
alignment() {
|
|
14
|
+
return _descriptor_3.alignment().concat(_descriptor_0.alignment().concat(_descriptor_0.alignment()));
|
|
15
|
+
}
|
|
16
|
+
fromValue(value_0) {
|
|
17
|
+
return {
|
|
18
|
+
is_left: _descriptor_3.fromValue(value_0),
|
|
19
|
+
left: _descriptor_0.fromValue(value_0),
|
|
20
|
+
right: _descriptor_0.fromValue(value_0)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
toValue(value_0) {
|
|
24
|
+
return _descriptor_3.toValue(value_0.is_left).concat(_descriptor_0.toValue(value_0.left).concat(_descriptor_0.toValue(value_0.right)));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const _descriptor_4 = new _Either_0();
|
|
29
|
+
|
|
30
|
+
const _descriptor_5 = new __compactRuntime.CompactTypeUnsignedInteger(340282366920938463463374607431768211455n, 16);
|
|
31
|
+
|
|
32
|
+
class _ContractAddress_0 {
|
|
33
|
+
alignment() {
|
|
34
|
+
return _descriptor_0.alignment();
|
|
35
|
+
}
|
|
36
|
+
fromValue(value_0) {
|
|
37
|
+
return {
|
|
38
|
+
bytes: _descriptor_0.fromValue(value_0)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
toValue(value_0) {
|
|
42
|
+
return _descriptor_0.toValue(value_0.bytes);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const _descriptor_6 = new _ContractAddress_0();
|
|
47
|
+
|
|
48
|
+
const _descriptor_7 = new __compactRuntime.CompactTypeUnsignedInteger(255n, 1);
|
|
49
|
+
|
|
50
|
+
export class Contract {
|
|
51
|
+
witnesses;
|
|
52
|
+
constructor(...args_0) {
|
|
53
|
+
if (args_0.length !== 1) {
|
|
54
|
+
throw new __compactRuntime.CompactError(`Contract constructor: expected 1 argument, received ${args_0.length}`);
|
|
55
|
+
}
|
|
56
|
+
const witnesses_0 = args_0[0];
|
|
57
|
+
if (typeof(witnesses_0) !== 'object') {
|
|
58
|
+
throw new __compactRuntime.CompactError('first (witnesses) argument to Contract constructor is not an object');
|
|
59
|
+
}
|
|
60
|
+
this.witnesses = witnesses_0;
|
|
61
|
+
this.circuits = {
|
|
62
|
+
verify_batched_handshakes: (...args_1) => {
|
|
63
|
+
if (args_1.length !== 5) {
|
|
64
|
+
throw new __compactRuntime.CompactError(`verify_batched_handshakes: expected 5 arguments (as invoked from Typescript), received ${args_1.length}`);
|
|
65
|
+
}
|
|
66
|
+
const contextOrig_0 = args_1[0];
|
|
67
|
+
const previous_root_0 = args_1[1];
|
|
68
|
+
const new_root_0 = args_1[2];
|
|
69
|
+
const batched_proof_data_0 = args_1[3];
|
|
70
|
+
const total_toll_collected_0 = args_1[4];
|
|
71
|
+
if (!(typeof(contextOrig_0) === 'object' && contextOrig_0.currentQueryContext != undefined)) {
|
|
72
|
+
__compactRuntime.typeError('verify_batched_handshakes',
|
|
73
|
+
'argument 1 (as invoked from Typescript)',
|
|
74
|
+
'rohan_handshake.compact line 18 char 1',
|
|
75
|
+
'CircuitContext',
|
|
76
|
+
contextOrig_0)
|
|
77
|
+
}
|
|
78
|
+
if (!(previous_root_0.buffer instanceof ArrayBuffer && previous_root_0.BYTES_PER_ELEMENT === 1 && previous_root_0.length === 32)) {
|
|
79
|
+
__compactRuntime.typeError('verify_batched_handshakes',
|
|
80
|
+
'argument 1 (argument 2 as invoked from Typescript)',
|
|
81
|
+
'rohan_handshake.compact line 18 char 1',
|
|
82
|
+
'Bytes<32>',
|
|
83
|
+
previous_root_0)
|
|
84
|
+
}
|
|
85
|
+
if (!(new_root_0.buffer instanceof ArrayBuffer && new_root_0.BYTES_PER_ELEMENT === 1 && new_root_0.length === 32)) {
|
|
86
|
+
__compactRuntime.typeError('verify_batched_handshakes',
|
|
87
|
+
'argument 2 (argument 3 as invoked from Typescript)',
|
|
88
|
+
'rohan_handshake.compact line 18 char 1',
|
|
89
|
+
'Bytes<32>',
|
|
90
|
+
new_root_0)
|
|
91
|
+
}
|
|
92
|
+
if (!(batched_proof_data_0.buffer instanceof ArrayBuffer && batched_proof_data_0.BYTES_PER_ELEMENT === 1 && batched_proof_data_0.length === 128)) {
|
|
93
|
+
__compactRuntime.typeError('verify_batched_handshakes',
|
|
94
|
+
'argument 3 (argument 4 as invoked from Typescript)',
|
|
95
|
+
'rohan_handshake.compact line 18 char 1',
|
|
96
|
+
'Bytes<128>',
|
|
97
|
+
batched_proof_data_0)
|
|
98
|
+
}
|
|
99
|
+
if (!(typeof(total_toll_collected_0) === 'bigint' && total_toll_collected_0 >= 0n && total_toll_collected_0 <= 18446744073709551615n)) {
|
|
100
|
+
__compactRuntime.typeError('verify_batched_handshakes',
|
|
101
|
+
'argument 4 (argument 5 as invoked from Typescript)',
|
|
102
|
+
'rohan_handshake.compact line 18 char 1',
|
|
103
|
+
'Uint<0..18446744073709551616>',
|
|
104
|
+
total_toll_collected_0)
|
|
105
|
+
}
|
|
106
|
+
const context = { ...contextOrig_0, gasCost: __compactRuntime.emptyRunningCost() };
|
|
107
|
+
const partialProofData = {
|
|
108
|
+
input: {
|
|
109
|
+
value: _descriptor_0.toValue(previous_root_0).concat(_descriptor_0.toValue(new_root_0).concat(_descriptor_1.toValue(batched_proof_data_0).concat(_descriptor_2.toValue(total_toll_collected_0)))),
|
|
110
|
+
alignment: _descriptor_0.alignment().concat(_descriptor_0.alignment().concat(_descriptor_1.alignment().concat(_descriptor_2.alignment())))
|
|
111
|
+
},
|
|
112
|
+
output: undefined,
|
|
113
|
+
publicTranscript: [],
|
|
114
|
+
privateTranscriptOutputs: []
|
|
115
|
+
};
|
|
116
|
+
const result_0 = this._verify_batched_handshakes_0(context,
|
|
117
|
+
partialProofData,
|
|
118
|
+
previous_root_0,
|
|
119
|
+
new_root_0,
|
|
120
|
+
batched_proof_data_0,
|
|
121
|
+
total_toll_collected_0);
|
|
122
|
+
partialProofData.output = { value: [], alignment: [] };
|
|
123
|
+
return { result: result_0, context: context, proofData: partialProofData, gasCost: context.gasCost };
|
|
124
|
+
},
|
|
125
|
+
initial_setup: (...args_1) => {
|
|
126
|
+
if (args_1.length !== 2) {
|
|
127
|
+
throw new __compactRuntime.CompactError(`initial_setup: expected 2 arguments (as invoked from Typescript), received ${args_1.length}`);
|
|
128
|
+
}
|
|
129
|
+
const contextOrig_0 = args_1[0];
|
|
130
|
+
const initial_root_0 = args_1[1];
|
|
131
|
+
if (!(typeof(contextOrig_0) === 'object' && contextOrig_0.currentQueryContext != undefined)) {
|
|
132
|
+
__compactRuntime.typeError('initial_setup',
|
|
133
|
+
'argument 1 (as invoked from Typescript)',
|
|
134
|
+
'rohan_handshake.compact line 52 char 1',
|
|
135
|
+
'CircuitContext',
|
|
136
|
+
contextOrig_0)
|
|
137
|
+
}
|
|
138
|
+
if (!(initial_root_0.buffer instanceof ArrayBuffer && initial_root_0.BYTES_PER_ELEMENT === 1 && initial_root_0.length === 32)) {
|
|
139
|
+
__compactRuntime.typeError('initial_setup',
|
|
140
|
+
'argument 1 (argument 2 as invoked from Typescript)',
|
|
141
|
+
'rohan_handshake.compact line 52 char 1',
|
|
142
|
+
'Bytes<32>',
|
|
143
|
+
initial_root_0)
|
|
144
|
+
}
|
|
145
|
+
const context = { ...contextOrig_0, gasCost: __compactRuntime.emptyRunningCost() };
|
|
146
|
+
const partialProofData = {
|
|
147
|
+
input: {
|
|
148
|
+
value: _descriptor_0.toValue(initial_root_0),
|
|
149
|
+
alignment: _descriptor_0.alignment()
|
|
150
|
+
},
|
|
151
|
+
output: undefined,
|
|
152
|
+
publicTranscript: [],
|
|
153
|
+
privateTranscriptOutputs: []
|
|
154
|
+
};
|
|
155
|
+
const result_0 = this._initial_setup_0(context,
|
|
156
|
+
partialProofData,
|
|
157
|
+
initial_root_0);
|
|
158
|
+
partialProofData.output = { value: [], alignment: [] };
|
|
159
|
+
return { result: result_0, context: context, proofData: partialProofData, gasCost: context.gasCost };
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
this.impureCircuits = {
|
|
163
|
+
verify_batched_handshakes: this.circuits.verify_batched_handshakes,
|
|
164
|
+
initial_setup: this.circuits.initial_setup
|
|
165
|
+
};
|
|
166
|
+
this.provableCircuits = {
|
|
167
|
+
verify_batched_handshakes: this.circuits.verify_batched_handshakes,
|
|
168
|
+
initial_setup: this.circuits.initial_setup
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
initialState(...args_0) {
|
|
172
|
+
if (args_0.length !== 1) {
|
|
173
|
+
throw new __compactRuntime.CompactError(`Contract state constructor: expected 1 argument (as invoked from Typescript), received ${args_0.length}`);
|
|
174
|
+
}
|
|
175
|
+
const constructorContext_0 = args_0[0];
|
|
176
|
+
if (typeof(constructorContext_0) !== 'object') {
|
|
177
|
+
throw new __compactRuntime.CompactError(`Contract state constructor: expected 'constructorContext' in argument 1 (as invoked from Typescript) to be an object`);
|
|
178
|
+
}
|
|
179
|
+
if (!('initialZswapLocalState' in constructorContext_0)) {
|
|
180
|
+
throw new __compactRuntime.CompactError(`Contract state constructor: expected 'initialZswapLocalState' in argument 1 (as invoked from Typescript)`);
|
|
181
|
+
}
|
|
182
|
+
if (typeof(constructorContext_0.initialZswapLocalState) !== 'object') {
|
|
183
|
+
throw new __compactRuntime.CompactError(`Contract state constructor: expected 'initialZswapLocalState' in argument 1 (as invoked from Typescript) to be an object`);
|
|
184
|
+
}
|
|
185
|
+
const state_0 = new __compactRuntime.ContractState();
|
|
186
|
+
let stateValue_0 = __compactRuntime.StateValue.newArray();
|
|
187
|
+
stateValue_0 = stateValue_0.arrayPush(__compactRuntime.StateValue.newNull());
|
|
188
|
+
state_0.data = new __compactRuntime.ChargedState(stateValue_0);
|
|
189
|
+
state_0.setOperation('verify_batched_handshakes', new __compactRuntime.ContractOperation());
|
|
190
|
+
state_0.setOperation('initial_setup', new __compactRuntime.ContractOperation());
|
|
191
|
+
const context = __compactRuntime.createCircuitContext(__compactRuntime.dummyContractAddress(), constructorContext_0.initialZswapLocalState.coinPublicKey, state_0.data, constructorContext_0.initialPrivateState);
|
|
192
|
+
const partialProofData = {
|
|
193
|
+
input: { value: [], alignment: [] },
|
|
194
|
+
output: undefined,
|
|
195
|
+
publicTranscript: [],
|
|
196
|
+
privateTranscriptOutputs: []
|
|
197
|
+
};
|
|
198
|
+
__compactRuntime.queryLedgerState(context,
|
|
199
|
+
partialProofData,
|
|
200
|
+
[
|
|
201
|
+
{ push: { storage: false,
|
|
202
|
+
value: __compactRuntime.StateValue.newCell({ value: _descriptor_7.toValue(0n),
|
|
203
|
+
alignment: _descriptor_7.alignment() }).encode() } },
|
|
204
|
+
{ push: { storage: true,
|
|
205
|
+
value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(new Uint8Array(32)),
|
|
206
|
+
alignment: _descriptor_0.alignment() }).encode() } },
|
|
207
|
+
{ ins: { cached: false, n: 1 } }]);
|
|
208
|
+
state_0.data = new __compactRuntime.ChargedState(context.currentQueryContext.state.state);
|
|
209
|
+
return {
|
|
210
|
+
currentContractState: state_0,
|
|
211
|
+
currentPrivateState: context.currentPrivateState,
|
|
212
|
+
currentZswapLocalState: context.currentZswapLocalState
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
_verify_batched_handshakes_0(context,
|
|
216
|
+
partialProofData,
|
|
217
|
+
previous_root_0,
|
|
218
|
+
new_root_0,
|
|
219
|
+
batched_proof_data_0,
|
|
220
|
+
total_toll_collected_0)
|
|
221
|
+
{
|
|
222
|
+
__compactRuntime.assert(true,
|
|
223
|
+
'Prover is not authorized to submit batch roots');
|
|
224
|
+
__compactRuntime.assert(this._equal_0(_descriptor_0.fromValue(__compactRuntime.queryLedgerState(context,
|
|
225
|
+
partialProofData,
|
|
226
|
+
[
|
|
227
|
+
{ dup: { n: 0 } },
|
|
228
|
+
{ idx: { cached: false,
|
|
229
|
+
pushPath: false,
|
|
230
|
+
path: [
|
|
231
|
+
{ tag: 'value',
|
|
232
|
+
value: { value: _descriptor_7.toValue(0n),
|
|
233
|
+
alignment: _descriptor_7.alignment() } }] } },
|
|
234
|
+
{ popeq: { cached: false,
|
|
235
|
+
result: undefined } }]).value),
|
|
236
|
+
previous_root_0),
|
|
237
|
+
'Previous Root mismatch! Cannot append batch.');
|
|
238
|
+
__compactRuntime.assert(total_toll_collected_0 >= 100n,
|
|
239
|
+
'Insufficient DUST/Toll fee collected for batch');
|
|
240
|
+
__compactRuntime.queryLedgerState(context,
|
|
241
|
+
partialProofData,
|
|
242
|
+
[
|
|
243
|
+
{ push: { storage: false,
|
|
244
|
+
value: __compactRuntime.StateValue.newCell({ value: _descriptor_7.toValue(0n),
|
|
245
|
+
alignment: _descriptor_7.alignment() }).encode() } },
|
|
246
|
+
{ push: { storage: true,
|
|
247
|
+
value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(new_root_0),
|
|
248
|
+
alignment: _descriptor_0.alignment() }).encode() } },
|
|
249
|
+
{ ins: { cached: false, n: 1 } }]);
|
|
250
|
+
return [];
|
|
251
|
+
}
|
|
252
|
+
_initial_setup_0(context, partialProofData, initial_root_0) {
|
|
253
|
+
__compactRuntime.queryLedgerState(context,
|
|
254
|
+
partialProofData,
|
|
255
|
+
[
|
|
256
|
+
{ push: { storage: false,
|
|
257
|
+
value: __compactRuntime.StateValue.newCell({ value: _descriptor_7.toValue(0n),
|
|
258
|
+
alignment: _descriptor_7.alignment() }).encode() } },
|
|
259
|
+
{ push: { storage: true,
|
|
260
|
+
value: __compactRuntime.StateValue.newCell({ value: _descriptor_0.toValue(initial_root_0),
|
|
261
|
+
alignment: _descriptor_0.alignment() }).encode() } },
|
|
262
|
+
{ ins: { cached: false, n: 1 } }]);
|
|
263
|
+
return [];
|
|
264
|
+
}
|
|
265
|
+
_equal_0(x0, y0) {
|
|
266
|
+
if (!x0.every((x, i) => y0[i] === x)) { return false; }
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
export function ledger(stateOrChargedState) {
|
|
271
|
+
const state = stateOrChargedState instanceof __compactRuntime.StateValue ? stateOrChargedState : stateOrChargedState.state;
|
|
272
|
+
const chargedState = stateOrChargedState instanceof __compactRuntime.StateValue ? new __compactRuntime.ChargedState(stateOrChargedState) : stateOrChargedState;
|
|
273
|
+
const context = {
|
|
274
|
+
currentQueryContext: new __compactRuntime.QueryContext(chargedState, __compactRuntime.dummyContractAddress()),
|
|
275
|
+
costModel: __compactRuntime.CostModel.initialCostModel()
|
|
276
|
+
};
|
|
277
|
+
const partialProofData = {
|
|
278
|
+
input: { value: [], alignment: [] },
|
|
279
|
+
output: undefined,
|
|
280
|
+
publicTranscript: [],
|
|
281
|
+
privateTranscriptOutputs: []
|
|
282
|
+
};
|
|
283
|
+
return {
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
const _emptyContext = {
|
|
287
|
+
currentQueryContext: new __compactRuntime.QueryContext(new __compactRuntime.ContractState().data, __compactRuntime.dummyContractAddress())
|
|
288
|
+
};
|
|
289
|
+
const _dummyContract = new Contract({ });
|
|
290
|
+
export const pureCircuits = {};
|
|
291
|
+
export const contractReferenceLocations =
|
|
292
|
+
{ tag: 'publicLedgerArray', indices: { } };
|
|
293
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "index.js",
|
|
4
|
+
"sourceRoot": "../../../",
|
|
5
|
+
"sources": ["contracts/rohan_handshake.compact"],
|
|
6
|
+
"names": [],
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;MAiBA,AAAA,yBA+BC;;;;;cA9BG,eAAwB;cACxB,UAAmB;cACnB,oBAA8B;cAC9B,sBAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yCAH9B,eAAwB,+BACxB,UAAmB,+BACnB,oBAA8B,+BAC9B,sBAA8B;;;;;;;;;2DAH9B,eAAwB;2DACxB,UAAmB;2DACnB,oBAA8B;2DAC9B,sBAA8B;;;OA2BjC;MAGD,AAAA,aAEC;;;;;cAF4B,cAAuB;;;;;;;;;;;;;;;;;;yCAAvB,cAAuB;;;;;;;;;+CAAvB,cAAuB;;;OAEnD;;;;;;;;;;GACA;EAtDD;;;;;;;;;;;;;;;;;;;;;;;;;;;IAUA;;;;;;;;;yEAAqC;;;;;;;GA4CpC;EArCD,AAAA,4BA+BC;;+BA9BG,eAAwB;+BACxB,UAAmB;+BACnB,oBAA8B;+BAC9B,sBAA8B;;;;kEAY1B;;;;;;;;;;;uIAAkB;0CAAI,eAAa;;4BAOnC,sBAAoB;;IAOxB;;;;;;;2HAA8B,UAAQ;;yEAApB;;GACrB;EAGD,AAAA,gBAEC,4BAF4B,cAAuB;IAChD;;;;;;;2HAA8B,cAAY;;yEAAxB;;GACrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"
|
|
8
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": { "major": 2, "minor": 0 },
|
|
3
|
+
"do_communications_commitment": true,
|
|
4
|
+
"num_inputs": 2,
|
|
5
|
+
"instructions": [
|
|
6
|
+
{ "op": "constrain_bits", "var": 0, "bits": 8 },
|
|
7
|
+
{ "op": "constrain_bits", "var": 1, "bits": 248 },
|
|
8
|
+
{ "op": "load_imm", "imm": "01" },
|
|
9
|
+
{ "op": "load_imm", "imm": "10" },
|
|
10
|
+
{ "op": "load_imm", "imm": "00" },
|
|
11
|
+
{ "op": "declare_pub_input", "var": 3 },
|
|
12
|
+
{ "op": "declare_pub_input", "var": 2 },
|
|
13
|
+
{ "op": "declare_pub_input", "var": 2 },
|
|
14
|
+
{ "op": "declare_pub_input", "var": 2 },
|
|
15
|
+
{ "op": "declare_pub_input", "var": 4 },
|
|
16
|
+
{ "op": "pi_skip", "guard": 2, "count": 5 },
|
|
17
|
+
{ "op": "load_imm", "imm": "11" },
|
|
18
|
+
{ "op": "load_imm", "imm": "20" },
|
|
19
|
+
{ "op": "declare_pub_input", "var": 5 },
|
|
20
|
+
{ "op": "declare_pub_input", "var": 2 },
|
|
21
|
+
{ "op": "declare_pub_input", "var": 2 },
|
|
22
|
+
{ "op": "declare_pub_input", "var": 6 },
|
|
23
|
+
{ "op": "declare_pub_input", "var": 0 },
|
|
24
|
+
{ "op": "declare_pub_input", "var": 1 },
|
|
25
|
+
{ "op": "pi_skip", "guard": 2, "count": 6 },
|
|
26
|
+
{ "op": "load_imm", "imm": "91" },
|
|
27
|
+
{ "op": "declare_pub_input", "var": 7 },
|
|
28
|
+
{ "op": "pi_skip", "guard": 2, "count": 1 }
|
|
29
|
+
]
|
|
30
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": { "major": 2, "minor": 0 },
|
|
3
|
+
"do_communications_commitment": true,
|
|
4
|
+
"num_inputs": 10,
|
|
5
|
+
"instructions": [
|
|
6
|
+
{ "op": "constrain_bits", "var": 0, "bits": 8 },
|
|
7
|
+
{ "op": "constrain_bits", "var": 1, "bits": 248 },
|
|
8
|
+
{ "op": "constrain_bits", "var": 2, "bits": 8 },
|
|
9
|
+
{ "op": "constrain_bits", "var": 3, "bits": 248 },
|
|
10
|
+
{ "op": "constrain_bits", "var": 4, "bits": 32 },
|
|
11
|
+
{ "op": "constrain_bits", "var": 5, "bits": 248 },
|
|
12
|
+
{ "op": "constrain_bits", "var": 6, "bits": 248 },
|
|
13
|
+
{ "op": "constrain_bits", "var": 7, "bits": 248 },
|
|
14
|
+
{ "op": "constrain_bits", "var": 8, "bits": 248 },
|
|
15
|
+
{ "op": "constrain_bits", "var": 9, "bits": 64 },
|
|
16
|
+
{ "op": "load_imm", "imm": "01" },
|
|
17
|
+
{ "op": "load_imm", "imm": "30" },
|
|
18
|
+
{ "op": "declare_pub_input", "var": 11 },
|
|
19
|
+
{ "op": "pi_skip", "guard": 10, "count": 1 },
|
|
20
|
+
{ "op": "load_imm", "imm": "50" },
|
|
21
|
+
{ "op": "load_imm", "imm": "00" },
|
|
22
|
+
{ "op": "declare_pub_input", "var": 12 },
|
|
23
|
+
{ "op": "declare_pub_input", "var": 10 },
|
|
24
|
+
{ "op": "declare_pub_input", "var": 10 },
|
|
25
|
+
{ "op": "declare_pub_input", "var": 13 },
|
|
26
|
+
{ "op": "pi_skip", "guard": 10, "count": 4 },
|
|
27
|
+
{ "op": "public_input", "guard": null },
|
|
28
|
+
{ "op": "public_input", "guard": null },
|
|
29
|
+
{ "op": "load_imm", "imm": "20" },
|
|
30
|
+
{ "op": "load_imm", "imm": "0C" },
|
|
31
|
+
{ "op": "declare_pub_input", "var": 17 },
|
|
32
|
+
{ "op": "declare_pub_input", "var": 10 },
|
|
33
|
+
{ "op": "declare_pub_input", "var": 16 },
|
|
34
|
+
{ "op": "declare_pub_input", "var": 14 },
|
|
35
|
+
{ "op": "declare_pub_input", "var": 15 },
|
|
36
|
+
{ "op": "pi_skip", "guard": 10, "count": 5 },
|
|
37
|
+
{ "op": "test_eq", "a": 14, "b": 0 },
|
|
38
|
+
{ "op": "test_eq", "a": 15, "b": 1 },
|
|
39
|
+
{ "op": "cond_select", "bit": 18, "a": 19, "b": 13 },
|
|
40
|
+
{ "op": "assert", "cond": 20 },
|
|
41
|
+
{ "op": "load_imm", "imm": "64" },
|
|
42
|
+
{ "op": "less_than", "a": 9, "b": 21, "bits": 64 },
|
|
43
|
+
{ "op": "cond_select", "bit": 22, "a": 13, "b": 10 },
|
|
44
|
+
{ "op": "assert", "cond": 23 },
|
|
45
|
+
{ "op": "load_imm", "imm": "10" },
|
|
46
|
+
{ "op": "declare_pub_input", "var": 24 },
|
|
47
|
+
{ "op": "declare_pub_input", "var": 10 },
|
|
48
|
+
{ "op": "declare_pub_input", "var": 10 },
|
|
49
|
+
{ "op": "declare_pub_input", "var": 10 },
|
|
50
|
+
{ "op": "declare_pub_input", "var": 13 },
|
|
51
|
+
{ "op": "pi_skip", "guard": 10, "count": 5 },
|
|
52
|
+
{ "op": "load_imm", "imm": "11" },
|
|
53
|
+
{ "op": "declare_pub_input", "var": 25 },
|
|
54
|
+
{ "op": "declare_pub_input", "var": 10 },
|
|
55
|
+
{ "op": "declare_pub_input", "var": 10 },
|
|
56
|
+
{ "op": "declare_pub_input", "var": 16 },
|
|
57
|
+
{ "op": "declare_pub_input", "var": 2 },
|
|
58
|
+
{ "op": "declare_pub_input", "var": 3 },
|
|
59
|
+
{ "op": "pi_skip", "guard": 10, "count": 6 },
|
|
60
|
+
{ "op": "load_imm", "imm": "91" },
|
|
61
|
+
{ "op": "declare_pub_input", "var": 26 },
|
|
62
|
+
{ "op": "pi_skip", "guard": 10, "count": 1 }
|
|
63
|
+
]
|
|
64
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Rohan Protocol
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|