Skip to content

Commit a82d8b0

Browse files
committed
fix the delta format in compliance instance
1 parent 504294e commit a82d8b0

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

native/aarm_core/src/compliance.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use crate::{
2-
constants::{DEFAULT_BYTES, TRIVIAL_RESOURCE_LOGIC_VK},
3-
merkle_path::MerklePath,
4-
nullifier_key::NullifierKey,
2+
constants::TRIVIAL_RESOURCE_LOGIC_VK, merkle_path::MerklePath, nullifier_key::NullifierKey,
53
resource::Resource,
64
};
75
use k256::{
8-
elliptic_curve::{group::GroupEncoding, Field},
9-
ProjectivePoint, Scalar,
6+
elliptic_curve::{
7+
sec1::{FromEncodedPoint, ToEncodedPoint},
8+
Field,
9+
},
10+
EncodedPoint, ProjectivePoint, Scalar,
1011
};
1112
use rand::Rng;
1213
use risc0_zkvm::sha::{Digest, Impl, Sha256};
@@ -17,7 +18,7 @@ pub struct ComplianceInstance {
1718
pub nullifier: Digest,
1819
pub commitment: Digest,
1920
pub merkle_root: Digest,
20-
pub delta: [u8; DEFAULT_BYTES],
21+
pub delta: EncodedPoint,
2122
pub consumed_logic_ref: Digest,
2223
pub created_logic_ref: Digest,
2324
}
@@ -117,17 +118,26 @@ impl<const COMMITMENT_TREE_DEPTH: usize> ComplianceCircuit<COMMITMENT_TREE_DEPTH
117118
MerklePath::from_path(self.compliance_witness.merkle_path).root(cm)
118119
}
119120

120-
pub fn delta_commitment(&self) -> [u8; DEFAULT_BYTES] {
121+
pub fn delta_commitment(&self) -> EncodedPoint {
121122
// Compute delta and make delta commitment public
122123
let delta = self.compliance_witness.consumed_resource.kind()
123124
* self.compliance_witness.consumed_resource.quantity_scalar()
124125
- self.compliance_witness.created_resource.kind()
125126
* self.compliance_witness.created_resource.quantity_scalar()
126127
+ ProjectivePoint::GENERATOR * self.compliance_witness.rcv;
127128

128-
let delta_bytes: [u8; DEFAULT_BYTES] = delta.to_affine().to_bytes()[..DEFAULT_BYTES]
129-
.try_into()
130-
.expect("Slice length mismatch");
131-
delta_bytes
129+
delta.to_encoded_point(false)
130+
}
131+
}
132+
133+
impl ComplianceInstance {
134+
pub fn delta_coordinates(&self) -> ([u8; 32], [u8; 32]) {
135+
let x = (*self.delta.x().unwrap()).into();
136+
let y = (*self.delta.y().unwrap()).into();
137+
(x, y)
138+
}
139+
140+
pub fn delta_projective(&self) -> ProjectivePoint {
141+
ProjectivePoint::from_encoded_point(&self.delta).unwrap()
132142
}
133143
}

0 commit comments

Comments
 (0)