Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Complete arithmetic implementation for bitcoin_key types #3

Open
dr-orlovsky opened this issue Jul 6, 2022 · 0 comments
Open

Complete arithmetic implementation for bitcoin_key types #3

dr-orlovsky opened this issue Jul 6, 2022 · 0 comments

Comments

@dr-orlovsky
Copy link
Member

Definition Operation Fails if Trait Return type
neg: Scalar -> Scalar x -> (0 - x) mod n - Neg Self
checked_add: Scalar, Scalar -> Scalar x, y -> (x + z) x + z > n n/a Result<Self, OverflowError>
checked_sub: Scalar, Scalar -> Scalar x, y -> (x + (0 - y) mod n) y > x n/a Result<Self, OverflowError>
checked_mul: Scalar, Scalar -> Scalar x, y -> add(x, x) y times x * y > n n/a Result<Self, OverflowError>
neg: Scalar -> Scalar P -> ∞ + P - Neg Self
checked_add: Point, Point -> Point P, Q -> P + Q Q = -P n/a Result<Self, PointAtInfinity>
checked_sub: Point, Point -> Point P, Q -> P + ∞ + Q Q = P n/a Result<Self, PointAtInfinity>
checked_add_exp: Point, Scalar -> Point P, y -> P + yG yG = -P n/a Result<Self, PointAtInfinity>
checked_sub_exp: Point, Scalar -> Point P, y -> P + ∞ + yG yG = P n/a Result<Self, PointAtInfinity>
mul: Point, Scalar -> Point P, y -> yP -1 Mul<Self> Self

where

  • x, y, z are scalars with the value up to n,
  • n is a order of the secp256k1 generator point G,
  • P, Q, R are points on the elliptic curve secp256k1 generated from G via xG, yG and zG multiplication.
  • is a point on elliptic curve at infinity, corresponding to G * 0

Footnotes

  1. allows overflow over G order

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant