You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.7 KiB
53 lines
1.7 KiB
// Copyright 2010 The Go Authors. All rights reserved. |
|
// Copyright 2011 ThePiachu. All rights reserved. |
|
// Copyright 2013-2014 The btcsuite developers |
|
// Use of this source code is governed by an ISC |
|
// license that can be found in the LICENSE file. |
|
|
|
package btcec |
|
|
|
// References: |
|
// [SECG]: Recommended Elliptic Curve Domain Parameters |
|
// http://www.secg.org/sec2-v2.pdf |
|
// |
|
// [GECC]: Guide to Elliptic Curve Cryptography (Hankerson, Menezes, Vanstone) |
|
|
|
// This package operates, internally, on Jacobian coordinates. For a given |
|
// (x, y) position on the curve, the Jacobian coordinates are (x1, y1, z1) |
|
// where x = x1/z1² and y = y1/z1³. The greatest speedups come when the whole |
|
// calculation can be performed within the transform (as in ScalarMult and |
|
// ScalarBaseMult). But even for Add and Double, it's faster to apply and |
|
// reverse the transform than to operate in affine coordinates. |
|
|
|
import ( |
|
"next.orly.dev/pkg/crypto/ec/secp256k1" |
|
) |
|
|
|
// KoblitzCurve provides an implementation for secp256k1 that fits the ECC |
|
// Curve interface from crypto/elliptic. |
|
type KoblitzCurve = secp256k1.KoblitzCurve |
|
|
|
// S256 returns a Curve which implements secp256k1. |
|
func S256() *KoblitzCurve { |
|
return secp256k1.S256() |
|
} |
|
|
|
// CurveParams contains the parameters for the secp256k1 curve. |
|
type CurveParams = secp256k1.CurveParams |
|
|
|
// Params returns the secp256k1 curve parameters for convenience. |
|
func Params() *CurveParams { |
|
return secp256k1.Params() |
|
} |
|
|
|
// Generator returns the public key at the Generator Point. |
|
func Generator() *PublicKey { |
|
var ( |
|
result JacobianPoint |
|
k secp256k1.ModNScalar |
|
) |
|
k.SetInt(1) |
|
ScalarBaseMultNonConst(&k, &result) |
|
result.ToAffine() |
|
return NewPublicKey(&result.X, &result.Y) |
|
}
|
|
|