github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/crypto/internal/nistec/p384.go (about) 1 // Copyright 2022 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Code generated by generate.go. DO NOT EDIT. 6 7 package nistec 8 9 import ( 10 "github.com/shogo82148/std/crypto/internal/nistec/fiat" 11 ) 12 13 // P384Point is a P384 point. The zero value is NOT valid. 14 type P384Point struct { 15 // The point is represented in projective coordinates (X:Y:Z), 16 // where x = X/Z and y = Y/Z. 17 x, y, z *fiat.P384Element 18 } 19 20 // NewP384Point returns a new P384Point representing the point at infinity point. 21 func NewP384Point() *P384Point 22 23 // SetGenerator sets p to the canonical generator and returns p. 24 func (p *P384Point) SetGenerator() *P384Point 25 26 // Set sets p = q and returns p. 27 func (p *P384Point) Set(q *P384Point) *P384Point 28 29 // SetBytes sets p to the compressed, uncompressed, or infinity value encoded in 30 // b, as specified in SEC 1, Version 2.0, Section 2.3.4. If the point is not on 31 // the curve, it returns nil and an error, and the receiver is unchanged. 32 // Otherwise, it returns p. 33 func (p *P384Point) SetBytes(b []byte) (*P384Point, error) 34 35 // Bytes returns the uncompressed or infinity encoding of p, as specified in 36 // SEC 1, Version 2.0, Section 2.3.3. Note that the encoding of the point at 37 // infinity is shorter than all other encodings. 38 func (p *P384Point) Bytes() []byte 39 40 // BytesX returns the encoding of the x-coordinate of p, as specified in SEC 1, 41 // Version 2.0, Section 2.3.5, or an error if p is the point at infinity. 42 func (p *P384Point) BytesX() ([]byte, error) 43 44 // BytesCompressed returns the compressed or infinity encoding of p, as 45 // specified in SEC 1, Version 2.0, Section 2.3.3. Note that the encoding of the 46 // point at infinity is shorter than all other encodings. 47 func (p *P384Point) BytesCompressed() []byte 48 49 // Add sets q = p1 + p2, and returns q. The points may overlap. 50 func (q *P384Point) Add(p1, p2 *P384Point) *P384Point 51 52 // Double sets q = p + p, and returns q. The points may overlap. 53 func (q *P384Point) Double(p *P384Point) *P384Point 54 55 // Select sets q to p1 if cond == 1, and to p2 if cond == 0. 56 func (q *P384Point) Select(p1, p2 *P384Point, cond int) *P384Point 57 58 // ScalarMult sets p = scalar * q, and returns p. 59 func (p *P384Point) ScalarMult(q *P384Point, scalar []byte) (*P384Point, error) 60 61 // ScalarBaseMult sets p = scalar * B, where B is the canonical generator, and 62 // returns p. 63 func (p *P384Point) ScalarBaseMult(scalar []byte) (*P384Point, error)