Documentation ¶
Overview ¶
Copyright © 2020 AMIS Technologies
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func NewCacheExp(bq *BQuadraticForm) *cacheExp
- type BQForm
- func (*BQForm) Descriptor() ([]byte, []int)deprecated
- func (x *BQForm) GetA() string
- func (x *BQForm) GetB() string
- func (x *BQForm) GetC() string
- func (*BQForm) ProtoMessage()
- func (x *BQForm) ProtoReflect() protoreflect.Message
- func (x *BQForm) Reset()
- func (x *BQForm) String() string
- func (bf *BQForm) ToBQuadraticForm() (*BQuadraticForm, error)
- func (bf *BQForm) ToCacheExp() (*cacheExp, error)
- type BQuadraticForm
- func (bqForm *BQuadraticForm) Composition(inputForm *BQuadraticForm) (*BQuadraticForm, error)
- func (bqForm *BQuadraticForm) Copy() *BQuadraticForm
- func (bqForm *BQuadraticForm) Equal(bqForm1 *BQuadraticForm) bool
- func (bqForm *BQuadraticForm) Exp(power *big.Int) (*BQuadraticForm, error)
- func (bqForm *BQuadraticForm) GetA() *big.Int
- func (bqForm *BQuadraticForm) GetB() *big.Int
- func (bqForm *BQuadraticForm) GetC() *big.Int
- func (bqForm *BQuadraticForm) GetDiscriminant() *big.Int
- func (bqForm *BQuadraticForm) Identity() *BQuadraticForm
- func (bqForm *BQuadraticForm) Inverse() *BQuadraticForm
- func (bqForm *BQuadraticForm) IsReducedForm() bool
- func (b *BQuadraticForm) ToMessage() *BQForm
- type Exper
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPositiveDiscriminant is returned if the discriminant is negative. ErrPositiveDiscriminant = errors.New("not a negative discriminant") // ErrDifferentDiscriminant is returned if the discriminants are different. ErrDifferentDiscriminant = errors.New("different discriminant") // ErrEmptySlice is returned if the slice is empty. ErrEmptySlice = errors.New("slice is empty") // ErrZero is returned if the integer is zero. ErrZero = errors.New("the integer is zero") )
var (
ErrInvalidMessage = errors.New("invalid message")
)
var File_github_com_getamis_alice_crypto_binaryquadraticform_message_proto protoreflect.FileDescriptor
Functions ¶
func NewCacheExp ¶
func NewCacheExp(bq *BQuadraticForm) *cacheExp
NewCacheExp initiates a cache BQ exp. In this struct, we calculate exp by cached values
Types ¶
type BQForm ¶
type BQForm struct { // a, b, c may be negative, so we use string type. A string `protobuf:"bytes,1,opt,name=a,proto3" json:"a,omitempty"` B string `protobuf:"bytes,2,opt,name=b,proto3" json:"b,omitempty"` C string `protobuf:"bytes,3,opt,name=c,proto3" json:"c,omitempty"` // contains filtered or unexported fields }
func (*BQForm) Descriptor
deprecated
func (*BQForm) ProtoMessage ¶
func (*BQForm) ProtoMessage()
func (*BQForm) ProtoReflect ¶ added in v1.0.2
func (x *BQForm) ProtoReflect() protoreflect.Message
func (*BQForm) ToBQuadraticForm ¶
func (bf *BQForm) ToBQuadraticForm() (*BQuadraticForm, error)
func (*BQForm) ToCacheExp ¶
type BQuadraticForm ¶
type BQuadraticForm struct {
// contains filtered or unexported fields
}
In this library, we only consider positive definite quadratic forms
This Library only supports some operations of "primitives positive definite binary quadratic forms" (i.e. * corresponding to ideal operations over imaginary quadratic fields). * A Quadratic form is given by: (a,b,c) := ax^2+bxy+cy^2 with discriminant = b^2 - 4ac < 0
func NewBQuadraticForm ¶
Give a, b, c to construct quadratic forms.
func NewBQuadraticFormByDiscriminant ¶
func NewBQuadraticFormByDiscriminant(a *big.Int, b *big.Int, discriminant *big.Int) (*BQuadraticForm, error)
Give a, b, discriminant to construct quadratic forms.
func (*BQuadraticForm) Composition ¶
func (bqForm *BQuadraticForm) Composition(inputForm *BQuadraticForm) (*BQuadraticForm, error)
The composition operation of binary quadratic forms * NUCOMP algorithm. Adapted from "Solving the Pell Equation" * by Michael J. Jacobson, Jr. and Hugh C. Williams. * http://www.springer.com/mathematics/numbers/book/978-0-387-84922-5 * The code original author: Maxwell Sayles. * Code: https://github.com/maxwellsayles/libqform/blob/master/mpz_qform.c
func (*BQuadraticForm) Copy ¶
func (bqForm *BQuadraticForm) Copy() *BQuadraticForm
copy the binary quadratic form
func (*BQuadraticForm) Equal ¶
func (bqForm *BQuadraticForm) Equal(bqForm1 *BQuadraticForm) bool
func (*BQuadraticForm) Exp ¶
func (bqForm *BQuadraticForm) Exp(power *big.Int) (*BQuadraticForm, error)
The output is bqForm ^ power. Ref: Algorithm 3.2, page 30, * Improved Arithmetic in the Ideal Class Group of Imaginary * Quadratic Number Fields, Maxwell Sayles.
func (*BQuadraticForm) GetA ¶
func (bqForm *BQuadraticForm) GetA() *big.Int
Get the coefficient of a binary quadratic form: ax^2 + bxy + cy^2 Get a
func (*BQuadraticForm) GetDiscriminant ¶
func (bqForm *BQuadraticForm) GetDiscriminant() *big.Int
Get discriminant
func (*BQuadraticForm) Identity ¶
func (bqForm *BQuadraticForm) Identity() *BQuadraticForm
Identity element := bqForm * bqForm.Inverse()
func (*BQuadraticForm) Inverse ¶
func (bqForm *BQuadraticForm) Inverse() *BQuadraticForm
The inverse quadratic Form of [a,b,c] is [a,-b,c]
func (*BQuadraticForm) IsReducedForm ¶
func (bqForm *BQuadraticForm) IsReducedForm() bool
Note that: D < 0. (a,b,c) is reduced if |b| <= a <= c and if b >= 0 whenever a = |b| or a = c
func (*BQuadraticForm) ToMessage ¶
func (b *BQuadraticForm) ToMessage() *BQForm