Skip to content

Commit

Permalink
outputs hex string for proof generation key in napi bindings (#4564)
Browse files Browse the repository at this point in the history
  • Loading branch information
jowparks authored Jan 19, 2024
1 parent 8583028 commit b879e8b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
9 changes: 9 additions & 0 deletions ironfish-rust-nodejs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

/* auto-generated by NAPI-RS */

export interface RoundOneSigningData {
nonceHiding: string
nonceBinding: string
commitmentHiding: string
commitmentBinding: string
}
export function roundOne(keyPackage: string, seed: number): RoundOneSigningData
export function contribute(inputPath: string, outputPath: string, seed?: string | undefined | null): Promise<string>
export function verifyTransform(paramsPath: string, newParamsPath: string): Promise<string>
export const KEY_LENGTH: number
Expand Down Expand Up @@ -75,6 +82,7 @@ export interface Key {
incomingViewKey: string
outgoingViewKey: string
publicAddress: string
proofGenerationKey: string
}
export function generateKey(): Key
export function spendingKeyToWords(privateKey: string, languageCode: LanguageCode): string
Expand Down Expand Up @@ -215,6 +223,7 @@ export class Transaction {
* aka: self.value_balance - intended_transaction_fee - change = 0
*/
post(spenderHexKey: string, changeGoesTo: string | undefined | null, intendedTransactionFee: bigint): Buffer
build(proofGenerationKeyStr: string, viewKeyStr: string, outgoingViewKeyStr: string, publicAddressStr: string, intendedTransactionFee: bigint): Buffer
setExpiration(sequence: number): void
}
export class FoundBlockResult {
Expand Down
3 changes: 2 additions & 1 deletion ironfish-rust-nodejs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,10 @@ if (!nativeBinding) {
throw new Error(`Failed to load native binding`)
}

const { FishHashContext, contribute, verifyTransform, KEY_LENGTH, NONCE_LENGTH, BoxKeyPair, randomBytes, boxMessage, unboxMessage, RollingFilter, initSignalHandler, triggerSegfault, ASSET_ID_LENGTH, ASSET_METADATA_LENGTH, ASSET_NAME_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, PROOF_LENGTH, TRANSACTION_SIGNATURE_LENGTH, TRANSACTION_PUBLIC_KEY_RANDOMNESS_LENGTH, TRANSACTION_EXPIRATION_LENGTH, TRANSACTION_FEE_LENGTH, LATEST_TRANSACTION_VERSION, TransactionPosted, Transaction, verifyTransactions, LanguageCode, generateKey, spendingKeyToWords, wordsToSpendingKey, generateKeyFromPrivateKey, initializeSapling, FoundBlockResult, ThreadPoolHandler, isValidPublicAddress } = nativeBinding
const { FishHashContext, roundOne, contribute, verifyTransform, KEY_LENGTH, NONCE_LENGTH, BoxKeyPair, randomBytes, boxMessage, unboxMessage, RollingFilter, initSignalHandler, triggerSegfault, ASSET_ID_LENGTH, ASSET_METADATA_LENGTH, ASSET_NAME_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, PROOF_LENGTH, TRANSACTION_SIGNATURE_LENGTH, TRANSACTION_PUBLIC_KEY_RANDOMNESS_LENGTH, TRANSACTION_EXPIRATION_LENGTH, TRANSACTION_FEE_LENGTH, LATEST_TRANSACTION_VERSION, TransactionPosted, Transaction, verifyTransactions, LanguageCode, generateKey, spendingKeyToWords, wordsToSpendingKey, generateKeyFromPrivateKey, initializeSapling, FoundBlockResult, ThreadPoolHandler, isValidPublicAddress } = nativeBinding

module.exports.FishHashContext = FishHashContext
module.exports.roundOne = roundOne
module.exports.contribute = contribute
module.exports.verifyTransform = verifyTransform
module.exports.KEY_LENGTH = KEY_LENGTH
Expand Down
5 changes: 5 additions & 0 deletions ironfish-rust-nodejs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
use std::fmt::Display;

use ironfish::keys::Language;
use ironfish::keys::ProofGenerationKeySerializable;
use ironfish::PublicAddress;
use ironfish::SaplingKey;

use napi::bindgen_prelude::*;
use napi_derive::napi;

Expand Down Expand Up @@ -63,6 +65,7 @@ pub struct Key {
pub incoming_view_key: String,
pub outgoing_view_key: String,
pub public_address: String,
pub proof_generation_key: String,
}

#[napi]
Expand All @@ -75,6 +78,7 @@ pub fn generate_key() -> Key {
incoming_view_key: sapling_key.incoming_view_key().hex_key(),
outgoing_view_key: sapling_key.outgoing_view_key().hex_key(),
public_address: sapling_key.public_address().hex_public_address(),
proof_generation_key: sapling_key.sapling_proof_generation_key().hex_key(),
}
}

Expand All @@ -101,6 +105,7 @@ pub fn generate_key_from_private_key(private_key: String) -> Result<Key> {
incoming_view_key: sapling_key.incoming_view_key().hex_key(),
outgoing_view_key: sapling_key.outgoing_view_key().hex_key(),
public_address: sapling_key.public_address().hex_public_address(),
proof_generation_key: sapling_key.sapling_proof_generation_key().hex_key(),
})
}

Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust/src/keys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl SaplingKey {

/// Adapter to convert this key to a proof generation key for use in
/// sapling functions
pub(crate) fn sapling_proof_generation_key(&self) -> ProofGenerationKey {
pub fn sapling_proof_generation_key(&self) -> ProofGenerationKey {
ProofGenerationKey {
ak: self.view_key.authorizing_key,
nsk: self.proof_authorizing_key,
Expand Down

0 comments on commit b879e8b

Please sign in to comment.