Skip to content

[Clarity-4] secp256r1Β #6554

@brice-stacks

Description

@brice-stacks

Implement the new secp256r1 functions as described in the SIP:

  • secp256r1-recover?

    • Input: (buff 32), (buff 65)
    • Output: (response (buff 33) uint)
    • Signature: (secp256r1-recover? message-hash signature)
    • Description: The secp256r1-recover? function recovers the public key
      used to sign the message whose SHA-256 hash is message-hash using the
      provided signature. If the signature does not match the message hash, it
      returns (err u1). If the signature is invalid or malformed, it returns
      (err u2). The signature is expected to be 65 bytes (64 bytes of compact
      signature data plus a recovery id in the final byte).
    • Example:
      (secp256r1-recover? 0x033510403a646d23ee4f005061c2ca6af5da7c32c83758e8e9b6ac4cc1c2153c
        0x9608dc164b76d2e19365ffa67b48981e441d323c3109718aee245d6ac8ccd21ddadadb94303c922c0d79d131ea59a0b6ba83e1157695db01189bb4b7e9f14b7200) ;; Returns (ok 0x037a6b62e3c8b14f1b5933f5d5ab0509a8e7d95a111b8d3b264d95bfa753b00296)
  • secp256r1-verify

    • Input: (buff 32), (buff 64) | (buff 65), (buff 33)
    • Output: bool
    • Signature: (secp256r1-verify message-hash signature public-key)
    • Description: The secp256r1-verify function verifies that the provided
      signature of the message-hash was produced by the private key
      corresponding to public-key. The message-hash is the SHA-256 hash of the
      message. The signature may be 64 bytes (compact signature) or 65 bytes
      including an optional recovery id. Returns true if the signature is valid
      for the given public-key and message hash, otherwise returns false.
    • Example:
      (secp256r1-verify 0x033510403a646d23ee4f005061c2ca6af5da7c32c83758e8e9b6ac4cc1c2153c
        0x9608dc164b76d2e19365ffa67b48981e441d323c3109718aee245d6ac8ccd21ddadadb94303c922c0d79d131ea59a0b6ba83e1157695db01189bb4b7e9f14b7200 0x037a6b62e3c8b14f1b5933f5d5ab0509a8e7d95a111b8d3b264d95bfa753b00296) ;; Returns true
      (secp256r1-verify 0x0000000000000000000000000000000000000000000000000000000000000000
        0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
        0x037a6b62e3c8b14f1b5933f5d5ab0509a8e7d95a111b8d3b264d95bfa753b00296) ;; Returns false

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Status: πŸ“‹ Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions