diff --git a/crates/chia-bls/src/public_key.rs b/crates/chia-bls/src/public_key.rs index 385fea825..49e8ce373 100644 --- a/crates/chia-bls/src/public_key.rs +++ b/crates/chia-bls/src/public_key.rs @@ -311,25 +311,30 @@ mod pybindings { const SIZE: usize = 48; #[new] - pub fn init() -> Self { + fn init() -> Self { Self::default() } #[staticmethod] #[pyo3(name = "generator")] - pub fn py_generator() -> Self { + fn py_generator() -> Self { Self::generator() } - pub fn pair(&self, other: &Signature) -> GTElement { + fn pair(&self, other: &Signature) -> GTElement { other.pair(self) } #[pyo3(name = "get_fingerprint")] - pub fn py_get_fingerprint(&self) -> u32 { + fn py_get_fingerprint(&self) -> u32 { self.get_fingerprint() } + #[pyo3(name = "derive_unhardened")] + fn py_derive_unhardened(&self, idx: u32) -> Self { + self.derive_unhardened(idx) + } + fn __str__(&self) -> String { hex::encode(self.to_bytes()) } diff --git a/crates/chia-bls/src/secret_key.rs b/crates/chia-bls/src/secret_key.rs index 2ff34d3f4..b221a00a9 100644 --- a/crates/chia-bls/src/secret_key.rs +++ b/crates/chia-bls/src/secret_key.rs @@ -250,17 +250,32 @@ mod pybindings { #[classattr] const PRIVATE_KEY_SIZE: usize = 32; - pub fn sign_g2(&self, msg: &[u8]) -> Signature { + fn sign_g2(&self, msg: &[u8]) -> Signature { crate::sign(self, msg) } - pub fn get_g1(&self) -> PublicKey { + fn get_g1(&self) -> PublicKey { + self.public_key() + } + + #[pyo3(name = "public_key")] + fn py_public_key(&self) -> PublicKey { self.public_key() } fn __str__(&self) -> String { hex::encode(self.to_bytes()) } + + #[pyo3(name = "derive_hardened")] + fn py_derive_hardened(&self, idx: u32) -> Self { + self.derive_hardened(idx) + } + + #[pyo3(name = "derive_unhardened")] + fn py_derive_unhardened(&self, idx: u32) -> Self { + self.derive_unhardened(idx) + } } impl ToJsonDict for SecretKey { diff --git a/wheel/generate_type_stubs.py b/wheel/generate_type_stubs.py index 91ef41b71..ab57e0625 100644 --- a/wheel/generate_type_stubs.py +++ b/wheel/generate_type_stubs.py @@ -389,6 +389,7 @@ def __init__( "def __str__(self) -> str: ...", "def __add__(self, other: G1Element) -> G1Element: ...", "def __iadd__(self, other: G1Element) -> G1Element: ...", + "def derive_unhardened(self, int) -> G1Element: ...", ], ) print_class( @@ -426,6 +427,9 @@ def __init__( "def sign_g2(self, msg: bytes, dst: bytes) -> G2Element: ...", "def get_g1(self) -> G1Element: ...", "def __str__(self) -> str: ...", + "def public_key(self) -> G1Element: ...", + "def derive_hardened(self, int) -> PrivateKey: ...", + "def derive_unhardened(self, int) -> PrivateKey: ...", ], ) diff --git a/wheel/python/chia_rs/chia_rs.pyi b/wheel/python/chia_rs/chia_rs.pyi index 5659dedd0..02001a0f4 100644 --- a/wheel/python/chia_rs/chia_rs.pyi +++ b/wheel/python/chia_rs/chia_rs.pyi @@ -126,6 +126,7 @@ class G1Element: def __str__(self) -> str: ... def __add__(self, other: G1Element) -> G1Element: ... def __iadd__(self, other: G1Element) -> G1Element: ... + def derive_unhardened(self, int) -> G1Element: ... def __init__( self ) -> None: ... @@ -211,6 +212,9 @@ class PrivateKey: def sign_g2(self, msg: bytes, dst: bytes) -> G2Element: ... def get_g1(self) -> G1Element: ... def __str__(self) -> str: ... + def public_key(self) -> G1Element: ... + def derive_hardened(self, int) -> PrivateKey: ... + def derive_unhardened(self, int) -> PrivateKey: ... def __init__( self ) -> None: ...