goas: factor out common zone config to executor lib
This commit is contained in:
parent
72e198eeb5
commit
7a7bea3931
|
@ -1,6 +1,24 @@
|
||||||
use common::{BoundTx, StateWitness};
|
use common::{BoundTx, StateWitness, ZoneMetadata};
|
||||||
use goas_proof_statements::{zone_funds::SpendFundsPrivate, zone_state::ZoneStatePrivate};
|
use goas_proof_statements::{zone_funds::SpendFundsPrivate, zone_state::ZoneStatePrivate};
|
||||||
|
|
||||||
|
pub fn zone_state_death_constraint() -> [u8; 32] {
|
||||||
|
ledger::death_constraint::risc0_id_to_cl_death_constraint(goas_risc0_proofs::ZONE_STATE_ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn zone_fund_death_constraint() -> [u8; 32] {
|
||||||
|
ledger::death_constraint::risc0_id_to_cl_death_constraint(
|
||||||
|
goas_risc0_proofs::SPEND_ZONE_FUNDS_ID,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn zone_metadata(zone_mnemonic: &str) -> ZoneMetadata {
|
||||||
|
ZoneMetadata {
|
||||||
|
zone_vk: zone_state_death_constraint(),
|
||||||
|
funds_vk: zone_fund_death_constraint(),
|
||||||
|
unit: cl::note::unit_point(zone_mnemonic),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn prove_zone_stf(
|
pub fn prove_zone_stf(
|
||||||
state: StateWitness,
|
state: StateWitness,
|
||||||
inputs: Vec<BoundTx>,
|
inputs: Vec<BoundTx>,
|
||||||
|
|
|
@ -5,16 +5,6 @@ use common::{BoundTx, StateWitness, Tx, ZoneMetadata, ZONE_CL_FUNDS_UNIT};
|
||||||
use ledger::death_constraint::DeathProof;
|
use ledger::death_constraint::DeathProof;
|
||||||
use rand_core::CryptoRngCore;
|
use rand_core::CryptoRngCore;
|
||||||
|
|
||||||
fn zone_state_death_constraint() -> [u8; 32] {
|
|
||||||
ledger::death_constraint::risc0_id_to_cl_death_constraint(goas_risc0_proofs::ZONE_STATE_ID)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn zone_fund_death_constraint() -> [u8; 32] {
|
|
||||||
ledger::death_constraint::risc0_id_to_cl_death_constraint(
|
|
||||||
goas_risc0_proofs::SPEND_ZONE_FUNDS_ID,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn zone_fund_note(value: u64, zone_meta: ZoneMetadata) -> cl::NoteWitness {
|
fn zone_fund_note(value: u64, zone_meta: ZoneMetadata) -> cl::NoteWitness {
|
||||||
cl::NoteWitness {
|
cl::NoteWitness {
|
||||||
value,
|
value,
|
||||||
|
@ -46,11 +36,7 @@ fn test_deposit() {
|
||||||
let init_state = StateWitness {
|
let init_state = StateWitness {
|
||||||
balances: BTreeMap::new(),
|
balances: BTreeMap::new(),
|
||||||
included_txs: vec![],
|
included_txs: vec![],
|
||||||
zone_metadata: ZoneMetadata {
|
zone_metadata: executor::zone_metadata("ZONE"),
|
||||||
zone_vk: zone_state_death_constraint(),
|
|
||||||
funds_vk: zone_fund_death_constraint(),
|
|
||||||
unit: cl::note::unit_point("ZONE_STATE"),
|
|
||||||
},
|
|
||||||
nonce: [0; 32],
|
nonce: [0; 32],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,16 +5,6 @@ use common::{BoundTx, StateWitness, Tx, ZoneMetadata, ZONE_CL_FUNDS_UNIT};
|
||||||
use ledger::death_constraint::DeathProof;
|
use ledger::death_constraint::DeathProof;
|
||||||
use rand_core::CryptoRngCore;
|
use rand_core::CryptoRngCore;
|
||||||
|
|
||||||
fn zone_state_death_constraint() -> [u8; 32] {
|
|
||||||
ledger::death_constraint::risc0_id_to_cl_death_constraint(goas_risc0_proofs::ZONE_STATE_ID)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn zone_fund_death_constraint() -> [u8; 32] {
|
|
||||||
ledger::death_constraint::risc0_id_to_cl_death_constraint(
|
|
||||||
goas_risc0_proofs::SPEND_ZONE_FUNDS_ID,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn zone_fund_utxo(
|
fn zone_fund_utxo(
|
||||||
value: u64,
|
value: u64,
|
||||||
zone_meta: ZoneMetadata,
|
zone_meta: ZoneMetadata,
|
||||||
|
@ -53,11 +43,7 @@ fn test_withdrawal() {
|
||||||
let init_state = StateWitness {
|
let init_state = StateWitness {
|
||||||
balances: BTreeMap::from_iter([(alice, 100)]),
|
balances: BTreeMap::from_iter([(alice, 100)]),
|
||||||
included_txs: vec![],
|
included_txs: vec![],
|
||||||
zone_metadata: ZoneMetadata {
|
zone_metadata: executor::zone_metadata("ZONE"),
|
||||||
zone_vk: zone_state_death_constraint(),
|
|
||||||
funds_vk: zone_fund_death_constraint(),
|
|
||||||
unit: cl::note::unit_point("ZONE_STATE"),
|
|
||||||
},
|
|
||||||
nonce: [0; 32],
|
nonce: [0; 32],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue