Commit Graph

241 Commits

Author SHA1 Message Date
CalDescent
9eeaf4f026 Remove public key from script sig, since it is already pushed to the stack in the redeem script. 2022-05-19 19:55:08 +01:00
CalDescent
1ce584f986 Use 0x51 (OP_TRUE) instead of 0x01 to denote that it is a refund 2022-05-19 19:19:47 +01:00
CalDescent
f48cdf9484 Declare is_refund as an array, for easier compatibility with existing Script setters. 2022-05-18 23:04:13 +01:00
CalDescent
01f0bacf79 Started modifying scriptSig to be compatible with atomicdex-style HTLCs. This removes support for P2PKH inputs, but Pirate doesn't support these anyway. 2022-05-18 22:51:45 +01:00
CalDescent
dda640b336 Made txin mutable 2022-05-18 19:29:18 +01:00
CalDescent
10c3389f17 Fixed bug with sequence 2022-05-18 19:25:36 +01:00
CalDescent
9768e4af78 Allow lock time to be optionally set when adding a transparent input. 2022-05-18 19:14:01 +01:00
CalDescent
1a8686863b Removed validation, since pubkey won't match address for P2SH 2022-05-17 18:53:04 +01:00
CalDescent
5a4fd01f35 Added redeem_script parameter 2022-05-15 12:38:53 +01:00
CalDescent
a2e12ea51e Attempt to redeem P2SH with secret. This is highly experimental.
Based on Qortal standard HTLCs. Will need adapting to Pirate specific ones at the very least.
2022-05-15 12:15:16 +01:00
CalDescent
3bc31b9cce Removed unnecessary 'to' parameter in add_transparent_output_with_script_pubkey(), and swapped the order of 'value' and 'script_pubkey'. 2022-05-15 11:17:06 +01:00
CalDescent
d5fa83313a Removed duplicate import 2022-05-13 15:43:51 +01:00
CalDescent
ec3828b108 Added add_transparent_output_with_script_pubkey() 2022-05-13 15:34:39 +01:00
CalDescent
6d28a22509 Updated zcash_primitives dependencies 2022-04-26 09:51:11 +01:00
Cryptoforge
2981c4d286 use u32 instead of consesus::BranchID for transaction building. Enables multichain useage. 2020-10-12 15:01:31 -07:00
Cryptoforge
0883d7f3fc add set_fee to tx builder 2020-07-30 21:37:54 -07:00
Cryptoforge
1ce4e97632 use zero consensus ids 2020-07-12 22:31:27 -07:00
Aditya Kulkarni
a0384d4fac Update master 2020-05-16 21:44:34 -07:00
Jack Grigg
c597db59a6 ff: Rename PrimeField::into_repr -> PrimeField::to_repr 2020-05-02 18:55:13 +12:00
Jack Grigg
15e229509a ff: Move pow_vartime back into Field trait
The only places we don't use constant u64 limbs, we use PrimeField::char
instead (except in a single test where we use a field element).
2020-05-02 18:54:02 +12:00
Jack Grigg
fb31d09218 ff: Remove Ord bound from PrimeField
ff_derive still implements Ord and PartialOrd for the fields it
implements, because pairing::bls12_381 internally assumes that those are
implemented. Once we delete that implementation, we will remove the Ord
and PartialOrd implementations from ff_derive.
2020-05-02 18:54:02 +12:00
Jack Grigg
38f87c2e73 ff: Add PrimeField::ReprEndianness associated type
This enables generic code to reliably operate on the bits of an encoded
field element, by converting them to and from a known (little)
endianness.

The BitAnd and Shr bounds on PrimeField are now removed, as users can
perform these operations themselves as needed.
2020-05-02 18:54:02 +12:00
Jack Grigg
55568b4d6e ff: Remove frobenius_map from Field trait
It is only used internally in the bls12_381 crate, and field extensions
aren't exposed anywhere in the Zcash stack.
2020-05-02 16:07:48 +12:00
Jack Grigg
1761ebfb35 ff: Remove SqrtField trait
The sqrt() function is now part of the Field trait. ff_derive returns an
error on fields for which it does not support generating a square root
function.

Note that Fq6 and Fq12 in pairing::bls12_381 leave the function
unimplemented. They will be dropped once the migration to the bls12_381
crate is complete. The equivalent structs in that crate are not exposed.
2020-05-02 16:07:48 +12:00
str4d
b02cf3b467
Merge pull request #223 from str4d/remove-primefieldrepr
Remove ff::PrimeFieldRepr
2020-05-01 08:59:41 +12:00
Jack Grigg
49f119fb03 ff: Remove PrimeFieldRepr trait
The ff::PrimeField::Repr associated type now has the minimal necessary
bounds, which can be satisfied by a newtype around a byte array.
2020-04-23 18:15:14 +12:00
Jack Grigg
1fe3e3784c ff: Add Ord bound to PrimeField 2020-04-23 17:31:33 +12:00
Jack Grigg
1a40cfd39c zcash_primitives: Make jubjub::Fs::invert constant time 2020-04-23 16:23:24 +12:00
Jack Grigg
08500ee712 ff: PrimeField: BitAnd<u64, Output = u64> + Shr<u32, Output = Self> 2020-04-23 16:23:24 +12:00
Jack Grigg
1fdca393bb ff: PrimeField::{is_even, is_odd} 2020-04-23 16:23:24 +12:00
Jack Grigg
232f0a50b8 ff: Rework BitIterator to work with both u8 and u64 limb sizes
This enables BitIterator to be used with both the byte encoding and limb
representation of scalars.
2020-04-23 16:23:24 +12:00
Jack Grigg
fd79de5408 ff: Add PrimeField: From<u64> constraint 2020-04-23 16:23:24 +12:00
Aditya Kulkarni
3ccadf3017 Add binding signature only if needed 2020-04-04 10:29:30 -07:00
Aditya Kulkarni
7dba253ad5 partial test 2020-04-04 10:27:51 -07:00
Aditya Kulkarni
98f9bda329 Add binding signature only if needed 2020-04-04 08:21:06 -07:00
Jack Grigg
b6457a905b ff: Move pow_vartime into a trait that is generic over the limb size
The trait is implemented by default for u8 and u64, allowing pow_vartime
to be used with both the byte encoding and limb representation of field
elements.
2020-03-28 00:27:59 +13:00
Jack Grigg
2df2a2b2f2 Merge branch 'develop' 2020-03-14 10:36:58 +13:00
Sean Bowe
100878cd14
Version bump of all crates (except librustzcash) 2020-03-12 15:59:19 -06:00
Sean Bowe
b52e4aac3a
Fix Field::random method declarations. 2020-03-03 17:47:29 -07:00
Jack Grigg
2d30c29d06 Pass &impl TxProver to Builder::build
This allows the caller to build multiple transactions with a single
proving backend.
2020-02-08 00:37:31 +00:00
Jack Grigg
76e0f658c1 Rename CommitmentTreeWitness -> MerklePath 2020-02-08 00:36:40 +00:00
Jack Grigg
3a3008caf9 Pass CommitmentTreeWitness directly into Builder::add_sapling_spend
This is more likely to be the data that the caller has available, and
is all we need now that a CommitmentTreeWitness can compute its root.
2020-02-07 17:31:38 +00:00
Jack Grigg
8a210ec271 CommitmentTreeWitness::root(leaf) 2020-02-07 17:21:59 +00:00
Jack Grigg
2064d1c801 Refactor zcash_primitives::merkle_tree::CommitmentTreeWitness
- The internal Option wrapper was an unnecessary leftover from when this
  code was directly inside the prover, where Some(x) represents an
  assigned variable.
- CommitmentTreeWitness::from_slice_with_depth is more idiomatic Rust.
2020-02-07 00:06:57 +00:00
François Garillot
865275e2a2
Correcting some trivial Rust option/iterator warts 2020-01-29 13:53:05 -08:00
Jack Grigg
00499b3441
Migrate zcash_primitives benchmarks to criterion 2019-12-19 16:11:11 -06:00
Jack Grigg
ec2c304efd
no_std support for ff crate 2019-12-14 12:55:34 +00:00
Jack Grigg
1c9f5742fa
Improve Field::pow API and impl
Renamed to Field::pow_vartime to indicate it is still variable time with
respect to the exponent.
2019-12-14 12:27:48 +00:00
Jack Grigg
3d2acf48ce
Constant-time field square root
WARNING: THIS IS NOT FULLY CONSTANT TIME YET!

This will be fixed once we migrate to the jubjub and bls12_381 crates.
2019-12-13 20:13:30 +00:00
Jack Grigg
40749da9a7
Constant-time field inversion
WARNING: THIS IS NOT ACTUALLY CONSTANT TIME YET!

The jubjub and bls12_381 crates will replace our constant-time usages,
but we NEED to fix ff_derive because other users will expect it to
implement the Field trait correctly.
2019-12-13 19:46:04 +00:00