Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benches/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn criterion_benchmark<FL: OrchardFlavorBench>(c: &mut Criterion) {
)
.unwrap();
}
let bundle: Bundle<_, i64, FL> = builder.build(rng).unwrap().unwrap().0;
let bundle: Bundle<_, i64, FL> = builder.build(rng).unwrap().0;

let instances: Vec<_> = bundle
.actions()
Expand Down
2 changes: 1 addition & 1 deletion benches/note_decryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn bench_note_decryption<FL: OrchardFlavorBench>(c: &mut Criterion) {
None,
)
.unwrap();
let bundle: Bundle<_, i64, FL> = builder.build(rng).unwrap().unwrap().0;
let bundle: Bundle<_, i64, FL> = builder.build(rng).unwrap().0;
bundle
.create_proof(&pk, rng)
.unwrap()
Expand Down
41 changes: 19 additions & 22 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ impl Builder {
pub fn build<V: TryFrom<i64>, FL: OrchardFlavor>(
self,
rng: impl RngCore,
) -> Result<Option<UnauthorizedBundleWithMetadata<V, FL>>, BuildError> {
) -> Result<UnauthorizedBundleWithMetadata<V, FL>, BuildError> {
bundle(
rng,
self.anchor,
Expand Down Expand Up @@ -745,7 +745,7 @@ pub fn bundle<V: TryFrom<i64>, FL: OrchardFlavor>(
spends: Vec<SpendInfo>,
outputs: Vec<OutputInfo>,
burn: HashMap<AssetBase, NoteValue>,
) -> Result<Option<UnauthorizedBundleWithMetadata<V, FL>>, BuildError> {
) -> Result<UnauthorizedBundleWithMetadata<V, FL>, BuildError> {
let flags = bundle_type.flags();

let num_requested_spends = spends.len();
Expand Down Expand Up @@ -884,25 +884,24 @@ pub fn bundle<V: TryFrom<i64>, FL: OrchardFlavor>(
let bvk = derive_bvk(&actions, native_value_balance, burn.iter().cloned());
assert_eq!(redpallas::VerificationKey::from(&bsk), bvk);

Ok(NonEmpty::from_vec(actions).map(|actions| {
(
Bundle::from_parts(
actions,
flags,
result_value_balance,
burn,
anchor,
InProgress {
proof: Unproven {
witnesses,
circuit_flavor: FL::FLAVOR,
},
sigs: Unauthorized { bsk },
Ok((
Bundle::from_parts(
// `actions` is never empty. It contains at least MIN_ACTIONS=2 actions.
NonEmpty::from_vec(actions).unwrap(),
flags,
result_value_balance,
burn,
anchor,
InProgress {
proof: Unproven {
witnesses,
circuit_flavor: FL::FLAVOR,
},
),
bundle_meta,
)
}))
sigs: Unauthorized { bsk },
},
),
bundle_meta,
))
}

/// Marker trait representing bundle signatures in the process of being created.
Expand Down Expand Up @@ -1302,7 +1301,6 @@ pub mod testing {
builder
.build(&mut self.rng)
.unwrap()
.unwrap()
.0
.create_proof(&pk, &mut self.rng)
.unwrap()
Expand Down Expand Up @@ -1434,7 +1432,6 @@ mod tests {
let bundle: Bundle<Authorized, i64, FL> = builder
.build(&mut rng)
.unwrap()
.unwrap()
.0
.create_proof(&pk, &mut rng)
.unwrap()
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/commitments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ mod tests {
)
.unwrap();

builder.build::<i64, FL>(rng).unwrap().unwrap().0
builder.build::<i64, FL>(rng).unwrap().0
}

/// Verify that the hash for an Orchard Vanilla bundle matches a fixed reference value
Expand Down
4 changes: 2 additions & 2 deletions tests/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn bundle_chain<FL: BundleOrchardFlavor>() {
builder.add_output(None, recipient, note_value, AssetBase::native(), None),
Ok(())
);
let (unauthorized, bundle_meta) = builder.build(&mut rng).unwrap().unwrap();
let (unauthorized, bundle_meta) = builder.build(&mut rng).unwrap();

assert_eq!(
unauthorized
Expand Down Expand Up @@ -163,7 +163,7 @@ fn bundle_chain<FL: BundleOrchardFlavor>() {
),
Ok(())
);
let (unauthorized, _) = builder.build(&mut rng).unwrap().unwrap();
let (unauthorized, _) = builder.build(&mut rng).unwrap();
let sighash = unauthorized.commitment().into();
let proven = unauthorized.create_proof(&pk, &mut rng).unwrap();
proven
Expand Down
4 changes: 2 additions & 2 deletions tests/zsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fn build_and_sign_bundle(
pk: &ProvingKey,
sk: &SpendingKey,
) -> Bundle<Authorized, i64, OrchardZSA> {
let unauthorized = builder.build(&mut rng).unwrap().unwrap().0;
let unauthorized = builder.build(&mut rng).unwrap().0;
let sighash = unauthorized.commitment().into();
let proven = unauthorized.create_proof(pk, &mut rng).unwrap();
proven
Expand Down Expand Up @@ -205,7 +205,7 @@ fn create_native_note(keys: &Keychain) -> Note {
),
Ok(())
);
let unauthorized = builder.build(&mut rng).unwrap().unwrap().0;
let unauthorized = builder.build(&mut rng).unwrap().0;
let sighash = unauthorized.commitment().into();
let proven = unauthorized.create_proof(keys.pk(), &mut rng).unwrap();
proven.apply_signatures(rng, sighash, &[]).unwrap()
Expand Down