Skip to content

Add the hardware signer compatibility (secp256r1)  #193

@remiroyc

Description

@remiroyc

Problem

The Bravos wallets use secure enclave and NIST-P256 elliptic curve (secp256r1) to sign messages.
We must implement this signer in Cairo to verify the order proof and be filly compatible with this kind of wallets.

Feature request

The task here is to add a variant to the SignerValidator enum to support this: https://github.com/starkware-libs/cairo/blob/v2.3.1/corelib/src/starknet/secp256r1.cairo

impl SignerValidator of SignatureChecker {
    fn verify(hash: felt252, signer: Signer) -> felt252 {
        match signer {
            Signer::WEIERSTRESS_STARKNET(sign_info) => {
                let is_valid = ecdsa::check_ecdsa_signature(
                    hash, sign_info.user_pubkey, sign_info.user_sig_r, sign_info.user_sig_s
                );
                assert(is_valid, 'INVALID_SIGNATURE');
                sign_info.user_pubkey
            }
        }
    }
}

#[derive(Serde, Copy, Drop)]
enum Signer {
    WEIERSTRESS_STARKNET: SignInfo,
}

Links

https://braavos.app/hardware-signer-2fa-security-crypto-smart-contract-wallets/

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:cairoWork on the Starknet part of the application; you need to know Cairo lang.priority: mediumstatus: help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions