Remove b
Turns out we don't need it
This commit is contained in:
parent
ae2a253a13
commit
2f1d410423
5 changed files with 6 additions and 12 deletions
|
@ -311,13 +311,12 @@ mod tests {
|
|||
|
||||
let p = bink["p"].as_str().unwrap();
|
||||
let a = bink["a"].as_str().unwrap();
|
||||
let b = bink["b"].as_str().unwrap();
|
||||
let gx = bink["g"]["x"].as_str().unwrap();
|
||||
let gy = bink["g"]["y"].as_str().unwrap();
|
||||
let kx = bink["pub"]["x"].as_str().unwrap();
|
||||
let ky = bink["pub"]["y"].as_str().unwrap();
|
||||
|
||||
let curve = EllipticCurve::new(p, a, b, gx, gy, kx, ky).unwrap();
|
||||
let curve = EllipticCurve::new(p, a, gx, gy, kx, ky).unwrap();
|
||||
|
||||
assert!(bink1998::ProductKey::from_key(&curve, product_key).is_ok());
|
||||
assert!(bink1998::ProductKey::from_key(&curve, "11111-R6BG2-39J83-RYKHF-W47TT").is_err());
|
||||
|
|
|
@ -382,13 +382,12 @@ mod tests {
|
|||
|
||||
let p = bink["p"].as_str().unwrap();
|
||||
let a = bink["a"].as_str().unwrap();
|
||||
let b = bink["b"].as_str().unwrap();
|
||||
let gx = bink["g"]["x"].as_str().unwrap();
|
||||
let gy = bink["g"]["y"].as_str().unwrap();
|
||||
let kx = bink["pub"]["x"].as_str().unwrap();
|
||||
let ky = bink["pub"]["y"].as_str().unwrap();
|
||||
|
||||
let curve = EllipticCurve::new(p, a, b, gx, gy, kx, ky).unwrap();
|
||||
let curve = EllipticCurve::new(p, a, gx, gy, kx, ky).unwrap();
|
||||
|
||||
assert!(super::ProductKey::from_key(&curve, product_key).is_ok());
|
||||
assert!(super::ProductKey::from_key(&curve, "11111-YRGC8-4KYTG-C3FCC-JCFDY").is_err());
|
||||
|
|
|
@ -30,7 +30,6 @@ impl EllipticCurve {
|
|||
pub fn new(
|
||||
p: &str,
|
||||
a: &str,
|
||||
b: &str,
|
||||
generator_x: &str,
|
||||
generator_y: &str,
|
||||
public_key_x: &str,
|
||||
|
@ -38,13 +37,12 @@ impl EllipticCurve {
|
|||
) -> Result<Self> {
|
||||
let p = BigInt::from_str_radix(p, 10)?;
|
||||
let a = BigInt::from_str_radix(a, 10)?;
|
||||
let b = BigInt::from_str_radix(b, 10)?;
|
||||
let generator_x = BigInt::from_str_radix(generator_x, 10)?;
|
||||
let generator_y = BigInt::from_str_radix(generator_y, 10)?;
|
||||
let public_key_x = BigInt::from_str_radix(public_key_x, 10)?;
|
||||
let public_key_y = BigInt::from_str_radix(public_key_y, 10)?;
|
||||
|
||||
let curve = WeierstrassCurve::new(a, b, p);
|
||||
let curve = WeierstrassCurve::new(a, p);
|
||||
|
||||
let gen_point = Point::Point {
|
||||
x: generator_x,
|
||||
|
|
|
@ -11,13 +11,12 @@ pub enum Point {
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct WeierstrassCurve {
|
||||
a: BigInt,
|
||||
b: BigInt,
|
||||
p: BigInt,
|
||||
}
|
||||
|
||||
impl WeierstrassCurve {
|
||||
pub fn new(a: BigInt, b: BigInt, p: BigInt) -> Self {
|
||||
WeierstrassCurve { a, b, p }
|
||||
pub fn new(a: BigInt, p: BigInt) -> Self {
|
||||
WeierstrassCurve { a, p }
|
||||
}
|
||||
|
||||
fn mod_inverse(a: &BigInt, p: &BigInt) -> BigInt {
|
||||
|
|
|
@ -102,7 +102,6 @@ fn validate(args: &ValidateArgs) -> Result<()> {
|
|||
fn initialize_curve(bink: &Bink, bink_id: &str) -> Result<EllipticCurve> {
|
||||
let p = &bink.p;
|
||||
let a = &bink.a;
|
||||
let b = &bink.b;
|
||||
let gx = &bink.g.x;
|
||||
let gy = &bink.g.y;
|
||||
let kx = &bink.public.x;
|
||||
|
@ -110,7 +109,7 @@ fn initialize_curve(bink: &Bink, bink_id: &str) -> Result<EllipticCurve> {
|
|||
|
||||
log::info!("Elliptic curve parameters for BINK ID {bink_id}:\n{bink}");
|
||||
|
||||
EllipticCurve::new(p, a, b, gx, gy, kx, ky)
|
||||
EllipticCurve::new(p, a, gx, gy, kx, ky)
|
||||
}
|
||||
|
||||
fn bink1998_generate(
|
||||
|
|
Loading…
Add table
Reference in a new issue