Skip to content

Commit 5babc79

Browse files
committed
Charms v0.8.0
Update to - SP1 v5.1.0 - protocol version 6 - Rust 1.88
1 parent 32b5b25 commit 5babc79

File tree

28 files changed

+378
-218
lines changed

28 files changed

+378
-218
lines changed

Cargo.lock

Lines changed: 284 additions & 133 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ edition.workspace = true
99
license.workspace = true
1010

1111
[workspace.package]
12-
version = "0.7.0"
13-
edition = "2021"
12+
version = "0.8.0"
13+
edition = "2024"
1414
authors = ["Ivan Mikushin <ivan@charms.dev>"]
1515
license = "MIT"
1616

@@ -21,17 +21,17 @@ axum-macros = { version = "0.5.0" }
2121
bincode = { version = "1.3.3" }
2222
bitcoin = { workspace = true, features = ["rand", "rand-std"] }
2323
bitcoincore-rpc = { version = "0.19.0" }
24-
charms-app-runner = { path = "./charms-app-runner", version = "0.7.0" }
25-
charms-client = { path = "./charms-client", version = "0.7.0" }
26-
charms-data = { path = "./charms-data", version = "0.7.0" }
27-
clap = { version = "4.5.40", features = ["derive"] }
28-
clap_complete = { version = "4.5.54" }
24+
charms-app-runner = { path = "./charms-app-runner", version = "0.8.0" }
25+
charms-client = { path = "./charms-client", version = "0.8.0" }
26+
charms-data = { path = "./charms-data", version = "0.8.0" }
27+
clap = { version = "4.5.41", features = ["derive"] }
28+
clap_complete = { version = "4.5.55" }
2929
cml-chain = { workspace = true }
3030
hex = { workspace = true }
31-
reqwest = { version = "0.12.20", features = ["json"] }
31+
reqwest = { version = "0.12.22", features = ["json"] }
3232
serde = { workspace = true, features = ["derive"] }
3333
serde_json = { workspace = true }
34-
serde_with = { version = "3.13.0", features = ["base64"] }
34+
serde_with = { version = "3.14.0", features = ["base64"] }
3535
serde_yaml = { workspace = true }
3636
sha2 = { workspace = true }
3737
sp1-core-executor = { workspace = true }
@@ -40,7 +40,7 @@ sp1-cuda = { workspace = true }
4040
sp1-primitives = { workspace = true }
4141
sp1-prover = { workspace = true }
4242
sp1-sdk = { workspace = true }
43-
tokio = { version = "1.45", features = ["full"] }
43+
tokio = { version = "1.47", features = ["full"] }
4444
toml = { version = "0.8.23" }
4545
tower-http = { version = "0.6.6", features = ["cors"] }
4646
tracing = { workspace = true }
@@ -66,7 +66,7 @@ members = [
6666
"charms-spell-checker",
6767
]
6868

69-
resolver = "2"
69+
resolver = "3"
7070

7171
[workspace.dependencies]
7272
anyhow = { version = "1.0.98" }
@@ -78,17 +78,17 @@ hex = { version = "0.4.3" }
7878
proptest = { version = "1.7.0" }
7979
proptest-derive = { version = "0.5.1" }
8080
serde = { version = "1.0" }
81-
serde_json = { version = "1.0.140" }
81+
serde_json = { version = "1.0.141" }
8282
serde_yaml = { version = "0.9.34" }
83-
sha2 = { version = "0.10.8" }
84-
sp1-core-executor = { version = "5.0.5" }
85-
sp1-core-machine = { version = "5.0.5" }
86-
sp1-cuda = { version = "5.0.5" }
87-
sp1-primitives = { version = "5.0.5" }
88-
sp1-prover = { version = "5.0.5" }
89-
sp1-sdk = { version = "5.0.6" }
90-
sp1-verifier = { version = "5.0.5" }
91-
sp1-zkvm = { version = "5.0.5" }
83+
sha2 = { version = "0.10.9" }
84+
sp1-core-executor = { version = "5.1.0" }
85+
sp1-core-machine = { version = "5.1.0" }
86+
sp1-cuda = { version = "5.1.0" }
87+
sp1-primitives = { version = "5.1.0" }
88+
sp1-prover = { version = "5.1.0" }
89+
sp1-sdk = { version = "5.1.0" }
90+
sp1-verifier = { version = "5.1.0" }
91+
sp1-zkvm = { version = "5.1.0" }
9292
test-strategy = { version = "0.4.3" }
9393
tracing = { version = "0.1" }
9494

@@ -103,5 +103,4 @@ strip = "debuginfo"
103103

104104
[patch.crates-io]
105105
secp256k1 = { git = "https://github.com/sp1-patches/rust-secp256k1", tag = "patch-0.29.1-sp1-5.0.0" }
106-
sha2 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", tag = "patch-sha2-0.10.8-sp1-4.0.0" }
107-
wasmi = { git = "https://github.com/imikushin/wasmi", branch = "rust-1.85" }
106+
sha2 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", tag = "patch-sha2-0.10.9-sp1-4.0.0" }

charms-app-checker/Cargo.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ edition.workspace = true
77
license.workspace = true
88

99
[dependencies]
10-
charms-app-runner = { path = "../charms-app-runner", version = "0.7.0" }
11-
charms-data = { path = "../charms-data", version = "0.7.0" }
12-
charms-client = { path = "../charms-client", version = "0.7.0" }
13-
serde = { workspace = true, features = ["derive"] }
14-
sp1-primitives = { workspace = true }
15-
sp1-zkvm = { workspace = true, features = ["verify"] }
10+
charms-app-runner = { path = "../charms-app-runner", version = "0.8.0" }
11+
charms-data = { path = "../charms-data", version = "0.8.0" }
12+
sp1-zkvm = { workspace = true }

charms-app-checker/src/bin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use charms_client::{AppProverInput, AppProverOutput};
1+
use charms_app_runner::{AppProverInput, AppProverOutput};
22
use charms_data::util;
33

44
pub fn main() {

charms-app-runner/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ license.workspace = true
99

1010
[dependencies]
1111
anyhow = { workspace = true }
12-
charms-data = { path = "../charms-data", version = "0.7.0" }
12+
charms-data = { path = "../charms-data", version = "0.8.0" }
13+
serde = { workspace = true, features = ["derive"] }
1314
sha2 = { workspace = true }
1415
wasmi = { version = "0.48.0", default-features = false, features = ["std", "prefer-btree-collections"] }

charms-app-runner/src/lib.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
use anyhow::{bail, ensure, Result};
2-
use charms_data::{is_simple_transfer, util, App, Data, Transaction, B32};
1+
use anyhow::{Result, bail, ensure};
2+
use charms_data::{App, B32, Data, Transaction, is_simple_transfer, util};
3+
use serde::{Deserialize, Serialize};
34
use sha2::{Digest, Sha256};
45
use std::{
56
collections::BTreeMap,
@@ -8,6 +9,21 @@ use std::{
89
};
910
use wasmi::{Caller, Config, Engine, Extern, Linker, Memory, Module, Store};
1011

12+
#[derive(Clone, Debug, Serialize, Deserialize)]
13+
pub struct AppProverInput {
14+
pub app_binaries: BTreeMap<B32, Vec<u8>>,
15+
pub tx: Transaction,
16+
pub app_public_inputs: BTreeMap<App, Data>,
17+
pub app_private_inputs: BTreeMap<App, Data>,
18+
}
19+
20+
#[derive(Clone, Debug, Serialize, Deserialize)]
21+
pub struct AppProverOutput {
22+
pub tx: Transaction,
23+
pub app_public_inputs: BTreeMap<App, Data>,
24+
pub cycles: Vec<u64>,
25+
}
26+
1127
#[derive(Clone)]
1228
pub struct AppRunner {
1329
pub engine: Engine,

charms-client/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ license.workspace = true
1010
[dependencies]
1111
anyhow = { workspace = true }
1212
bitcoin = { workspace = true, features = ["serde"] }
13-
charms-data = { path = "../charms-data", version = "0.7.0" }
13+
charms-app-runner = { path = "../charms-app-runner", version = "0.8.0" }
14+
charms-data = { path = "../charms-data", version = "0.8.0" }
1415
cml-chain = { workspace = true }
1516
enum_dispatch = { version = "0.3.13" }
1617
hex = { workspace = true }
1718
serde = { workspace = true, features = ["derive"] }
18-
serde_with = { version = "3.13.0" }
19+
serde_with = { version = "3.14.0" }
1920
sha2 = { workspace = true }
2021
sp1-primitives = { workspace = true }
2122
sp1-verifier = { workspace = true }
2223
tracing = { workspace = true }
2324

2425
[dev-dependencies]
2526
ciborium = { version = "0.2.2" }
26-
serde_json = { version = "1.0.140" }
27+
serde_json = { version = "1.0.141" }

charms-client/src/lib.rs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
use crate::tx::{extract_and_verify_spell, EnchantedTx, Tx};
2-
use charms_data::{check, App, Charms, Data, Transaction, TxId, UtxoId, B32};
1+
use crate::tx::{EnchantedTx, Tx, extract_and_verify_spell};
2+
use charms_data::{App, B32, Charms, Data, Transaction, TxId, UtxoId, check};
33
use serde::{Deserialize, Serialize};
44
use sha2::{Digest, Sha256};
55
use std::collections::{BTreeMap, BTreeSet};
66

7+
pub use charms_app_runner::{AppProverInput, AppProverOutput};
8+
79
pub mod bitcoin_tx;
810
pub mod cardano_tx;
911
pub mod tx;
1012

1113
pub const APP_VK: [u32; 8] = [
12-
487454586, 357291639, 225001263, 1885191303, 293126599, 491099374, 3759322, 1460462146,
14+
773139792, 1871461666, 1172442063, 346922495, 1779450904, 263758648, 121652725, 113479979,
1315
];
1416

1517
/// Verification key for version `0` of the protocol implemented by `charms-spell-checker` binary.
@@ -22,6 +24,8 @@ pub const V2_SPELL_VK: &str = "0x00bd312b6026dbe4a2c16da1e8118d4fea31587a4b572b6
2224
pub const V3_SPELL_VK: &str = "0x0034872b5af38c95fe82fada696b09a448f7ab0928273b7ac8c58ba29db774b9";
2325
/// Verification key for version `4` of the protocol implemented by `charms-spell-checker` binary.
2426
pub const V4_SPELL_VK: &str = "0x00c707a155bf8dc18dc41db2994c214e93e906a3e97b4581db4345b3edd837c5";
27+
/// Verification key for version `5` of the protocol implemented by `charms-spell-checker` binary.
28+
pub const V5_SPELL_VK: &str = "0x00e98665c417bd2e6e81c449af63b26ed5ad5c400ef55811b592450bf62c67cd";
2529

2630
/// Version `0` of the protocol.
2731
pub const V0: u32 = 0u32;
@@ -35,9 +39,11 @@ pub const V3: u32 = 3u32;
3539
pub const V4: u32 = 4u32;
3640
/// Version `5` of the protocol.
3741
pub const V5: u32 = 5u32;
42+
/// Version `6` of the protocol.
43+
pub const V6: u32 = 6u32;
3844

3945
/// Current version of the protocol.
40-
pub const CURRENT_VERSION: u32 = V5;
46+
pub const CURRENT_VERSION: u32 = V6;
4147

4248
/// Maps the index of the charm's app (in [`NormalizedSpell`].`app_public_inputs`) to the charm's
4349
/// data.
@@ -270,21 +276,6 @@ pub struct SpellProverInput {
270276
pub app_prover_output: Option<AppProverOutput>, // proof is provided in input stream data
271277
}
272278

273-
#[derive(Clone, Debug, Serialize, Deserialize)]
274-
pub struct AppProverInput {
275-
pub app_binaries: BTreeMap<B32, Vec<u8>>,
276-
pub tx: Transaction,
277-
pub app_public_inputs: BTreeMap<App, Data>,
278-
pub app_private_inputs: BTreeMap<App, Data>,
279-
}
280-
281-
#[derive(Clone, Debug, Serialize, Deserialize)]
282-
pub struct AppProverOutput {
283-
pub tx: Transaction,
284-
pub app_public_inputs: BTreeMap<App, Data>,
285-
pub cycles: Vec<u64>,
286-
}
287-
288279
#[cfg(test)]
289280
mod test {
290281
#[test]

charms-client/src/tx.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use crate::{
2-
bitcoin_tx::BitcoinTx, cardano_tx::CardanoTx, NormalizedSpell, CURRENT_VERSION, V0,
3-
V0_SPELL_VK, V1, V1_SPELL_VK, V2, V2_SPELL_VK, V3, V3_SPELL_VK, V4, V4_SPELL_VK,
2+
CURRENT_VERSION, NormalizedSpell, V0, V0_SPELL_VK, V1, V1_SPELL_VK, V2, V2_SPELL_VK, V3,
3+
V3_SPELL_VK, V4, V4_SPELL_VK, V5, V5_SPELL_VK, bitcoin_tx::BitcoinTx, cardano_tx::CardanoTx,
44
};
55
use anyhow::bail;
6-
use charms_data::{util, TxId};
6+
use charms_data::{TxId, util};
77
use enum_dispatch::enum_dispatch;
88
use serde::{Deserialize, Serialize};
9-
use serde_with::{serde_as, IfIsHumanReadable};
9+
use serde_with::{IfIsHumanReadable, serde_as};
1010
use sp1_primitives::io::SP1PublicValues;
1111

1212
#[enum_dispatch]
@@ -72,6 +72,7 @@ pub fn extract_and_verify_spell(spell_vk: &str, tx: &Tx) -> anyhow::Result<Norma
7272
pub fn vks(spell_version: u32, spell_vk: &str) -> anyhow::Result<(&str, &[u8])> {
7373
match spell_version {
7474
CURRENT_VERSION => Ok((spell_vk, CURRENT_GROTH16_VK_BYTES)),
75+
V5 => Ok((V5_SPELL_VK, V5_GROTH16_VK_BYTES)),
7576
V4 => Ok((V4_SPELL_VK, V4_GROTH16_VK_BYTES)),
7677
V3 => Ok((V3_SPELL_VK, V3_GROTH16_VK_BYTES)),
7778
V2 => Ok((V2_SPELL_VK, V2_GROTH16_VK_BYTES)),
@@ -87,12 +88,13 @@ pub const V2_GROTH16_VK_BYTES: &'static [u8] = V1_GROTH16_VK_BYTES;
8788
pub const V3_GROTH16_VK_BYTES: &'static [u8] = V1_GROTH16_VK_BYTES;
8889
pub const V4_GROTH16_VK_BYTES: &'static [u8] = include_bytes!("../vk/v4/groth16_vk.bin");
8990
pub const V5_GROTH16_VK_BYTES: &'static [u8] = V4_GROTH16_VK_BYTES;
90-
pub const CURRENT_GROTH16_VK_BYTES: &'static [u8] = V5_GROTH16_VK_BYTES;
91+
pub const V6_GROTH16_VK_BYTES: &'static [u8] = V5_GROTH16_VK_BYTES;
92+
pub const CURRENT_GROTH16_VK_BYTES: &'static [u8] = V6_GROTH16_VK_BYTES;
9193

9294
pub fn to_sp1_pv<T: Serialize>(spell_version: u32, t: &T) -> SP1PublicValues {
9395
let mut pv = SP1PublicValues::new();
9496
match spell_version {
95-
CURRENT_VERSION | V4 | V3 | V2 | V1 => {
97+
CURRENT_VERSION | V5 | V4 | V3 | V2 | V1 => {
9698
// we commit to CBOR-encoded tuple `(spell_vk, n_spell)`
9799
pv.write_slice(util::write(t).unwrap().as_slice());
98100
}

charms-sdk/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ authors.workspace = true
88
license.workspace = true
99

1010
[dependencies]
11-
charms-data = { path = "../charms-data", version = "0.7.0" }
11+
charms-data = { path = "../charms-data", version = "0.8.0" }

0 commit comments

Comments
 (0)