Struct cardano_serialization_lib::crypto::Vkey
source · pub struct Vkey(_);
Implementations§
source§impl Vkey
impl Vkey
pub fn from_bytes(bytes: Vec<u8>) -> Result<Vkey, DeserializeError>
source§impl Vkey
impl Vkey
sourcepub fn new(pk: &PublicKey) -> Self
pub fn new(pk: &PublicKey) -> Self
Examples found in repository?
More examples
src/utils.rs (line 1192)
1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219
pub fn make_daedalus_bootstrap_witness(
tx_body_hash: &TransactionHash,
addr: &ByronAddress,
key: &LegacyDaedalusPrivateKey,
) -> BootstrapWitness {
let chain_code = key.chaincode();
let pubkey = Bip32PublicKey::from_bytes(&key.0.to_public().as_ref()).unwrap();
let vkey = Vkey::new(&pubkey.to_raw_key());
let signature =
Ed25519Signature::from_bytes(key.0.sign(&tx_body_hash.to_bytes()).as_ref().to_vec())
.unwrap();
BootstrapWitness::new(&vkey, &signature, chain_code, addr.attributes())
}
#[wasm_bindgen]
pub fn make_icarus_bootstrap_witness(
tx_body_hash: &TransactionHash,
addr: &ByronAddress,
key: &Bip32PrivateKey,
) -> BootstrapWitness {
let chain_code = key.chaincode();
let raw_key = key.to_raw_key();
let vkey = Vkey::new(&raw_key.to_public());
let signature = raw_key.sign(&tx_body_hash.to_bytes());
BootstrapWitness::new(&vkey, &signature, chain_code, addr.attributes())
}
#[wasm_bindgen]
pub fn make_vkey_witness(tx_body_hash: &TransactionHash, sk: &PrivateKey) -> Vkeywitness {
let sig = sk.sign(tx_body_hash.0.as_ref());
Vkeywitness::new(&Vkey::new(&sk.to_public()), &sig)
}
src/tx_builder/batch_tools/witnesses_calculator.rs (line 94)
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
pub(super) fn create_mock_witnesses_set(&self) -> TransactionWitnessSet {
let fake_key_root = fake_private_key();
let raw_key_public = fake_raw_key_public();
let fake_sig = fake_raw_key_sig();
// recall: this includes keys for input, certs and withdrawals
let vkeys = match self.vkeys_count {
0 => None,
x => {
let fake_vkey_witness = Vkeywitness::new(&Vkey::new(&raw_key_public), &fake_sig);
let mut result = Vkeywitnesses::new();
for _i in 0..x {
result.add(&fake_vkey_witness.clone());
}
Some(result)
}
};
let bootstrap_keys = match self.boostrap_count {
0 => None,
_x => {
let mut result = BootstrapWitnesses::new();
for boostrap_address in &self.bootsraps {
// picking icarus over daedalus for fake witness generation shouldn't matter
result.add(&make_icarus_bootstrap_witness(
&TransactionHash::from([0u8; TransactionHash::BYTE_COUNT]),
boostrap_address,
&fake_key_root,
));
}
Some(result)
}
};
TransactionWitnessSet {
vkeys,
native_scripts: None,
bootstraps: bootstrap_keys,
plutus_scripts: None,
plutus_data: None,
redeemers: None,
}
}
src/tx_builder.rs (line 107)
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
fn fake_full_tx(
tx_builder: &TransactionBuilder,
body: TransactionBody,
) -> Result<Transaction, JsError> {
let fake_key_root = fake_private_key();
let raw_key_public = fake_raw_key_public();
let fake_sig = fake_raw_key_sig();
// recall: this includes keys for input, certs and withdrawals
let vkeys = match count_needed_vkeys(tx_builder) {
0 => None,
x => {
let fake_vkey_witness = Vkeywitness::new(&Vkey::new(&raw_key_public), &fake_sig);
let mut result = Vkeywitnesses::new();
for _i in 0..x {
result.add(&fake_vkey_witness.clone());
}
Some(result)
}
};
let bootstraps = get_bootstraps(&tx_builder.inputs);
let bootstrap_keys = match bootstraps.len() {
0 => None,
_x => {
let mut result = BootstrapWitnesses::new();
for addr in bootstraps {
// picking icarus over daedalus for fake witness generation shouldn't matter
result.add(&make_icarus_bootstrap_witness(
&TransactionHash::from([0u8; TransactionHash::BYTE_COUNT]),
&ByronAddress::from_bytes(addr.clone()).unwrap(),
&fake_key_root,
));
}
Some(result)
}
};
let (plutus_scripts, plutus_data, redeemers) = {
if let Some(s) = tx_builder.get_combined_plutus_scripts() {
let (s, d, r) = s.collect();
(Some(s), d, Some(r))
} else {
(None, None, None)
}
};
let witness_set = TransactionWitnessSet {
vkeys,
native_scripts: tx_builder.get_combined_native_scripts(),
bootstraps: bootstrap_keys,
plutus_scripts,
plutus_data,
redeemers,
};
Ok(Transaction {
body,
witness_set,
is_valid: true,
auxiliary_data: tx_builder.auxiliary_data.clone(),
})
}
pub fn public_key(&self) -> PublicKey
Trait Implementations§
source§impl<'de> Deserialize<'de> for Vkey
impl<'de> Deserialize<'de> for Vkey
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Deserialize for Vkey
impl Deserialize for Vkey
fn deserialize<R: BufRead + Seek>(
raw: &mut Deserializer<R>
) -> Result<Self, DeserializeError>
source§impl JsonSchema for Vkey
impl JsonSchema for Vkey
source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read more