Skip to content

Commit 6fce3e7

Browse files
committed
include candid-extractor. realised we need pullable metadata on dfx.json. us gh action to release wasm on github
1 parent dcf7d82 commit 6fce3e7

File tree

6 files changed

+124
-62
lines changed

6 files changed

+124
-62
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Release Verity Managed *General Purpose MPC-TLS* Verifier WASM
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch: {}
8+
9+
jobs:
10+
build-and-release:
11+
name: Build and publish WASM
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Rust (stable) with wasm32-wasip1 target
20+
uses: dtolnay/rust-toolchain@stable
21+
with:
22+
targets: wasm32-wasip1
23+
24+
- name: Install build dependencies
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y binaryen
28+
cargo install --locked wasi2ic candid-extractor
29+
30+
- name: Install DFX
31+
run: |
32+
DFX_VERSION=0.27.0 sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)"
33+
echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH
34+
echo "$HOME/bin" >> $GITHUB_PATH
35+
dfx --version
36+
37+
- name: Build verifier canister via dfx
38+
working-directory: ic/managed/verifier
39+
run: dfx build --skip-assets
40+
41+
- name: Compute checksum
42+
run: |
43+
cd target/wasm32-wasip1/release
44+
sha256sum verity_ic_verifier_ic.wasm | tee verity_ic_verifier_ic.wasm.sha256
45+
46+
- name: Create GitHub Release and upload assets
47+
uses: softprops/action-gh-release@v2
48+
with:
49+
files: |
50+
target/wasm32-wasip1/release/verity_ic_verifier_ic.wasm
51+
target/wasm32-wasip1/release/verity_ic_verifier_ic.wasm.sha256
52+
draft: false
53+
prerelease: false
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
57+

ic/managed/verifier/README.md

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
1-
# Verity Managed `verifier`
1+
# Verity Managed *General Purpose MPC-TLS* Verifier
22

33
To learn about the Verity Verifier in detail, please refer to the [official documentation](https://docs.verity.usher.so/), specifically the [Verity Verifier](https://docs.verity.usher.so/build/verifier) section.
44

5-
**The following is from the Docs as of *23rd of January 2025*.**
5+
**The following is from the documentation as of *23 January 2025*.**
66

77
## Local Deployment
88

9-
**Disclaimer:** Deployment of the canister (ic/managed/verifier) to the Mainnet is not advised. This is to ensure compliance with licensing agreements and to maintain security compatibility with the wider Verity Network. We recommend using our Managed Verifier and interfacing over XNET `async` call or wallet-to-IC update `direct` call for optimal security and performance.
9+
**Disclaimer:** Deployment of the canister (`ic/managed/verifier`) to mainnet is not recommended. This is to ensure compliance with licence agreements and to maintain compatibility and security with the broader Verity Network. We recommend using our Managed *General Purpose MPC-TLS* Verifier and interfacing via an inter-canister `async` calls or a wallet‑to‑IC `direct` calls for optimal security and performance.
1010

1111
### Prerequisites
1212

13-
1. **Ensure Rust is configured for for `wasm32-wasip1` target.**
13+
1. **Ensure Rust is configured for the `wasm32-wasip1` target.**
1414

1515
```bash
1616
rustup target add wasm32-wasip1
1717
```
1818

19-
2. Install `wasi2ic`
19+
2. Install `wasi2ic`:
2020

2121
```bash
2222
cargo install wasi2ic
2323
```
2424

25-
3. Install `binaryen`
25+
3. Install `binaryen`:
26+
27+
With Homebrew:
28+
29+
```bash
30+
brew install binaryen
31+
```
32+
33+
From the releases page:
2634
1. Download [Binaryen](https://github.com/WebAssembly/binaryen/releases) from the releases page.
27-
2. Extract the files - `tar -xzf binaryen-version.tar.gz`
28-
3. Move to a directory - `sudo mv binaryen-version/bin/wasm-opt /usr/local/bin/`
29-
4. `wasm-opt --version`
35+
2. Extract the files: `tar -xzf binaryen-version.tar.gz`.
36+
3. Move the binary to your PATH: `sudo mv binaryen-version/bin/wasm-opt /usr/local/bin/`.
37+
4. Verify the installation: `wasm-opt --version`.
3038

3139
### Deployment
3240

@@ -35,50 +43,51 @@ To deploy the canister locally, follow these steps:
3543
1. `dfx start --clean`
3644
2. `dfx deploy`
3745

38-
### Test
46+
### Testing
3947

4048
1. `pnpm prep`
4149
2. `pnpm test --run`
4250

43-
### Performance Benchmarks
51+
### Performance benchmarks
4452

4553
We have benchmarked the following functions to provide insight into their performance:
4654

47-
#### verify_proof_async and verify_proof_async_batch
55+
#### `verify_proof_async` and `verify_proof_async_batch`
4856

49-
- **Execution Time:** Constant time, regardless of input size(~2100ms).
50-
- **DFX Cycle Cost:** Ranges between 550-720 per TLS data bytes/length.
57+
- **Execution time:** Constant, regardless of input size (~2100 ms).
58+
- **DFX cycle cost:** Approximately 550720 cycles per byte of TLS data.
5159

52-
#### verify_proof_direct and verify_proof_direct_batch
60+
#### `verify_proof_direct` and `verify_proof_direct_batch`
5361

54-
- **Execution Time:** Linear time, calculated as 3x the execution time of `verify_proof_async` plus Signing Time (L).
55-
- **DFX Cycle Cost:** Almost the same as `verify_proof_async` and `verify_proof_async_batch`.
62+
- **Execution time:** Linear; approximately 3× the execution time of `verify_proof_async` plus signing time (L).
63+
- **DFX cycle cost:** Roughly the same as `verify_proof_async` and `verify_proof_async_batch`.
5664

5765
### Caveats
5866

5967
#### `clang` dependency
6068

61-
**On macOS:** If you are experiencing issues during `cargo build` where the `ring` library fails to compile, this is typically due to `clang` not being found.
69+
**On macOS:** If you experience issues during `cargo build` where the `ring` library fails to compile, this is typically because `clang` is not found.
70+
71+
To resolve this:
6272

63-
To resolve this, you can install `clang` using Homebrew.
73+
1. Install `clang` using Homebrew.
6474

6575
```bash
66-
brew install clang llvm
76+
brew install llvm
6777
```
6878

69-
Alternatively, you can set the following environment variables:
79+
2. Ensure `clang` is on your `PATH`:
7080

7181
```bash
72-
export WASI_SDK_PATH=/usr/local/wasi-sdk-25.0
73-
export CC_wasm32_wasip1="${WASI_SDK_PATH}/bin/clang"
82+
echo 'PATH="$(brew --prefix llvm)/bin${PATH:+:${PATH}}"; export PATH;' >> ~/.zshrc
7483
```
7584

7685
#### `etherum_pk`
7786

78-
The `etherum_pk` field in the `PublicKeyReply` struct is the Ethereum address derived from the Sec1 public key. This is done using the `get_address_from_public_key` function in the `ethereum` module.
87+
The `etherum_pk` field in the `PublicKeyReply` struct is the Ethereum address derived from the SEC1 public key. This is obtained using the `get_address_from_public_key` function in the `ethereum` module.
7988

8089
```rust
8190
let address = ethereum::get_address_from_public_key(res.public_key.clone()).expect("INVALID_PUBLIC_KEY");
8291
```
8392

84-
*It should be spelled `ethereum_pk` and not `etherum_pk`.*
93+
*It should be spelled `ethereum_pk`, not `etherum_pk`.*

ic/managed/verifier/dfx.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@
1313
},
1414
"type": "custom",
1515
"wasm": "../../../target/wasm32-wasip1/release/verity_ic_verifier_ic.wasm",
16-
"build": ["bash -c ./scripts/build.sh"]
16+
"build": ["bash -c ./scripts/build.sh"],
17+
"pullable": {
18+
"wasm_url": "https://github.com/usherlabs/verity-dp/releases/latest/download/verity_ic_verifier_ic.wasm",
19+
"init_guide": "If running in production, call: `dfx canister call verity_verifier reinitialize '(opt variant { Production })' --ic` ",
20+
"dependencies": [],
21+
"init_arg": null,
22+
"wasm_hash": null
23+
}
1724
}
1825
},
1926
"output_env_file": ".env",

ic/managed/verifier/scripts/build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ set -ex
44
# sudo apt-get install binaryen
55
# cargo install wasi2ic
66

7+
# Install candid-extractor to generating Candid files for Rust canisters
8+
# https://internetcomputer.org/docs/building-apps/developer-tools/cdks/rust/generating-candid
9+
# cargo install candid-extractor
10+
711
# cargo build --target wasm32-unknown-unknown --release -p ic_af --locked
812
# wasi2ic ./target/wasm32-unknown-unknown/release/ic_af.wasm ./target/wasm32-unknown-unknown/release/ic_af-ic.wasm
913
# wasm-opt -Os -o ./target/wasm32-unknown-unknown/release/ic_af-ic.wasm \
1014
# ./target/wasm32-unknown-unknown/release/ic_af-ic.wasm
1115

1216
# export RUSTFLAGS=$RUSTFLAGS' -C target-feature=+simd128'
1317
cargo build --target wasm32-wasip1 --release -p verity-ic-verifier
18+
candid-extractor ../../../target/wasm32-wasip1/release/verity_ic_verifier.wasm > verity_verifier.did
1419
wasi2ic ../../../target/wasm32-wasip1/release/verity_ic_verifier.wasm ../../../target/wasm32-wasip1/release/verity_ic_verifier_ic.wasm
1520
wasm-opt -Os -o ../../../target/wasm32-wasip1/release/verity_ic_verifier_ic.wasm \
1621
../../../target/wasm32-wasip1/release/verity_ic_verifier_ic.wasm

ic/managed/verifier/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,6 @@ async fn post_upgrade() {
139139
init_canister(env_opt);
140140
}
141141
// --------------------------- upgrade hooks ------------------------- //
142+
143+
// Enable Candid export
144+
ic_cdk::export_candid!();
Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,19 @@
1-
type ProofVerificationResponse = vec ProofResponse;
2-
3-
type ProofResponse = variant {
4-
SessionProof : text;
5-
FullProof : text;
6-
};
7-
8-
type MerkleTree = record {
9-
nodes : vec text;
10-
num_leaves : nat64;
11-
root : text;
12-
};
13-
141
type DirectVerificationResponse = record {
15-
results : ProofVerificationResponse;
16-
root : text;
17-
signature : text;
18-
};
19-
20-
type DirectVerificationResult = variant {
21-
Ok : DirectVerificationResponse;
22-
Err : text;
23-
};
24-
25-
type ProofBatch = record {
26-
proof_requests : vec text;
27-
notary_pub_key : text;
2+
signature : text;
3+
root : text;
4+
results : vec ProofResponse;
285
};
29-
30-
31-
service : {
32-
"ping" : () -> (text) query;
33-
"verify_proof_direct" : (proof_requests : vec text, notary_pub_key : text) -> (DirectVerificationResult);
34-
"verify_proof_async" : (proof_requests : vec text, notary_pub_key : text) -> (ProofVerificationResponse);
35-
"verify_proof_direct_batch": (batches: vec ProofBatch) -> (DirectVerificationResult);
36-
"verify_proof_async_batch" : (batches: vec ProofBatch) -> (ProofVerificationResponse);
37-
"public_key" : () -> (record { sec1_pk : text; etherum_pk : text });
38-
};
6+
type Environment = variant { Production; Development; Staging };
7+
type ProofBatch = record { proof_requests : vec text; notary_pub_key : text };
8+
type ProofResponse = variant { SessionProof : text; FullProof : text };
9+
type PublicKeyReply = record { sec1_pk : text; etherum_pk : text };
10+
type Result = variant { Ok : DirectVerificationResponse; Err : text };
11+
service : (opt Environment) -> {
12+
ping : () -> (text) query;
13+
public_key : () -> (PublicKeyReply);
14+
reinitialize : (opt Environment) -> ();
15+
verify_proof_async : (vec text, text) -> (vec ProofResponse) query;
16+
verify_proof_async_batch : (vec ProofBatch) -> (vec ProofResponse) query;
17+
verify_proof_direct : (vec text, text) -> (Result);
18+
verify_proof_direct_batch : (vec ProofBatch) -> (Result);
19+
}

0 commit comments

Comments
 (0)