Skip to content

Commit

Permalink
Connected the new API, but fails
Browse files Browse the repository at this point in the history
  • Loading branch information
sellout committed Oct 21, 2024
1 parent 3d71aef commit 336d0fe
Show file tree
Hide file tree
Showing 10 changed files with 494 additions and 95 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ include = [
"/README.md",
"build.rs",
"src/*.rs",
"src/*/*.rs",
"/depend/check_uint128_t.c",
"/depend/zcash/src/amount.cpp",
"/depend/zcash/src/amount.h",
Expand Down Expand Up @@ -62,6 +63,7 @@ rust-interpreter = []

[dependencies]
bitflags = "2.5"
log = "0.4"

[build-dependencies]
# The `bindgen` dependency should automatically upgrade to match the version used by zebra-state's `rocksdb` dependency in:
Expand Down
4 changes: 4 additions & 0 deletions src/external/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//! Modules that we use from Zcash, but that are outside the script directory.

pub mod pubkey;
pub mod uint256;
23 changes: 23 additions & 0 deletions src/external/pubkey.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use super::uint256::*;

/// FIXME: `PUBLIC_KEY_SIZE` is meant to be an upper bound, it seems. Maybe parameterize the type
/// over the size.
pub struct PubKey<'a>(pub &'a [u8]);

impl PubKey<'_> {
pub const PUBLIC_KEY_SIZE: usize = 65;
pub const COMPRESSED_PUBLIC_KEY_SIZE: usize = 33;

/// Check syntactic correctness.
///
/// Note that this is consensus critical as CheckSig() calls it!
pub fn is_valid(&self) -> bool {
self.0.len() > 0
}

/// Verify a DER signature (~72 bytes).
/// If this public key is not fully valid, the return value will be false.
pub fn verify(&self, hash: &UInt256, vch_sig: &[u8]) -> bool {
todo!()
}
}
2 changes: 2 additions & 0 deletions src/external/uint256.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// FIXME: This probably needs to be an actually separate type somewhere.
pub type UInt256 = [u8; 32];
Loading

0 comments on commit 336d0fe

Please sign in to comment.