status-go/vendor/github.com/kilic/bls12-381
Samuel Hawksby-Robinson c8f9dad554
Feature/key compression (#1990)
## What has changed?

I've introduced to the public binding functionality that will compress and decompress public keys of a variety of encoding and key types. This functionality supports all major byte encoding formats and the following EC public key types:

- `secp256k1` pks
- `bls12-381 g1` pks
- `bls12-381 g2` pks

## Why make the change?

We want shorter public (chat) keys and we want to be future proof and encoding agnostic. See the issue here https://github.com/status-im/status-go/issues/1937

---

* Added basic signature for compresspk and uncompresspk

* Added basic encoding information

* make vendor

* formatted imports for the linter

* Reformatted imports hoping linter likes it

* This linter is capricious

* Added check that the secp256k1 key is valid

* Added test for valid key

* Added multiformat/go-varint dep

* Added public key type handling

* Added key decompression with key type handling

* Added handling for '0x' type indentifying

* Added more robust testing

* Less lint for the linting gods

* make vendor for bls12_381

* Added bls12-381 compression tests

* Added decompress key expected results

* Refactor of typed and untyped keys in tests

* Lint god appeasment

* Refactor of sample public keys

* Implemented bls12-381 decompression

* gofmt

* Renamed decode/encode funcs to be more descriptive

* Added binary bindings for key de/compression

* Refactor of func parameters

gomobile is a bit tempermental using raw bytes as a parameter, so I've decided to use string only inputs and outputs

* gofmt

* Added function documentation

* Moved multiformat de/compression into api/multiformat ns

* Moved multiformat de/compression into api/multiformat ns

* Changed compress to serialize on API
2020-06-23 11:47:17 +01:00
..
.gitignore Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
LICENSE Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
README.md Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
arithmetic_decl.go Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
arithmetic_fallback.go Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
arithmetic_x86.s Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
bls12_381.go Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
field_element.go Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
fp.go Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
fp2.go Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
fp6.go Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
fp12.go Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
g1.go Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
g2.go Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
go.mod Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
go.sum Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
gt.go Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
hash_to_field.go Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
isogeny.go Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
pairing.go Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
swu.go Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
utils.go Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00
wnaf.go Feature/key compression (#1990) 2020-06-23 11:47:17 +01:00

README.md

High Speed BLS12-381 Implementation in Go

Pairing Instance

A Group instance or a pairing engine instance is not suitable for concurrent processing since an instance has its own preallocated memory for temporary variables. A new instance must be created for each thread.

Base Field

x86 optimized base field is generated with kilic/fp and for native go is generated with goff. Generated codes are slightly edited in both for further requirements.

Scalar Field

Standart big.Int module is currently used for scalar field implementation. x86 optimized faster field implementation is planned to be added.

Serialization

Point serialization is in line with zkcrypto library.

Hashing to Curve

Hashing to curve implementations for both G1 and G2 follows _XMD:SHA-256_SSWU_RO_ and _XMD:SHA-256_SSWU_NU_ suites as defined in v7 of irtf hash to curve draft.

Benchmarks

on 3.1 GHz i5

BenchmarkPairing  1034837 ns/op