Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Idiomatic entry-to-statement conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
ax0 committed Oct 11, 2024
1 parent de7d197 commit 8c7a361
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions src/pod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ pub fn entry_to_statement<V: EntryValue>(entry: &Entry<V>, gadget_id: GadgetID)
}
}

impl<V: EntryValue> Into<Statement> for Entry<V> {
fn into(self) -> Statement {
entry_to_statement(&self, GadgetID::NONE)
}
}

#[derive(Clone, Debug, PartialEq)]
pub struct POD<Payload: HashablePayload, Proof: ProofOf<Payload>, const FromGadgetID: usize> {
pub payload: Payload,
Expand Down Expand Up @@ -653,25 +659,13 @@ fn op_test() -> Result<(), Error> {
let entry5 = Entry::new("yet another scalar1", scalar1);
let entry6 = Entry::new("scalar3", scalar3);

// Create entry statements. Unwrapped for convenience.
let entry_statement1 = Operation::NewEntry
.apply_operation(GadgetID::GOD, None, None, None, Some(&entry1))
.unwrap();
let entry_statement2 = Operation::NewEntry
.apply_operation(GadgetID::GOD, None, None, None, Some(&entry2))
.unwrap();
let entry_statement3 = Operation::NewEntry
.apply_operation(GadgetID::GOD, None, None, None, Some(&entry3))
.unwrap();
let entry_statement4 = Operation::NewEntry
.apply_operation(GadgetID::GOD, None, None, None, Some(&entry4))
.unwrap();
let entry_statement5 = Operation::NewEntry
.apply_operation(GadgetID::GOD, None, None, None, Some(&entry5))
.unwrap();
let entry_statement6 = Operation::NewEntry
.apply_operation(GadgetID::GOD, None, None, None, Some(&entry6))
.unwrap();
// Create entry statements.
let entry_statement1 = entry1.into();
let entry_statement2 = entry2.into();
let entry_statement3 = entry3.into();
let entry_statement4 = entry4.into();
let entry_statement5 = entry5.into();
let entry_statement6 = entry6.into();

// Entry 2's value = entry 1's value + entry 6's value
let sum_of_statement = Operation::SumOf
Expand Down

0 comments on commit 8c7a361

Please sign in to comment.