Skip to content

Commit b067ed5

Browse files
committed
fixed Context serialization and dummy proof construction
1 parent 389c389 commit b067ed5

File tree

5 files changed

+51
-5
lines changed

5 files changed

+51
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 0.12.1 (2025-02-12) - `air` crate only
4+
- Fixed `Context` struct serialization.
5+
36
## 0.12.0 (2025-02-08)
47
- [BREAKING] Added security estimate in unique decoding regime (#356).
58
- [BREAKING] Added option for algebraic batching to build DEEP polynomial (#357).

air/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
22
name = "winter-air"
3-
version = "0.12.0"
3+
version = "0.12.1"
44
description = "AIR components for the Winterfell STARK prover/verifier"
55
authors = ["winterfell contributors"]
66
readme = "README.md"
77
license = "MIT"
88
repository = "https://github.com/novifinancial/winterfell"
9-
documentation = "https://docs.rs/winter-air/0.12.0"
9+
documentation = "https://docs.rs/winter-air/0.12.1"
1010
categories = ["cryptography", "no-std"]
1111
keywords = ["crypto", "arithmetization", "air"]
1212
edition = "2021"

air/src/proof/context.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ impl Serializable for Context {
147147
target.write_u8(self.field_modulus_bytes.len() as u8);
148148
target.write_bytes(&self.field_modulus_bytes);
149149
self.options.write_into(target);
150+
self.num_constraints.write_into(target);
150151
}
151152
}
152153

@@ -190,7 +191,7 @@ impl Deserializable for Context {
190191
mod tests {
191192
use math::fields::f64::BaseElement;
192193

193-
use super::{Context, ProofOptions, ToElements, TraceInfo};
194+
use super::{Context, Deserializable, ProofOptions, Serializable, ToElements, TraceInfo};
194195
use crate::{options::BatchingMethod, FieldExtension};
195196

196197
#[test]
@@ -254,4 +255,30 @@ mod tests {
254255
let context = Context::new::<BaseElement>(trace_info, options, num_constraints);
255256
assert_eq!(expected, context.to_elements());
256257
}
258+
259+
#[test]
260+
fn context_serialization() {
261+
use math::fields::f64::BaseElement as DummyField;
262+
263+
let context = Context::new::<DummyField>(
264+
TraceInfo::new(1, 8),
265+
ProofOptions::new(
266+
1,
267+
2,
268+
2,
269+
FieldExtension::None,
270+
8,
271+
1,
272+
BatchingMethod::Linear,
273+
BatchingMethod::Linear,
274+
),
275+
100,
276+
);
277+
278+
let bytes = context.to_bytes();
279+
280+
let deserialized_context = Context::read_from_bytes(&bytes).unwrap();
281+
282+
assert_eq!(context, deserialized_context);
283+
}
257284
}

air/src/proof/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,14 @@ impl Proof {
164164
),
165165
100,
166166
),
167-
num_unique_queries: 0,
167+
num_unique_queries: 1,
168168
commitments: Commitments::default(),
169-
trace_queries: Vec::new(),
169+
trace_queries: vec![
170+
Queries::new::<DummyHasher<DummyField>, DummyField, MerkleTree<_>>(
171+
BatchMerkleProof::<DummyHasher<DummyField>> { nodes: Vec::new(), depth: 0 },
172+
vec![vec![DummyField::ONE]],
173+
),
174+
],
170175
constraint_queries: Queries::new::<DummyHasher<DummyField>, DummyField, MerkleTree<_>>(
171176
BatchMerkleProof::<DummyHasher<DummyField>> { nodes: Vec::new(), depth: 0 },
172177
vec![vec![DummyField::ONE]],

air/src/proof/tests.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,14 @@ use super::Proof;
99
pub fn starkproof_new_dummy_doesnt_panic() {
1010
let _ = Proof::new_dummy();
1111
}
12+
13+
#[test]
14+
fn dummy_proof_serialization() {
15+
let proof = Proof::new_dummy();
16+
17+
let bytes = proof.to_bytes();
18+
19+
let proof_copy = Proof::from_bytes(&bytes).unwrap();
20+
21+
assert_eq!(proof, proof_copy);
22+
}

0 commit comments

Comments
 (0)