Sign in

    daqing/moon-pay-sdk/crypto does not have a README file

    CryptoError

    pub(all) suberror CryptoError {
    Malformed(String)
    Unsupported(String)
    Operation(String)
    Random(String)
    }

    Key, certificate or ciphertext material that cannot be used as given.
    impl Show for CryptoError

    CryptoError::output

    fn CryptoError::output(self : CryptoError, logger : &Logger) -> Unit

    CryptoError::to_string

    fn CryptoError::to_string(self : CryptoError) -> String

    aes256_gcm_decrypt

    fn aes256_gcm_decrypt(key : BytesView, nonce : BytesView, cipher : BytesView, aad? : BytesView) -> Bytes raise CryptoError

    Decrypt an AES-256-GCM payload in the WeChat Pay v3 callback layout: the ciphertext bytes carry the 16-byte authentication tag appended, the nonce is 12 bytes and the associated data may be empty.

    certificate_public_key

    The RSA public key the certificate carries.

    certificate_serial_hex

    fn certificate_serial_hex(cert :
    Cert
    ) -> String

    The certificate serial number as lowercase hex — the form WeChat Pay uses in its Wechatpay-Serial header.

    load_certificate_pem

    fn load_certificate_pem(text : String) ->
    Cert
    raise CryptoError

    Load an X.509 certificate from a PEM string (BEGIN CERTIFICATE).

    load_private_key_pem

    fn load_private_key_pem(text : String) ->
    PrivateKey
    raise CryptoError

    Load an RSA signing key from a PEM string: PKCS#8 (BEGIN PRIVATE KEY) or PKCS#1 (BEGIN RSA PRIVATE KEY).

    load_public_key_pem

    fn load_public_key_pem(text : String) ->
    PublicKey
    raise CryptoError

    Load an RSA public key from a SubjectPublicKeyInfo PEM string (BEGIN PUBLIC KEY).

    public_key_from_spki_der

    fn public_key_from_spki_der(der : Bytes) ->
    PublicKey
    raise CryptoError

    Build an RSA public key from DER SubjectPublicKeyInfo bytes.

    random_bytes

    async fn random_bytes(len : Int) -> Bytes raise CryptoError

    Cryptographic random bytes from the operating system entropy pool (/dev/urandom on Linux and macOS).

    random_hex

    async fn random_hex(byte_len : Int) -> String raise CryptoError

    A lowercase-hex random string, two characters per byte — the shape of WeChat Pay's nonce_str.

    sign_rsa_sha256

    fn sign_rsa_sha256(key :
    PrivateKey
    , message : BytesView) -> Bytes

    Sign with RSA PKCS#1 v1.5 over SHA-256 — the scheme behind both WeChat Pay v3 request authentication and Alipay RSA2. Deterministic: the same key and message always produce the same signature.

    verify_rsa_sha256

    fn verify_rsa_sha256(key :
    PublicKey
    , message : BytesView, signature : BytesView) -> Bool

    Check an RSA PKCS#1 v1.5 / SHA-256 signature.