Skip to content

Commit

Permalink
Merge pull request #3785 from iron-fish/staging
Browse files Browse the repository at this point in the history
STAGING -> MASTER
  • Loading branch information
danield9tqh authored Apr 13, 2023
2 parents 5f68460 + b71f91a commit 6e6508d
Show file tree
Hide file tree
Showing 126 changed files with 11,067 additions and 10,293 deletions.
6 changes: 3 additions & 3 deletions ironfish-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ironfish",
"version": "0.1.75",
"version": "0.1.76",
"description": "CLI for running and interacting with an Iron Fish node",
"author": "Iron Fish <[email protected]> (https://ironfish.network)",
"main": "build/src/index.js",
Expand Down Expand Up @@ -60,8 +60,8 @@
"@aws-sdk/client-s3": "3.127.0",
"@aws-sdk/client-secrets-manager": "3.276.0",
"@aws-sdk/s3-request-presigner": "3.127.0",
"@ironfish/rust-nodejs": "0.1.30",
"@ironfish/sdk": "0.0.52",
"@ironfish/rust-nodejs": "0.1.31",
"@ironfish/sdk": "0.0.53",
"@oclif/core": "1.23.1",
"@oclif/plugin-help": "5.1.12",
"@oclif/plugin-not-found": "2.3.1",
Expand Down
8 changes: 4 additions & 4 deletions ironfish-mpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ The results of Drand's round 2,863,343 will be listed below
From: https://api.drand.sh/8990e7a9aaed2ffed73dbd7092123d6f289930540d7651336225dc172e51b2ce/public/2863343
```json
{
"round":2863343,
"randomness":"..",
"signature":"..",
"previous_signature":".."
"round": 2863343,
"randomness": "32e360d600ece16bc0c4248eb5f3a355b4af5fefe978530480113b522c09d36c",
"signature": "823cfda3099e515022253b76e3a8ee43e0b9989b56d8aaff31d976c0dde6ba2bafc2cbd4c84d6377deef7e8bb21cb53d15af8beb1480b1ec2e541ca4bd08bc1252e7c7922256445a3b32717bb38ec894eee8017ff67218c5dbfa81576e1cf134",
"previous_signature": "a96719eb694b01dcecf6b38bae832ba425774ea35d8359f544937aad0022ca8b5fdc517fbd013f12df9ffe89c60329b5184eb8b8582b316e946ac640f2b0a3ad0c06911c0c891fb948ce9ea398f4c8b1d20195990ccbb51d75810ca7a7ee1e45"
}
```

Expand Down
4 changes: 2 additions & 2 deletions ironfish-mpc/src/bin/beacon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ fn main() {
use rand_chacha::ChaChaRng;

// Place beacon value here. The value will be the randomness generated by The League of Entropy's drand network
// (network chain hash: 8990e7a9aaed2ffed73dbd7092123d6f289930540d7651336225dc172e51b2ce) in round #2759370.
// (network chain hash: 8990e7a9aaed2ffed73dbd7092123d6f289930540d7651336225dc172e51b2ce) in round #2863343.
let beacon_value: [u8; 32] =
decode_hex("80c1cf36d080eb87853569ac5c7cb75357bec1daefb876289fa6c69472228210")
decode_hex("32e360d600ece16bc0c4248eb5f3a355b4af5fefe978530480113b522c09d36c")
.as_slice()
.try_into()
.unwrap();
Expand Down
7 changes: 3 additions & 4 deletions ironfish-mpc/src/bin/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ extern crate pairing;
use std::fs::File;
use std::io::BufWriter;

use ironfish_zkp::constants::ASSET_ID_LENGTH;

fn main() {
let params = File::create("params").unwrap();
let mut params = BufWriter::with_capacity(1024 * 1024, params);
Expand All @@ -16,7 +18,6 @@ fn main() {
ar: None,
auth_path: vec![None; ironfish_zkp::constants::TREE_DEPTH],
anchor: None,
asset_generator: None,
sender_address: None,
})
.unwrap()
Expand All @@ -29,7 +30,7 @@ fn main() {
payment_address: None,
commitment_randomness: None,
esk: None,
asset_generator: None,
asset_id: [0; ASSET_ID_LENGTH],
ar: None,
proof_generation_key: None,
})
Expand All @@ -39,8 +40,6 @@ fn main() {

// Sapling mint circuit
ironfish_phase2::MPCParameters::new(ironfish_zkp::proofs::MintAsset {
name: [0u8; 32],
metadata: [0u8; 77],
proof_generation_key: None,
public_key_randomness: None,
})
Expand Down
6 changes: 2 additions & 4 deletions ironfish-mpc/src/bin/verify.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extern crate pairing;

use blake2::{Blake2b512, Digest};
use ironfish_zkp::constants::ASSET_ID_LENGTH;
use std::fs::File;
use std::io::BufReader;

Expand All @@ -26,7 +27,6 @@ fn main() {
ar: None,
auth_path: vec![None; ironfish_zkp::constants::TREE_DEPTH],
anchor: None,
asset_generator: None,
sender_address: None,
})
.expect("parameters are invalid");
Expand All @@ -37,16 +37,14 @@ fn main() {
payment_address: None,
commitment_randomness: None,
esk: None,
asset_generator: None,
asset_id: [0; ASSET_ID_LENGTH],
ar: None,
proof_generation_key: None,
})
.expect("parameters are invalid");

let sapling_mint_contributions = sapling_mint
.verify(ironfish_zkp::proofs::MintAsset {
name: [0u8; 32],
metadata: [0u8; 77],
proof_generation_key: None,
public_key_randomness: None,
})
Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust-nodejs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export const ENCRYPTED_NOTE_LENGTH: number
export const PUBLIC_ADDRESS_LENGTH: number
export const RANDOMNESS_LENGTH: number
export const MEMO_LENGTH: number
export const GENERATOR_LENGTH: number
export const AMOUNT_VALUE_LENGTH: number
export const DECRYPTED_NOTE_LENGTH: number
export interface NativeSpendDescription {
Expand Down Expand Up @@ -91,6 +90,7 @@ export class Asset {
constructor(ownerPrivateKey: string, name: string, metadata: string)
metadata(): Buffer
name(): Buffer
nonce(): number
owner(): Buffer
static nativeId(): Buffer
id(): Buffer
Expand Down
3 changes: 1 addition & 2 deletions ironfish-rust-nodejs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ if (!nativeBinding) {
throw new Error(`Failed to load native binding`)
}

const { contribute, verifyTransform, KEY_LENGTH, NONCE_LENGTH, BoxKeyPair, randomBytes, boxMessage, unboxMessage, RollingFilter, initSignalHandler, triggerSegfault, ASSET_ID_LENGTH, ASSET_METADATA_LENGTH, ASSET_NAME_LENGTH, ASSET_OWNER_LENGTH, ASSET_LENGTH, Asset, NOTE_ENCRYPTION_KEY_LENGTH, MAC_LENGTH, ENCRYPTED_NOTE_PLAINTEXT_LENGTH, ENCRYPTED_NOTE_LENGTH, NoteEncrypted, PUBLIC_ADDRESS_LENGTH, RANDOMNESS_LENGTH, MEMO_LENGTH, GENERATOR_LENGTH, AMOUNT_VALUE_LENGTH, DECRYPTED_NOTE_LENGTH, Note, TransactionPosted, PROOF_LENGTH, TRANSACTION_SIGNATURE_LENGTH, TRANSACTION_PUBLIC_KEY_RANDOMNESS_LENGTH, TRANSACTION_EXPIRATION_LENGTH, TRANSACTION_FEE_LENGTH, TRANSACTION_VERSION, Transaction, verifyTransactions, LanguageCode, generateKey, spendingKeyToWords, wordsToSpendingKey, generateKeyFromPrivateKey, initializeSapling, FoundBlockResult, ThreadPoolHandler, isValidPublicAddress } = nativeBinding
const { contribute, verifyTransform, KEY_LENGTH, NONCE_LENGTH, BoxKeyPair, randomBytes, boxMessage, unboxMessage, RollingFilter, initSignalHandler, triggerSegfault, ASSET_ID_LENGTH, ASSET_METADATA_LENGTH, ASSET_NAME_LENGTH, ASSET_OWNER_LENGTH, ASSET_LENGTH, Asset, NOTE_ENCRYPTION_KEY_LENGTH, MAC_LENGTH, ENCRYPTED_NOTE_PLAINTEXT_LENGTH, ENCRYPTED_NOTE_LENGTH, NoteEncrypted, PUBLIC_ADDRESS_LENGTH, RANDOMNESS_LENGTH, MEMO_LENGTH, AMOUNT_VALUE_LENGTH, DECRYPTED_NOTE_LENGTH, Note, TransactionPosted, PROOF_LENGTH, TRANSACTION_SIGNATURE_LENGTH, TRANSACTION_PUBLIC_KEY_RANDOMNESS_LENGTH, TRANSACTION_EXPIRATION_LENGTH, TRANSACTION_FEE_LENGTH, TRANSACTION_VERSION, Transaction, verifyTransactions, LanguageCode, generateKey, spendingKeyToWords, wordsToSpendingKey, generateKeyFromPrivateKey, initializeSapling, FoundBlockResult, ThreadPoolHandler, isValidPublicAddress } = nativeBinding

module.exports.contribute = contribute
module.exports.verifyTransform = verifyTransform
Expand All @@ -273,7 +273,6 @@ module.exports.NoteEncrypted = NoteEncrypted
module.exports.PUBLIC_ADDRESS_LENGTH = PUBLIC_ADDRESS_LENGTH
module.exports.RANDOMNESS_LENGTH = RANDOMNESS_LENGTH
module.exports.MEMO_LENGTH = MEMO_LENGTH
module.exports.GENERATOR_LENGTH = GENERATOR_LENGTH
module.exports.AMOUNT_VALUE_LENGTH = AMOUNT_VALUE_LENGTH
module.exports.DECRYPTED_NOTE_LENGTH = DECRYPTED_NOTE_LENGTH
module.exports.Note = Note
Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust-nodejs/npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironfish/rust-nodejs-darwin-arm64",
"version": "0.1.30",
"version": "0.1.31",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust-nodejs/npm/darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironfish/rust-nodejs-darwin-x64",
"version": "0.1.30",
"version": "0.1.31",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust-nodejs/npm/linux-arm64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironfish/rust-nodejs-linux-arm64-gnu",
"version": "0.1.30",
"version": "0.1.31",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust-nodejs/npm/linux-arm64-musl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironfish/rust-nodejs-linux-arm64-musl",
"version": "0.1.30",
"version": "0.1.31",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust-nodejs/npm/linux-x64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironfish/rust-nodejs-linux-x64-gnu",
"version": "0.1.30",
"version": "0.1.31",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust-nodejs/npm/linux-x64-musl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironfish/rust-nodejs-linux-x64-musl",
"version": "0.1.30",
"version": "0.1.31",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust-nodejs/npm/win32-x64-msvc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironfish/rust-nodejs-win32-x64-msvc",
"version": "0.1.30",
"version": "0.1.31",
"os": [
"win32"
],
Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust-nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironfish/rust-nodejs",
"version": "0.1.30",
"version": "0.1.31",
"description": "Node.js bindings for Rust code required by the Iron Fish SDK",
"main": "index.js",
"types": "index.d.ts",
Expand Down
17 changes: 12 additions & 5 deletions ironfish-rust-nodejs/src/structs/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use ironfish_rust::{
assets::asset::{
Asset, ASSET_LENGTH as SERIALIZED_ASSET_LENGTH, ID_LENGTH, METADATA_LENGTH, NAME_LENGTH,
NATIVE_ASSET,
assets::{
asset::{
Asset, ASSET_LENGTH as SERIALIZED_ASSET_LENGTH, ID_LENGTH, METADATA_LENGTH, NAME_LENGTH,
},
asset_identifier::NATIVE_ASSET,
},
keys::PUBLIC_ADDRESS_SIZE,
SaplingKey,
Expand Down Expand Up @@ -60,19 +62,24 @@ impl NativeAsset {
Buffer::from(self.asset.name())
}

#[napi]
pub fn nonce(&self) -> u8 {
self.asset.nonce()
}

#[napi]
pub fn owner(&self) -> Buffer {
Buffer::from(&self.asset.owner()[..])
}

#[napi]
pub fn native_id() -> Buffer {
Buffer::from(&NATIVE_ASSET[..])
Buffer::from(&NATIVE_ASSET.as_bytes()[..])
}

#[napi]
pub fn id(&self) -> Buffer {
Buffer::from(&self.asset.id()[..])
Buffer::from(&self.asset.id().as_bytes()[..])
}

#[napi]
Expand Down
23 changes: 7 additions & 16 deletions ironfish-rust-nodejs/src/structs/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use ironfish_rust::{
assets::asset::{asset_generator_from_id, ID_LENGTH as ASSET_ID_LENGTH},
note::{AMOUNT_VALUE_SIZE, GENERATOR_SIZE, MEMO_SIZE, SCALAR_SIZE},
assets::asset::ID_LENGTH as ASSET_ID_LENGTH,
note::{AMOUNT_VALUE_SIZE, MEMO_SIZE, SCALAR_SIZE},
ViewKey,
};
use napi::{bindgen_prelude::*, JsBuffer};
Expand All @@ -25,23 +25,20 @@ pub const RANDOMNESS_LENGTH: u32 = SCALAR_SIZE as u32;
#[napi]
pub const MEMO_LENGTH: u32 = MEMO_SIZE as u32;

#[napi]
pub const GENERATOR_LENGTH: u32 = GENERATOR_SIZE as u32;

#[napi]
pub const AMOUNT_VALUE_LENGTH: u32 = AMOUNT_VALUE_SIZE as u32;

#[napi]
pub const DECRYPTED_NOTE_LENGTH: u32 = RANDOMNESS_LENGTH
+ MEMO_LENGTH
+ GENERATOR_LENGTH
+ ASSET_ID_LENGTH as u32
+ PUBLIC_ADDRESS_LENGTH
+ AMOUNT_VALUE_LENGTH
+ PUBLIC_ADDRESS_LENGTH;
// 32 randomness
//+ 32 memo
//+ 32 public address
//+ 32 asset generator
//+ 32 asset id
//+ 8 value
//+ 32 sender address
//= 168 bytes
Expand Down Expand Up @@ -70,16 +67,10 @@ impl NativeNote {
let asset_id_vec = buffer.as_ref();
let mut asset_id_bytes = [0; ASSET_ID_LENGTH];
asset_id_bytes.clone_from_slice(&asset_id_vec[0..ASSET_ID_LENGTH]);
let asset_generator = asset_generator_from_id(&asset_id_bytes);
let asset_id = asset_id_bytes.try_into().map_err(to_napi_err)?;

Ok(NativeNote {
note: Note::new(
owner_address,
value_u64,
memo,
asset_generator,
sender_address,
),
note: Note::new(owner_address, value_u64, memo, asset_id, sender_address),
})
}

Expand Down Expand Up @@ -125,7 +116,7 @@ impl NativeNote {
/// Asset identifier associated with this note
#[napi]
pub fn asset_id(&self) -> Buffer {
Buffer::from(&self.note.asset_id()[..])
Buffer::from(&self.note.asset_id().as_bytes()[..])
}

/// Sender of the note
Expand Down
5 changes: 3 additions & 2 deletions ironfish-rust-nodejs/src/structs/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use std::cell::RefCell;
use std::convert::TryInto;

use ironfish_rust::assets::asset::AssetIdentifier;
use ironfish_rust::assets::asset_identifier::AssetIdentifier;
use ironfish_rust::transaction::{
batch_verify_transactions, TRANSACTION_EXPIRATION_SIZE, TRANSACTION_FEE_SIZE,
TRANSACTION_PUBLIC_KEY_SIZE, TRANSACTION_SIGNATURE_SIZE,
Expand Down Expand Up @@ -222,7 +222,8 @@ impl NativeTransaction {
#[napi]
pub fn burn(&mut self, asset_id_js_bytes: JsBuffer, value: BigInt) -> Result<()> {
let asset_id_bytes = asset_id_js_bytes.into_value()?;
let asset_id: AssetIdentifier = asset_id_bytes.as_ref().try_into().map_err(to_napi_err)?;
let asset_id = AssetIdentifier::new(asset_id_bytes.as_ref().try_into().unwrap())
.map_err(to_napi_err)?;
let value_u64 = value.get_u64().1;
self.transaction
.add_burn(asset_id, value_u64)
Expand Down
Loading

0 comments on commit 6e6508d

Please sign in to comment.