Skip to content

PublicKey: missing fromBytes functionΒ #52

@NicolasDP

Description

@NicolasDP

js-chain-libs/src/lib.rs

Lines 91 to 106 in 038d715

impl PublicKey {
/// Get private key from its bech32 representation
/// Example:
/// ```javascript
/// const pkey = PublicKey.from_bech32('ed25519_pk1dgaagyh470y66p899txcl3r0jaeaxu6yd7z2dxyk55qcycdml8gszkxze2');
/// ```
pub fn from_bech32(bech32_str: &str) -> Result<PublicKey, JsValue> {
crypto::PublicKey::try_from_bech32_str(&bech32_str)
.map(PublicKey)
.map_err(|_| JsValue::from_str("Malformed public key"))
}
pub fn as_bytes(&self) -> Vec<u8> {
self.0.as_ref().to_vec()
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions