Skip to content

Commit 2e2bab0

Browse files
committed
replace SELF out of circuit
1 parent 7df2d47 commit 2e2bab0

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

src/backends/plonky2/basetypes.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
//! is enabled.
33
//! See src/middleware/basetypes.rs for more details.
44
5+
/// F is the native field we use everywhere. Currently it's Goldilocks from plonky2
6+
pub use plonky2::field::goldilocks_field::GoldilocksField as F;
57
use plonky2::{
6-
field::{extension::quadratic::QuadraticExtension, goldilocks_field::GoldilocksField},
8+
field::extension::quadratic::QuadraticExtension,
79
hash::{hash_types, poseidon::PoseidonHash},
810
plonk::{circuit_builder, circuit_data, config::GenericConfig, proof},
911
};
1012
use schemars::JsonSchema;
1113
use serde::{Deserialize, Deserializer, Serialize};
1214

13-
/// F is the native field we use everywhere. Currently it's Goldilocks from plonky2
14-
pub type F = GoldilocksField;
15-
1615
/// D defines the extension degree of the field used in the Plonky2 proofs (quadratic extension).
1716
pub const D: usize = 2;
1817

src/middleware/basetypes.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ use std::{
3333

3434
use hex::{FromHex, FromHexError, ToHex};
3535
use plonky2::{
36-
field::{
37-
goldilocks_field::GoldilocksField,
38-
types::{Field, PrimeField64},
39-
},
36+
field::types::{Field, PrimeField64},
4037
hash::poseidon::PoseidonHash,
4138
plonk::config::Hasher,
4239
};
@@ -58,12 +55,7 @@ pub const HASH_SIZE: usize = 4;
5855
pub const VALUE_SIZE: usize = 4;
5956

6057
pub const EMPTY_VALUE: RawValue = RawValue([F::ZERO, F::ZERO, F::ZERO, F::ZERO]);
61-
pub const SELF_ID_HASH: Hash = Hash([
62-
GoldilocksField(0x5),
63-
GoldilocksField(0xe),
64-
GoldilocksField(0x1),
65-
GoldilocksField(0xf),
66-
]);
58+
pub const SELF_ID_HASH: Hash = Hash([F(0x5), F(0xe), F(0x1), F(0xf)]);
6759
pub const EMPTY_HASH: Hash = Hash([F::ZERO, F::ZERO, F::ZERO, F::ZERO]);
6860

6961
#[derive(Clone, Copy, Debug, Default, Hash, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]

src/middleware/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ impl Params {
766766
}
767767
}
768768

769-
/// Replace references to SELF by `self_id` in anchored keys of the statement.
769+
/// Replace references to SELF by `self_id`.
770770
pub fn normalize_statement(statement: &Statement, self_id: PodId) -> Statement {
771771
let predicate = statement.predicate();
772772
let args = statement
@@ -776,6 +776,9 @@ pub fn normalize_statement(statement: &Statement, self_id: PodId) -> Statement {
776776
StatementArg::Key(AnchoredKey { pod_id, key }) if *pod_id == SELF => {
777777
StatementArg::Key(AnchoredKey::new(self_id, key.clone()))
778778
}
779+
StatementArg::Literal(value) if value.raw.0 == SELF.0 .0 => {
780+
StatementArg::Literal(self_id.into())
781+
}
779782
_ => sa.clone(),
780783
})
781784
.collect();

0 commit comments

Comments
 (0)