diff --git a/Makefile b/Makefile index e26c59bebf4..48c94e8a21c 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,6 @@ # - docs - builds the documentation in html format # - gotools - installs go tools like golint # - help-docs - generate the command reference docs -# - idemixgen - builds a native idemixgen binary # - integration-test-prereqs - setup prerequisites for integration tests # - integration-test - runs the integration tests # - ledgerutil - builds a native ledgerutil binary @@ -85,14 +84,13 @@ GO_TAGS ?= RELEASE_EXES = orderer $(TOOLS_EXES) RELEASE_IMAGES = baseos ccenv orderer peer tools RELEASE_PLATFORMS = darwin-amd64 linux-amd64 windows-amd64 -TOOLS_EXES = configtxgen configtxlator cryptogen discover idemixgen ledgerutil osnadmin peer +TOOLS_EXES = configtxgen configtxlator cryptogen discover ledgerutil osnadmin peer pkgmap.configtxgen := $(PKGNAME)/cmd/configtxgen pkgmap.configtxlator := $(PKGNAME)/cmd/configtxlator pkgmap.cryptogen := $(PKGNAME)/cmd/cryptogen pkgmap.discover := $(PKGNAME)/cmd/discover -pkgmap.idemixgen := $(PKGNAME)/cmd/idemixgen -pkgmap.ledgerutil := $(PKGNAME)/cmd/ledgerutil +pkgmap.ledgerutil := $(PKGNAME)/cmd/ledgerutil pkgmap.orderer := $(PKGNAME)/cmd/orderer pkgmap.osnadmin := $(PKGNAME)/cmd/osnadmin pkgmap.peer := $(PKGNAME)/cmd/peer diff --git a/bccsp/idemix/bccsp_test.go b/bccsp/idemix/bccsp_test.go deleted file mode 100644 index ecd62e614eb..00000000000 --- a/bccsp/idemix/bccsp_test.go +++ /dev/null @@ -1,295 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ -package idemix_test - -import ( - "crypto/rand" - - "github.com/hyperledger/fabric/bccsp" - "github.com/hyperledger/fabric/bccsp/idemix" - "github.com/hyperledger/fabric/bccsp/sw" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Idemix Bridge", func() { - Describe("setting up the environment with one issuer and one user", func() { - var ( - CSP bccsp.BCCSP - IssuerKey bccsp.Key - IssuerPublicKey bccsp.Key - AttributeNames []string - - UserKey bccsp.Key - NymKey bccsp.Key - NymPublicKey bccsp.Key - - IssuerNonce []byte - credRequest []byte - - credential []byte - - RevocationKey bccsp.Key - RevocationPublicKey bccsp.Key - cri []byte - ) - - BeforeEach(func() { - var err error - CSP, err = idemix.New(sw.NewDummyKeyStore()) - Expect(err).NotTo(HaveOccurred()) - - // Issuer - AttributeNames = []string{"Attr1", "Attr2", "Attr3", "Attr4", "Attr5"} - IssuerKey, err = CSP.KeyGen(&bccsp.IdemixIssuerKeyGenOpts{Temporary: true, AttributeNames: AttributeNames}) - Expect(err).NotTo(HaveOccurred()) - IssuerPublicKey, err = IssuerKey.PublicKey() - Expect(err).NotTo(HaveOccurred()) - - // User - UserKey, err = CSP.KeyGen(&bccsp.IdemixUserSecretKeyGenOpts{Temporary: true}) - Expect(err).NotTo(HaveOccurred()) - - // User Nym Key - NymKey, err = CSP.KeyDeriv(UserKey, &bccsp.IdemixNymKeyDerivationOpts{Temporary: true, IssuerPK: IssuerPublicKey}) - Expect(err).NotTo(HaveOccurred()) - NymPublicKey, err = NymKey.PublicKey() - Expect(err).NotTo(HaveOccurred()) - - IssuerNonce = make([]byte, 32) - n, err := rand.Read(IssuerNonce) - Expect(n).To(BeEquivalentTo(32)) - Expect(err).NotTo(HaveOccurred()) - - // Credential Request for User - credRequest, err = CSP.Sign( - UserKey, - nil, - &bccsp.IdemixCredentialRequestSignerOpts{IssuerPK: IssuerPublicKey, IssuerNonce: IssuerNonce}, - ) - Expect(err).NotTo(HaveOccurred()) - - // Credential - credential, err = CSP.Sign( - IssuerKey, - credRequest, - &bccsp.IdemixCredentialSignerOpts{ - Attributes: []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0}}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1}}, - {Type: bccsp.IdemixIntAttribute, Value: 1}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1, 2}}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1, 2, 3}}, - }, - }, - ) - Expect(err).NotTo(HaveOccurred()) - - // Revocation - RevocationKey, err = CSP.KeyGen(&bccsp.IdemixRevocationKeyGenOpts{Temporary: true}) - Expect(err).NotTo(HaveOccurred()) - RevocationPublicKey, err = RevocationKey.PublicKey() - Expect(err).NotTo(HaveOccurred()) - - // CRI - cri, err = CSP.Sign( - RevocationKey, - nil, - &bccsp.IdemixCRISignerOpts{}, - ) - Expect(err).NotTo(HaveOccurred()) - }) - - It("the environment is properly set", func() { - // Verify CredRequest - valid, err := CSP.Verify( - IssuerPublicKey, - credRequest, - nil, - &bccsp.IdemixCredentialRequestSignerOpts{IssuerNonce: IssuerNonce}, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(valid).To(BeTrue()) - - // Verify Credential - valid, err = CSP.Verify( - UserKey, - credential, - nil, - &bccsp.IdemixCredentialSignerOpts{ - IssuerPK: IssuerPublicKey, - Attributes: []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0}}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1}}, - {Type: bccsp.IdemixIntAttribute, Value: 1}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1, 2}}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1, 2, 3}}, - }, - }, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(valid).To(BeTrue()) - - // Verify CRI - valid, err = CSP.Verify( - RevocationPublicKey, - cri, - nil, - &bccsp.IdemixCRISignerOpts{}, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(valid).To(BeTrue()) - }) - - Describe("producing an idemix signature with no disclosed attribute", func() { - var ( - digest []byte - signature []byte - ) - - BeforeEach(func() { - var err error - - digest = []byte("a digest") - - signature, err = CSP.Sign( - UserKey, - digest, - &bccsp.IdemixSignerOpts{ - Credential: credential, - Nym: NymKey, - IssuerPK: IssuerPublicKey, - Attributes: []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - }, - RhIndex: 4, - Epoch: 0, - CRI: cri, - }, - ) - Expect(err).NotTo(HaveOccurred()) - }) - - It("the signature is valid", func() { - valid, err := CSP.Verify( - IssuerPublicKey, - signature, - digest, - &bccsp.IdemixSignerOpts{ - RevocationPublicKey: RevocationPublicKey, - Attributes: []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - }, - RhIndex: 4, - Epoch: 0, - }, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(valid).To(BeTrue()) - }) - }) - - Describe("producing an idemix signature with disclosed attributes", func() { - var ( - digest []byte - signature []byte - ) - - BeforeEach(func() { - var err error - - digest = []byte("a digest") - - signature, err = CSP.Sign( - UserKey, - digest, - &bccsp.IdemixSignerOpts{ - Credential: credential, - Nym: NymKey, - IssuerPK: IssuerPublicKey, - Attributes: []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixBytesAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixIntAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - }, - RhIndex: 4, - Epoch: 0, - CRI: cri, - }, - ) - Expect(err).NotTo(HaveOccurred()) - }) - - It("the signature is valid", func() { - valid, err := CSP.Verify( - IssuerPublicKey, - signature, - digest, - &bccsp.IdemixSignerOpts{ - RevocationPublicKey: RevocationPublicKey, - Attributes: []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0}}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixIntAttribute, Value: 1}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - }, - RhIndex: 4, - Epoch: 0, - }, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(valid).To(BeTrue()) - }) - }) - - Describe("producing an idemix nym signature", func() { - var ( - digest []byte - signature []byte - ) - - BeforeEach(func() { - var err error - - digest = []byte("a digest") - - signature, err = CSP.Sign( - UserKey, - digest, - &bccsp.IdemixNymSignerOpts{ - Nym: NymKey, - IssuerPK: IssuerPublicKey, - }, - ) - Expect(err).NotTo(HaveOccurred()) - }) - - It("the signature is valid", func() { - valid, err := CSP.Verify( - NymPublicKey, - signature, - digest, - &bccsp.IdemixNymSignerOpts{ - IssuerPK: IssuerPublicKey, - }, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(valid).To(BeTrue()) - }) - }) - }) -}) diff --git a/bccsp/idemix/bridge/bridge_suite_test.go b/bccsp/idemix/bridge/bridge_suite_test.go deleted file mode 100644 index 5f8640430fd..00000000000 --- a/bccsp/idemix/bridge/bridge_suite_test.go +++ /dev/null @@ -1,24 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ -package bridge_test - -import ( - "testing" - - "github.com/hyperledger/fabric-amcl/amcl" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestPlain(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Plain Suite") -} - -// NewRandPanic is an utility test function that always panic when invoked -func NewRandPanic() *amcl.RAND { - panic("new rand panic") -} diff --git a/bccsp/idemix/bridge/bridge_test.go b/bccsp/idemix/bridge/bridge_test.go deleted file mode 100644 index ddd638b8dad..00000000000 --- a/bccsp/idemix/bridge/bridge_test.go +++ /dev/null @@ -1,1397 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ -package bridge_test - -import ( - "crypto/rand" - "fmt" - - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" - "github.com/hyperledger/fabric/bccsp" - "github.com/hyperledger/fabric/bccsp/idemix/bridge" - "github.com/hyperledger/fabric/bccsp/idemix/handlers" - "github.com/hyperledger/fabric/bccsp/idemix/handlers/mock" - cryptolib "github.com/hyperledger/fabric/idemix" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Idemix Bridge", func() { - var ( - userSecretKey handlers.Big - issuerPublicKey handlers.IssuerPublicKey - issuerSecretKey handlers.IssuerSecretKey - nymPublicKey handlers.Ecp - nymSecretKey handlers.Big - ) - - BeforeEach(func() { - userSecretKey = &bridge.Big{} - issuerPublicKey = &bridge.IssuerPublicKey{} - issuerSecretKey = &bridge.IssuerSecretKey{} - nymPublicKey = &bridge.Ecp{} - nymSecretKey = &bridge.Big{} - }) - - Describe("issuer", func() { - var Issuer *bridge.Issuer - - BeforeEach(func() { - Issuer = &bridge.Issuer{NewRand: bridge.NewRandOrPanic} - }) - - Context("key generation", func() { - Context("successful generation", func() { - var ( - key handlers.IssuerSecretKey - err error - attributes []string - ) - - It("with valid attributes", func() { - attributes = []string{"A", "B"} - key, err = Issuer.NewKey(attributes) - Expect(err).NotTo(HaveOccurred()) - Expect(key).NotTo(BeNil()) - }) - - It("with empty attributes", func() { - attributes = nil - key, err = Issuer.NewKey(attributes) - Expect(err).NotTo(HaveOccurred()) - Expect(key).NotTo(BeNil()) - }) - - AfterEach(func() { - raw, err := key.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw).NotTo(BeEmpty()) - - pk := key.Public() - Expect(pk).NotTo(BeNil()) - - h := pk.Hash() - Expect(h).NotTo(BeEmpty()) - - raw, err = pk.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw).NotTo(BeEmpty()) - - pk2, err := Issuer.NewPublicKeyFromBytes(raw, attributes) - Expect(err).NotTo(HaveOccurred()) - - raw2, err := pk2.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw2).NotTo(BeEmpty()) - Expect(pk2.Hash()).To(BeEquivalentTo(pk.Hash())) - Expect(raw2).To(BeEquivalentTo(raw)) - }) - }) - - It("panic on rand failure", func() { - Issuer.NewRand = NewRandPanic - key, err := Issuer.NewKey(nil) - Expect(err).To(MatchError("failure [new rand panic]")) - Expect(key).To(BeNil()) - }) - }) - - Context("public key import", func() { - It("fails to unmarshal issuer public key", func() { - pk, err := Issuer.NewPublicKeyFromBytes([]byte{0, 1, 2, 3, 4}, nil) - Expect(err).To(MatchError("failed to unmarshal issuer public key: proto: idemix.IssuerPublicKey: illegal tag 0 (wire type 0)")) - Expect(pk).To(BeNil()) - }) - - It("fails to unmarshal issuer public key", func() { - pk, err := Issuer.NewPublicKeyFromBytes(nil, nil) - Expect(err).To(MatchError(ContainSubstring("failure [runtime error: index out of range"))) - Expect(pk).To(BeNil()) - }) - - Context("and it is modified", func() { - var pk handlers.IssuerPublicKey - BeforeEach(func() { - attributes := []string{"A", "B"} - key, err := Issuer.NewKey(attributes) - Expect(err).NotTo(HaveOccurred()) - pk = key.Public() - Expect(pk).NotTo(BeNil()) - }) - - It("fails to validate invalid issuer public key", func() { - if pk.(*bridge.IssuerPublicKey).PK.ProofC[0] != 1 { - pk.(*bridge.IssuerPublicKey).PK.ProofC[0] = 1 - } else { - pk.(*bridge.IssuerPublicKey).PK.ProofC[0] = 0 - } - raw, err := pk.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw).NotTo(BeEmpty()) - - pk, err = Issuer.NewPublicKeyFromBytes(raw, nil) - Expect(err).To(MatchError("invalid issuer public key: zero knowledge proof in public key invalid")) - Expect(pk).To(BeNil()) - }) - - It("fails to verify attributes, different length", func() { - raw, err := pk.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw).NotTo(BeEmpty()) - - pk, err := Issuer.NewPublicKeyFromBytes(raw, []string{"A"}) - Expect(err).To(MatchError("invalid number of attributes, expected [2], got [1]")) - Expect(pk).To(BeNil()) - }) - - It("fails to verify attributes, different attributes", func() { - raw, err := pk.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw).NotTo(BeEmpty()) - - pk, err := Issuer.NewPublicKeyFromBytes(raw, []string{"A", "C"}) - Expect(err).To(MatchError("invalid attribute name at position [1]")) - Expect(pk).To(BeNil()) - }) - }) - }) - }) - - Describe("user", func() { - var User *bridge.User - - BeforeEach(func() { - User = &bridge.User{NewRand: bridge.NewRandOrPanic} - }) - - Context("secret key generation", func() { - It("panic on rand failure", func() { - User.NewRand = NewRandPanic - key, err := User.NewKey() - Expect(err).To(MatchError("failure [new rand panic]")) - Expect(key).To(BeNil()) - }) - }) - - Context("secret key import", func() { - It("success", func() { - key, err := User.NewKey() - Expect(err).NotTo(HaveOccurred()) - - raw, err := key.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw).NotTo(BeNil()) - - key2, err := User.NewKeyFromBytes(raw) - Expect(err).NotTo(HaveOccurred()) - - raw2, err := key2.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw2).NotTo(BeNil()) - - Expect(raw2).To(BeEquivalentTo(raw)) - }) - - It("fails on nil raw", func() { - key, err := User.NewKeyFromBytes(nil) - Expect(err).To(MatchError("invalid length, expected [32], got [0]")) - Expect(key).To(BeNil()) - }) - - It("fails on invalid raw", func() { - key, err := User.NewKeyFromBytes([]byte{0, 1, 2, 3}) - Expect(err).To(MatchError("invalid length, expected [32], got [4]")) - Expect(key).To(BeNil()) - }) - }) - - Context("nym generation", func() { - It("fails on nil user secret key", func() { - r1, r2, err := User.MakeNym(nil, issuerPublicKey) - Expect(err).To(MatchError("invalid user secret key, expected *Big, got []")) - Expect(r1).To(BeNil()) - Expect(r2).To(BeNil()) - }) - - It("fails on invalid user secret key", func() { - r1, r2, err := User.MakeNym(issuerPublicKey, issuerPublicKey) - Expect(err).To(MatchError("invalid user secret key, expected *Big, got [*bridge.IssuerPublicKey]")) - Expect(r1).To(BeNil()) - Expect(r2).To(BeNil()) - }) - - It("fails on nil issuer public key", func() { - r1, r2, err := User.MakeNym(userSecretKey, nil) - Expect(err).To(MatchError("invalid issuer public key, expected *IssuerPublicKey, got []")) - Expect(r1).To(BeNil()) - Expect(r2).To(BeNil()) - }) - - It("fails on invalid issuer public key", func() { - r1, r2, err := User.MakeNym(userSecretKey, &mock.IssuerPublicKey{}) - Expect(err).To(MatchError("invalid issuer public key, expected *IssuerPublicKey, got [*mock.IssuerPublicKey]")) - Expect(r1).To(BeNil()) - Expect(r2).To(BeNil()) - }) - - It("panic on rand failure", func() { - User.NewRand = NewRandPanic - r1, r2, err := User.MakeNym(userSecretKey, issuerPublicKey) - Expect(err).To(MatchError("failure [new rand panic]")) - Expect(r1).To(BeNil()) - Expect(r2).To(BeNil()) - }) - }) - - Context("public nym import", func() { - It("success", func() { - npk := handlers.NewNymPublicKey(&bridge.Ecp{ - E: FP256BN.NewECPbigs(FP256BN.NewBIGint(10), FP256BN.NewBIGint(20)), - }) - raw, err := npk.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw).NotTo(BeNil()) - - npk2, err := User.NewPublicNymFromBytes(raw) - Expect(err).NotTo(HaveOccurred()) - raw2, err := npk2.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw2).NotTo(BeNil()) - - Expect(raw2).To(BeEquivalentTo(raw)) - }) - - It("panic on nil raw", func() { - key, err := User.NewPublicNymFromBytes(nil) - Expect(err).To(MatchError("failure [runtime error: index out of range [0] with length 0]")) - Expect(key).To(BeNil()) - }) - - It("failure unmarshalling invalid raw", func() { - key, err := User.NewPublicNymFromBytes([]byte{0, 1, 2, 3}) - Expect(err).To(MatchError("failure [runtime error: index out of range [2] with length 2]")) - Expect(key).To(BeNil()) - }) - }) - }) - - Describe("credential request", func() { - var ( - CredRequest *bridge.CredRequest - IssuerNonce []byte - ) - BeforeEach(func() { - CredRequest = &bridge.CredRequest{NewRand: bridge.NewRandOrPanic} - IssuerNonce = make([]byte, 32) - n, err := rand.Read(IssuerNonce) - Expect(n).To(BeEquivalentTo(32)) - Expect(err).NotTo(HaveOccurred()) - }) - - Context("sign", func() { - It("fail on nil user secret key", func() { - raw, err := CredRequest.Sign(nil, issuerPublicKey, IssuerNonce) - Expect(err).To(MatchError("invalid user secret key, expected *Big, got []")) - Expect(raw).To(BeNil()) - }) - - It("fail on invalid user secret key", func() { - raw, err := CredRequest.Sign(issuerPublicKey, issuerPublicKey, IssuerNonce) - Expect(err).To(MatchError("invalid user secret key, expected *Big, got [*bridge.IssuerPublicKey]")) - Expect(raw).To(BeNil()) - }) - - It("fail on nil issuer public key", func() { - raw, err := CredRequest.Sign(userSecretKey, nil, IssuerNonce) - Expect(err).To(MatchError("invalid issuer public key, expected *IssuerPublicKey, got []")) - Expect(raw).To(BeNil()) - }) - - It("fail on invalid issuer public key", func() { - raw, err := CredRequest.Sign(userSecretKey, &mock.IssuerPublicKey{}, IssuerNonce) - Expect(err).To(MatchError("invalid issuer public key, expected *IssuerPublicKey, got [*mock.IssuerPublicKey]")) - Expect(raw).To(BeNil()) - }) - - It("fail on nil nonce", func() { - raw, err := CredRequest.Sign(userSecretKey, issuerPublicKey, nil) - Expect(err).To(MatchError("invalid issuer nonce, expected length 32, got 0")) - Expect(raw).To(BeNil()) - }) - - It("fail on empty nonce", func() { - raw, err := CredRequest.Sign(userSecretKey, issuerPublicKey, []byte{}) - Expect(err).To(MatchError("invalid issuer nonce, expected length 32, got 0")) - Expect(raw).To(BeNil()) - }) - - It("panic on rand failure", func() { - CredRequest.NewRand = NewRandPanic - raw, err := CredRequest.Sign(userSecretKey, issuerPublicKey, IssuerNonce) - Expect(err).To(MatchError("failure [new rand panic]")) - Expect(raw).To(BeNil()) - }) - }) - - Context("verify", func() { - It("panic on nil credential request", func() { - err := CredRequest.Verify(nil, issuerPublicKey, IssuerNonce) - Expect(err).To(MatchError(ContainSubstring("failure [runtime error: index out of range"))) - }) - - It("fail on invalid credential request", func() { - err := CredRequest.Verify([]byte{0, 1, 2, 3, 4}, issuerPublicKey, IssuerNonce) - Expect(err).To(MatchError("proto: idemix.CredRequest: illegal tag 0 (wire type 0)")) - }) - - It("fail on nil issuer public key", func() { - err := CredRequest.Verify(nil, nil, IssuerNonce) - Expect(err).To(MatchError("invalid issuer public key, expected *IssuerPublicKey, got []")) - }) - - It("fail on invalid issuer public key", func() { - err := CredRequest.Verify(nil, &mock.IssuerPublicKey{}, IssuerNonce) - Expect(err).To(MatchError("invalid issuer public key, expected *IssuerPublicKey, got [*mock.IssuerPublicKey]")) - }) - }) - }) - - Describe("credential", func() { - var Credential handlers.Credential - BeforeEach(func() { - Credential = &bridge.Credential{} - }) - - Context("sign", func() { - It("fail on nil issuer secret key", func() { - raw, err := Credential.Sign(nil, []byte{0, 1, 2, 3, 4}, nil) - Expect(err).To(MatchError("invalid issuer secret key, expected *Big, got []")) - Expect(raw).To(BeNil()) - }) - - It("fail on invalid credential request", func() { - raw, err := Credential.Sign(issuerSecretKey, []byte{0, 1, 2, 3, 4}, nil) - Expect(err).To(MatchError("failed unmarshalling credential request: proto: idemix.CredRequest: illegal tag 0 (wire type 0)")) - Expect(raw).To(BeNil()) - }) - - It("fail on nil inputs", func() { - raw, err := Credential.Sign(issuerSecretKey, nil, nil) - Expect(err).To(MatchError("failure [runtime error: invalid memory address or nil pointer dereference]")) - Expect(raw).To(BeNil()) - }) - - It("fail on invalid attributes", func() { - raw, err := Credential.Sign(issuerSecretKey, nil, []bccsp.IdemixAttribute{ - {Type: 5, Value: nil}, - }) - Expect(err).To(MatchError("attribute type not allowed or supported [5] at position [0]")) - Expect(raw).To(BeNil()) - }) - }) - - Context("verify", func() { - It("fail on nil user secret key", func() { - err := Credential.Verify(nil, nil, nil, nil) - Expect(err).To(MatchError("invalid user secret key, expected *Big, got []")) - }) - - It("fail on invalid user secret key", func() { - err := Credential.Verify(issuerPublicKey, nil, nil, nil) - Expect(err).To(MatchError("invalid user secret key, expected *Big, got [*bridge.IssuerPublicKey]")) - }) - - It("fail on nil issuer public key", func() { - err := Credential.Verify(userSecretKey, nil, nil, nil) - Expect(err).To(MatchError("invalid issuer public key, expected *IssuerPublicKey, got [*bridge.Big]")) - }) - - It("fail on invalid issuer public key", func() { - err := Credential.Verify(userSecretKey, &mock.IssuerPublicKey{}, nil, nil) - Expect(err).To(MatchError("invalid issuer public key, expected *IssuerPublicKey, got [*bridge.Big]")) - }) - - It("fail on invalid attributes", func() { - err := Credential.Verify(userSecretKey, issuerPublicKey, nil, []bccsp.IdemixAttribute{ - {Type: 5, Value: nil}, - }) - Expect(err).To(MatchError("attribute type not allowed or supported [5] at position [0]")) - }) - }) - }) - - Describe("revocation", func() { - var Revocation handlers.Revocation - BeforeEach(func() { - Revocation = &bridge.Revocation{} - }) - - Context("sign", func() { - It("fail on nil inputs", func() { - raw, err := Revocation.Sign(nil, nil, 0, 0) - Expect(err).To(MatchError("failed creating CRI: CreateCRI received nil input")) - Expect(raw).To(BeNil()) - }) - - It("fail on invalid handlers", func() { - raw, err := Revocation.Sign(nil, [][]byte{{0, 2, 3, 4}}, 0, 0) - Expect(err).To(MatchError(ContainSubstring("failure [runtime error: index out of range"))) - Expect(raw).To(BeNil()) - }) - }) - - Context("verify", func() { - It("fail on nil inputs", func() { - err := Revocation.Verify(nil, nil, 0, 0) - Expect(err).To(MatchError("EpochPK invalid: received nil input")) - }) - - It("fail on malformed cri", func() { - err := Revocation.Verify(nil, []byte{0, 1, 2, 3, 4}, 0, 0) - Expect(err).To(MatchError("proto: idemix.CredentialRevocationInformation: illegal tag 0 (wire type 0)")) - }) - }) - }) - - Describe("signature", func() { - var SignatureScheme handlers.SignatureScheme - BeforeEach(func() { - SignatureScheme = &bridge.SignatureScheme{NewRand: bridge.NewRandOrPanic} - }) - - Context("sign", func() { - It("fail on nil user secret key", func() { - signature, err := SignatureScheme.Sign(nil, nil, nil, nil, nil, nil, nil, 0, nil) - Expect(err).To(MatchError("invalid user secret key, expected *Big, got []")) - Expect(signature).To(BeNil()) - }) - - It("fail on nil nym public key", func() { - signature, err := SignatureScheme.Sign(nil, userSecretKey, nil, nil, nil, nil, nil, 0, nil) - Expect(err).To(MatchError("invalid nym public key, expected *Ecp, got []")) - Expect(signature).To(BeNil()) - }) - - It("fail on nil nym secret key", func() { - signature, err := SignatureScheme.Sign(nil, userSecretKey, nymPublicKey, nil, nil, nil, nil, 0, nil) - Expect(err).To(MatchError("invalid nym secret key, expected *Big, got []")) - Expect(signature).To(BeNil()) - }) - - It("fail on nil issuer public key", func() { - signature, err := SignatureScheme.Sign(nil, userSecretKey, nymPublicKey, nymSecretKey, nil, nil, nil, 0, nil) - Expect(err).To(MatchError("invalid issuer public key, expected *IssuerPublicKey, got []")) - Expect(signature).To(BeNil()) - }) - }) - - Context("verify", func() { - It("fail on nil issuer Public key", func() { - err := SignatureScheme.Verify(nil, nil, nil, nil, 0, nil, 0) - Expect(err).To(MatchError("invalid issuer public key, expected *IssuerPublicKey, got []")) - }) - - It("fail on nil signature", func() { - err := SignatureScheme.Verify(issuerPublicKey, nil, nil, nil, 0, nil, 0) - Expect(err).To(MatchError("cannot verify idemix signature: received nil input")) - }) - - It("fail on invalid signature", func() { - err := SignatureScheme.Verify(issuerPublicKey, []byte{0, 1, 2, 3, 4}, nil, nil, 0, nil, 0) - Expect(err).To(MatchError("proto: idemix.Signature: illegal tag 0 (wire type 0)")) - }) - - It("fail on invalid attributes", func() { - err := SignatureScheme.Verify(issuerPublicKey, nil, nil, - []bccsp.IdemixAttribute{{Type: -1}}, 0, nil, 0) - Expect(err).To(MatchError("attribute type not allowed or supported [-1] at position [0]")) - }) - }) - }) - - Describe("nym signature", func() { - var NymSignatureScheme handlers.NymSignatureScheme - BeforeEach(func() { - NymSignatureScheme = &bridge.NymSignatureScheme{NewRand: bridge.NewRandOrPanic} - }) - - Context("sign", func() { - It("fail on nil user secret key", func() { - signature, err := NymSignatureScheme.Sign(nil, nil, nil, nil, nil) - Expect(err).To(MatchError("invalid user secret key, expected *Big, got []")) - Expect(signature).To(BeNil()) - }) - - It("fail on nil nym public key", func() { - signature, err := NymSignatureScheme.Sign(userSecretKey, nil, nil, nil, nil) - Expect(err).To(MatchError("invalid nym public key, expected *Ecp, got []")) - Expect(signature).To(BeNil()) - }) - - It("fail on nil nym secret key", func() { - signature, err := NymSignatureScheme.Sign(userSecretKey, nymPublicKey, nil, nil, nil) - Expect(err).To(MatchError("invalid nym secret key, expected *Big, got []")) - Expect(signature).To(BeNil()) - }) - - It("fail on nil issuer public key", func() { - signature, err := NymSignatureScheme.Sign(userSecretKey, nymPublicKey, nymSecretKey, nil, nil) - Expect(err).To(MatchError("invalid issuer public key, expected *IssuerPublicKey, got []")) - Expect(signature).To(BeNil()) - }) - }) - - Context("verify", func() { - It("fail on nil issuer Public key", func() { - err := NymSignatureScheme.Verify(nil, nil, nil, nil) - Expect(err).To(MatchError("invalid issuer public key, expected *IssuerPublicKey, got []")) - }) - - It("fail on nil nym public key", func() { - err := NymSignatureScheme.Verify(issuerPublicKey, nil, nil, nil) - Expect(err).To(MatchError("invalid nym public key, expected *Ecp, got []")) - }) - - It("panic on nil signature", func() { - err := NymSignatureScheme.Verify(issuerPublicKey, nymPublicKey, nil, nil) - Expect(err).To(MatchError(ContainSubstring("failure [runtime error: index out of range"))) - }) - - It("fail on invalid signature", func() { - err := NymSignatureScheme.Verify(issuerPublicKey, nymPublicKey, []byte{0, 1, 2, 3, 4}, nil) - Expect(err).To(MatchError("error unmarshalling signature: proto: idemix.NymSignature: illegal tag 0 (wire type 0)")) - }) - }) - }) - - Describe("setting up the environment with one issuer and one user", func() { - var ( - Issuer handlers.Issuer - IssuerKeyGen *handlers.IssuerKeyGen - IssuerKey bccsp.Key - IssuerPublicKey bccsp.Key - AttributeNames []string - - User handlers.User - UserKeyGen *handlers.UserKeyGen - UserKey bccsp.Key - NymKeyDerivation *handlers.NymKeyDerivation - NymKey bccsp.Key - NymPublicKey bccsp.Key - - CredRequest handlers.CredRequest - CredentialRequestSigner *handlers.CredentialRequestSigner - CredentialRequestVerifier *handlers.CredentialRequestVerifier - IssuerNonce []byte - credRequest []byte - - Credential handlers.Credential - CredentialSigner *handlers.CredentialSigner - CredentialVerifier *handlers.CredentialVerifier - credential []byte - - Revocation handlers.Revocation - RevocationKeyGen *handlers.RevocationKeyGen - RevocationKey bccsp.Key - RevocationPublicKey bccsp.Key - CriSigner *handlers.CriSigner - CriVerifier *handlers.CriVerifier - cri []byte - ) - - BeforeEach(func() { - // Issuer - var err error - Issuer = &bridge.Issuer{NewRand: bridge.NewRandOrPanic} - IssuerKeyGen = &handlers.IssuerKeyGen{Issuer: Issuer} - AttributeNames = []string{"Attr1", "Attr2", "Attr3", "Attr4", "Attr5"} - IssuerKey, err = IssuerKeyGen.KeyGen(&bccsp.IdemixIssuerKeyGenOpts{Temporary: true, AttributeNames: AttributeNames}) - Expect(err).NotTo(HaveOccurred()) - IssuerPublicKey, err = IssuerKey.PublicKey() - Expect(err).NotTo(HaveOccurred()) - - // User - User = &bridge.User{NewRand: bridge.NewRandOrPanic} - UserKeyGen = &handlers.UserKeyGen{User: User} - UserKey, err = UserKeyGen.KeyGen(&bccsp.IdemixUserSecretKeyGenOpts{}) - Expect(err).NotTo(HaveOccurred()) - - // User Nym Key - NymKeyDerivation = &handlers.NymKeyDerivation{User: User} - NymKey, err = NymKeyDerivation.KeyDeriv(UserKey, &bccsp.IdemixNymKeyDerivationOpts{IssuerPK: IssuerPublicKey}) - Expect(err).NotTo(HaveOccurred()) - NymPublicKey, err = NymKey.PublicKey() - Expect(err).NotTo(HaveOccurred()) - - // Credential Request for User - IssuerNonce = make([]byte, 32) - n, err := rand.Read(IssuerNonce) - Expect(n).To(BeEquivalentTo(32)) - Expect(err).NotTo(HaveOccurred()) - - CredRequest = &bridge.CredRequest{NewRand: bridge.NewRandOrPanic} - CredentialRequestSigner = &handlers.CredentialRequestSigner{CredRequest: CredRequest} - CredentialRequestVerifier = &handlers.CredentialRequestVerifier{CredRequest: CredRequest} - credRequest, err = CredentialRequestSigner.Sign( - UserKey, - nil, - &bccsp.IdemixCredentialRequestSignerOpts{IssuerPK: IssuerPublicKey, IssuerNonce: IssuerNonce}, - ) - Expect(err).NotTo(HaveOccurred()) - - // Credential - Credential = &bridge.Credential{NewRand: bridge.NewRandOrPanic} - CredentialSigner = &handlers.CredentialSigner{Credential: Credential} - CredentialVerifier = &handlers.CredentialVerifier{Credential: Credential} - credential, err = CredentialSigner.Sign( - IssuerKey, - credRequest, - &bccsp.IdemixCredentialSignerOpts{ - Attributes: []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0}}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1}}, - {Type: bccsp.IdemixIntAttribute, Value: 1}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1, 2}}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1, 2, 3}}, - }, - }, - ) - Expect(err).NotTo(HaveOccurred()) - - // Revocation - Revocation = &bridge.Revocation{} - RevocationKeyGen = &handlers.RevocationKeyGen{Revocation: Revocation} - RevocationKey, err = RevocationKeyGen.KeyGen(&bccsp.IdemixRevocationKeyGenOpts{}) - Expect(err).NotTo(HaveOccurred()) - RevocationPublicKey, err = RevocationKey.PublicKey() - Expect(err).NotTo(HaveOccurred()) - - // CRI - CriSigner = &handlers.CriSigner{Revocation: Revocation} - CriVerifier = &handlers.CriVerifier{Revocation: Revocation} - cri, err = CriSigner.Sign( - RevocationKey, - nil, - &bccsp.IdemixCRISignerOpts{}, - ) - Expect(err).NotTo(HaveOccurred()) - }) - - It("the environment is properly set", func() { - // Verify CredRequest - valid, err := CredentialRequestVerifier.Verify( - IssuerPublicKey, - credRequest, - nil, - &bccsp.IdemixCredentialRequestSignerOpts{IssuerNonce: IssuerNonce}, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(valid).To(BeTrue()) - - // Verify Credential - valid, err = CredentialVerifier.Verify( - UserKey, - credential, - nil, - &bccsp.IdemixCredentialSignerOpts{ - IssuerPK: IssuerPublicKey, - Attributes: []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0}}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1}}, - {Type: bccsp.IdemixIntAttribute, Value: 1}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1, 2}}, - {Type: bccsp.IdemixHiddenAttribute}, - }, - }, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(valid).To(BeTrue()) - - // Verify CRI - valid, err = CriVerifier.Verify( - RevocationPublicKey, - cri, - nil, - &bccsp.IdemixCRISignerOpts{}, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(valid).To(BeTrue()) - }) - - Context("the environment is not valid with the respect to different parameters", func() { - It("invalid credential request nonce", func() { - valid, err := CredentialRequestVerifier.Verify( - IssuerPublicKey, - credRequest, - nil, - &bccsp.IdemixCredentialRequestSignerOpts{IssuerNonce: []byte("pine-apple-pine-apple-pine-apple")}, - ) - Expect(err).To(MatchError(fmt.Sprintf("invalid nonce, expected [%v], got [%v]", []byte("pine-apple-pine-apple-pine-apple"), IssuerNonce))) - Expect(valid).NotTo(BeTrue()) - }) - - It("invalid credential request nonce, too short", func() { - valid, err := CredentialRequestVerifier.Verify( - IssuerPublicKey, - credRequest, - nil, - &bccsp.IdemixCredentialRequestSignerOpts{IssuerNonce: []byte("pin-apple-pine-apple-pineapple")}, - ) - Expect(err).To(MatchError("invalid issuer nonce, expected length 32, got 30")) - Expect(valid).NotTo(BeTrue()) - }) - - It("invalid credential request", func() { - if credRequest[4] == 0 { - credRequest[4] = 1 - } else { - credRequest[4] = 0 - } - valid, err := CredentialRequestVerifier.Verify( - IssuerPublicKey, - credRequest, - nil, - &bccsp.IdemixCredentialRequestSignerOpts{IssuerNonce: IssuerNonce}, - ) - Expect(err).To(MatchError("zero knowledge proof is invalid")) - Expect(valid).NotTo(BeTrue()) - }) - - It("invalid credential request in verifying credential", func() { - if credRequest[4] == 0 { - credRequest[4] = 1 - } else { - credRequest[4] = 0 - } - credential, err := CredentialSigner.Sign( - IssuerKey, - credRequest, - &bccsp.IdemixCredentialSignerOpts{ - Attributes: []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0}}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1}}, - {Type: bccsp.IdemixIntAttribute, Value: 1}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1, 2}}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1, 2, 3}}, - }, - }, - ) - Expect(err).To(MatchError("failed creating new credential: zero knowledge proof is invalid")) - Expect(credential).To(BeNil()) - }) - - It("nil credential", func() { - // Verify Credential - valid, err := CredentialVerifier.Verify( - UserKey, - nil, - nil, - &bccsp.IdemixCredentialSignerOpts{ - IssuerPK: IssuerPublicKey, - Attributes: []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixBytesAttribute, Value: []byte{1}}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1}}, - {Type: bccsp.IdemixIntAttribute, Value: 1}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1, 2}}, - {Type: bccsp.IdemixHiddenAttribute}, - }, - }, - ) - Expect(err).To(MatchError("invalid signature, it must not be empty")) - Expect(valid).To(BeFalse()) - }) - - It("malformed credential", func() { - // Verify Credential - valid, err := CredentialVerifier.Verify( - UserKey, - []byte{0, 1, 2, 3, 4}, - nil, - &bccsp.IdemixCredentialSignerOpts{ - IssuerPK: IssuerPublicKey, - Attributes: []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixBytesAttribute, Value: []byte{1}}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1}}, - {Type: bccsp.IdemixIntAttribute, Value: 1}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1, 2}}, - {Type: bccsp.IdemixHiddenAttribute}, - }, - }, - ) - Expect(err).To(MatchError("proto: idemix.Credential: illegal tag 0 (wire type 0)")) - Expect(valid).To(BeFalse()) - }) - - It("invalid credential", func() { - // Invalidate credential by changing it in one position - if credential[4] == 0 { - credential[4] = 1 - } else { - credential[4] = 0 - } - - // Verify Credential - valid, err := CredentialVerifier.Verify( - UserKey, - credential, - nil, - &bccsp.IdemixCredentialSignerOpts{ - IssuerPK: IssuerPublicKey, - Attributes: []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0}}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1}}, - {Type: bccsp.IdemixIntAttribute, Value: 1}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1, 2}}, - {Type: bccsp.IdemixHiddenAttribute}, - }, - }, - ) - Expect(err).To(MatchError("credential is not cryptographically valid")) - Expect(valid).To(BeFalse()) - }) - - It("invalid byte array in credential", func() { - // Verify Credential - valid, err := CredentialVerifier.Verify( - UserKey, - credential, - nil, - &bccsp.IdemixCredentialSignerOpts{ - IssuerPK: IssuerPublicKey, - Attributes: []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixBytesAttribute, Value: []byte{1}}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1}}, - {Type: bccsp.IdemixIntAttribute, Value: 1}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1, 2}}, - {Type: bccsp.IdemixHiddenAttribute}, - }, - }, - ) - Expect(err).To(MatchError("credential does not contain the correct attribute value at position [0]")) - Expect(valid).To(BeFalse()) - }) - - It("invalid int in credential", func() { - // Verify Credential - valid, err := CredentialVerifier.Verify( - UserKey, - credential, - nil, - &bccsp.IdemixCredentialSignerOpts{ - IssuerPK: IssuerPublicKey, - Attributes: []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0}}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1}}, - {Type: bccsp.IdemixIntAttribute, Value: 2}, - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0, 1, 2}}, - {Type: bccsp.IdemixHiddenAttribute}, - }, - }, - ) - Expect(err).To(MatchError("credential does not contain the correct attribute value at position [2]")) - Expect(valid).To(BeFalse()) - }) - - It("invalid cri", func() { - // Verify CRI - cri[8] = 0 - valid, err := CriVerifier.Verify( - RevocationPublicKey, - cri, - nil, - &bccsp.IdemixCRISignerOpts{}, - ) - Expect(err).To(MatchError("EpochPKSig invalid")) - Expect(valid).To(BeFalse()) - }) - }) - - Describe("the environment is not properly set", func() { - Describe("issuer", func() { - Context("duplicate attribute", func() { - It("returns an error", func() { - AttributeNames = []string{"A", "A"} - IssuerKey, err := IssuerKeyGen.KeyGen(&bccsp.IdemixIssuerKeyGenOpts{Temporary: true, AttributeNames: AttributeNames}) - Expect(err).To(MatchError("attribute A appears multiple times in AttributeNames")) - Expect(IssuerKey).To(BeNil()) - }) - }) - }) - }) - - Describe("producing and verifying idemix signature with different sets of attributes", func() { - var ( - SignatureScheme handlers.SignatureScheme - Signer *handlers.Signer - Verifier *handlers.Verifier - digest []byte - signature []byte - - SignAttributes []bccsp.IdemixAttribute - VerifyAttributes []bccsp.IdemixAttribute - RhIndex int - Epoch int - errMessage string - validity bool - ) - - BeforeEach(func() { - SignatureScheme = &bridge.SignatureScheme{NewRand: bridge.NewRandOrPanic} - Signer = &handlers.Signer{SignatureScheme: SignatureScheme} - Verifier = &handlers.Verifier{SignatureScheme: SignatureScheme} - - digest = []byte("a digest") - RhIndex = 4 - Epoch = 0 - errMessage = "" - }) - - It("the signature with no disclosed attributes is valid", func() { - validity = true - SignAttributes = []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - } - VerifyAttributes = SignAttributes - }) - - It("the signature with disclosed attributes is valid", func() { - validity = true - SignAttributes = []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0}}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixIntAttribute, Value: 1}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - } - VerifyAttributes = SignAttributes - }) - - It("the signature with different disclosed attributes is not valid", func() { - validity = false - errMessage = "signature invalid: zero-knowledge proof is invalid" - SignAttributes = []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixBytesAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixIntAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - } - VerifyAttributes = []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixBytesAttribute, Value: []byte{1}}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixIntAttribute, Value: 1}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - } - }) - - It("the signature with different disclosed attributes is not valid", func() { - validity = false - errMessage = "signature invalid: zero-knowledge proof is invalid" - SignAttributes = []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixBytesAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixIntAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - } - VerifyAttributes = []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixBytesAttribute, Value: []byte{0}}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixIntAttribute, Value: 10}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - } - }) - - AfterEach(func() { - var err error - signature, err = Signer.Sign( - UserKey, - digest, - &bccsp.IdemixSignerOpts{ - Credential: credential, - Nym: NymKey, - IssuerPK: IssuerPublicKey, - Attributes: SignAttributes, - RhIndex: RhIndex, - Epoch: Epoch, - CRI: cri, - }, - ) - Expect(err).NotTo(HaveOccurred()) - - valid, err := Verifier.Verify( - IssuerPublicKey, - signature, - digest, - &bccsp.IdemixSignerOpts{ - RevocationPublicKey: RevocationPublicKey, - Attributes: VerifyAttributes, - RhIndex: RhIndex, - Epoch: Epoch, - }, - ) - - if errMessage == "" { - Expect(err).NotTo(HaveOccurred()) - } else { - Expect(err).To(MatchError(errMessage)) - } - Expect(valid).To(BeEquivalentTo(validity)) - }) - }) - - Context("producing an idemix signature", func() { - var ( - SignatureScheme handlers.SignatureScheme - Signer *handlers.Signer - SignAttributes []bccsp.IdemixAttribute - Verifier *handlers.Verifier - ) - - BeforeEach(func() { - SignatureScheme = &bridge.SignatureScheme{NewRand: bridge.NewRandOrPanic} - Signer = &handlers.Signer{SignatureScheme: SignatureScheme} - SignAttributes = []bccsp.IdemixAttribute{ - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - {Type: bccsp.IdemixHiddenAttribute}, - } - Verifier = &handlers.Verifier{SignatureScheme: SignatureScheme} - }) - - It("fails when the credential is malformed", func() { - signature, err := Signer.Sign( - UserKey, - []byte("a message"), - &bccsp.IdemixSignerOpts{ - Credential: []byte{0, 1, 2, 3}, - Nym: NymKey, - IssuerPK: IssuerPublicKey, - Attributes: SignAttributes, - RhIndex: 4, - Epoch: 0, - CRI: cri, - }, - ) - Expect(err).To(MatchError("failed unmarshalling credential: proto: idemix.Credential: illegal tag 0 (wire type 0)")) - Expect(signature).To(BeNil()) - }) - - It("fails when the cri is malformed", func() { - signature, err := Signer.Sign( - UserKey, - []byte("a message"), - &bccsp.IdemixSignerOpts{ - Credential: credential, - Nym: NymKey, - IssuerPK: IssuerPublicKey, - Attributes: SignAttributes, - RhIndex: 4, - Epoch: 0, - CRI: []byte{0, 1, 2, 3, 4}, - }, - ) - Expect(err).To(MatchError("failed unmarshalling credential revocation information: proto: idemix.CredentialRevocationInformation: illegal tag 0 (wire type 0)")) - Expect(signature).To(BeNil()) - }) - - It("fails when invalid rhIndex is passed", func() { - signature, err := Signer.Sign( - UserKey, - []byte("a message"), - &bccsp.IdemixSignerOpts{ - Credential: credential, - Nym: NymKey, - IssuerPK: IssuerPublicKey, - Attributes: SignAttributes, - RhIndex: 5, - Epoch: 0, - CRI: cri, - }, - ) - Expect(err).To(MatchError("failed creating new signature: cannot create idemix signature: received invalid input")) - Expect(signature).To(BeNil()) - }) - - It("fails when the credential is invalid", func() { - if credential[4] != 0 { - credential[4] = 0 - } else { - credential[4] = 1 - } - - signature, err := Signer.Sign( - UserKey, - []byte("a message"), - &bccsp.IdemixSignerOpts{ - Credential: credential, - Nym: NymKey, - IssuerPK: IssuerPublicKey, - Attributes: SignAttributes, - RhIndex: 4, - Epoch: 0, - CRI: cri, - }, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(signature).NotTo(BeNil()) - - valid, err := Verifier.Verify( - IssuerPublicKey, - signature, - []byte("a message"), - &bccsp.IdemixSignerOpts{ - RevocationPublicKey: RevocationPublicKey, - Attributes: SignAttributes, - RhIndex: 0, - Epoch: 0, - }, - ) - Expect(err).To(MatchError("signature invalid: APrime = 1")) - Expect(valid).To(BeFalse()) - }) - - It("fails when the credential is nil", func() { - credential[4] = 0 - signature, err := Signer.Sign( - UserKey, - []byte("a message"), - &bccsp.IdemixSignerOpts{ - Credential: nil, - Nym: NymKey, - IssuerPK: IssuerPublicKey, - Attributes: SignAttributes, - RhIndex: 4, - Epoch: 0, - CRI: cri, - }, - ) - Expect(err).To(MatchError(ContainSubstring("failure [runtime error: index out of range"))) - Expect(signature).To(BeNil()) - }) - }) - - Describe("producing an idemix nym signature", func() { - var ( - NymSignatureScheme *bridge.NymSignatureScheme - NymSigner *handlers.NymSigner - NymVerifier *handlers.NymVerifier - digest []byte - signature []byte - ) - - BeforeEach(func() { - var err error - NymSignatureScheme = &bridge.NymSignatureScheme{NewRand: bridge.NewRandOrPanic} - NymSigner = &handlers.NymSigner{NymSignatureScheme: NymSignatureScheme} - NymVerifier = &handlers.NymVerifier{NymSignatureScheme: NymSignatureScheme} - - digest = []byte("a digest") - - signature, err = NymSigner.Sign( - UserKey, - digest, - &bccsp.IdemixNymSignerOpts{ - Nym: NymKey, - IssuerPK: IssuerPublicKey, - }, - ) - Expect(err).NotTo(HaveOccurred()) - }) - - It("the signature is valid", func() { - valid, err := NymVerifier.Verify( - NymPublicKey, - signature, - digest, - &bccsp.IdemixNymSignerOpts{ - IssuerPK: IssuerPublicKey, - }, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(valid).To(BeTrue()) - }) - - Context("the signature is malformed", func() { - var nymSignature *cryptolib.NymSignature - - BeforeEach(func() { - nymSignature = &cryptolib.NymSignature{} - err := proto.Unmarshal(signature, nymSignature) - Expect(err).NotTo(HaveOccurred()) - }) - - marshalAndVerify := func(nymSignature *cryptolib.NymSignature) (bool, error) { - signature, err := proto.Marshal(nymSignature) - Expect(err).NotTo(HaveOccurred()) - - return NymVerifier.Verify( - NymPublicKey, - signature, - digest, - &bccsp.IdemixNymSignerOpts{ - IssuerPK: IssuerPublicKey, - }, - ) - } - - Context("cause nonce does not encode a proper Big", func() { - It("returns an error", func() { - nymSignature.Nonce = []byte{0, 1, 2, 3, 4} - valid, err := marshalAndVerify(nymSignature) - Expect(valid).To(BeFalse()) - Expect(err).To(MatchError(ContainSubstring("failure [runtime error: index out of range"))) - }) - }) - - Context("cause nonce is nil", func() { - It("returns an error", func() { - nymSignature.Nonce = nil - valid, err := marshalAndVerify(nymSignature) - Expect(valid).To(BeFalse()) - Expect(err).To(MatchError(ContainSubstring("failure [runtime error: index out of range"))) - }) - }) - - Context("cause nonce encode a different thing", func() { - It("returns an error", func() { - var err error - nymSignature.Nonce, err = (&bridge.Big{E: FP256BN.NewBIGint(1)}).Bytes() - Expect(err).NotTo(HaveOccurred()) - - valid, err := marshalAndVerify(nymSignature) - Expect(valid).To(BeFalse()) - Expect(err).To(MatchError("pseudonym signature invalid: zero-knowledge proof is invalid")) - }) - }) - - Context("cause ProofC is not encoded properly", func() { - It("returns an error", func() { - nymSignature.ProofC = []byte{0, 1, 2, 3, 4} - - valid, err := marshalAndVerify(nymSignature) - Expect(valid).To(BeFalse()) - Expect(err).To(MatchError(ContainSubstring("failure [runtime error: index out of range"))) - }) - }) - - Context("cause ProofC is nil", func() { - It("returns an error", func() { - nymSignature.ProofC = nil - - valid, err := marshalAndVerify(nymSignature) - Expect(valid).To(BeFalse()) - Expect(err).To(MatchError(ContainSubstring("failure [runtime error: index out of range"))) - }) - }) - - Context("cause ProofC encode a different thing", func() { - It("returns an error", func() { - var err error - nymSignature.ProofC, err = (&bridge.Big{E: FP256BN.NewBIGint(1)}).Bytes() - Expect(err).NotTo(HaveOccurred()) - - valid, err := marshalAndVerify(nymSignature) - Expect(valid).To(BeFalse()) - Expect(err).To(MatchError("pseudonym signature invalid: zero-knowledge proof is invalid")) - }) - }) - - Context("cause ProofSRNym is not encoded properly", func() { - It("returns an error", func() { - nymSignature.ProofSRNym = []byte{0, 1, 2, 3, 4} - - valid, err := marshalAndVerify(nymSignature) - Expect(valid).To(BeFalse()) - Expect(err).To(MatchError(ContainSubstring("failure [runtime error: index out of range"))) - }) - }) - - Context("cause ProofSRNym is nil", func() { - It("returns an error", func() { - nymSignature.ProofSRNym = nil - valid, err := marshalAndVerify(nymSignature) - Expect(valid).To(BeFalse()) - Expect(err).To(MatchError(ContainSubstring("failure [runtime error: index out of range"))) - }) - }) - - Context("cause ProofSRNym encode a different thing", func() { - It("returns an error", func() { - var err error - nymSignature.ProofSRNym, err = (&bridge.Big{E: FP256BN.NewBIGint(1)}).Bytes() - Expect(err).NotTo(HaveOccurred()) - - valid, err := marshalAndVerify(nymSignature) - Expect(valid).To(BeFalse()) - Expect(err).To(MatchError("pseudonym signature invalid: zero-knowledge proof is invalid")) - }) - }) - - Context("cause ProofSSk is not encoded properly", func() { - It("returns an error", func() { - nymSignature.ProofSSk = []byte{0, 1, 2, 3, 4} - - valid, err := marshalAndVerify(nymSignature) - Expect(valid).To(BeFalse()) - Expect(err).To(MatchError(ContainSubstring("failure [runtime error: index out of range"))) - }) - }) - - Context("cause ProofSSk is nil", func() { - It("returns an error", func() { - nymSignature.ProofSSk = nil - - valid, err := marshalAndVerify(nymSignature) - Expect(valid).To(BeFalse()) - Expect(err).To(MatchError(ContainSubstring("failure [runtime error: index out of range"))) - }) - }) - - Context("cause ProofSSk encode a different thing", func() { - It("returns an error", func() { - var err error - nymSignature.ProofSSk, err = (&bridge.Big{E: FP256BN.NewBIGint(1)}).Bytes() - Expect(err).NotTo(HaveOccurred()) - - valid, err := marshalAndVerify(nymSignature) - Expect(valid).To(BeFalse()) - Expect(err).To(MatchError("pseudonym signature invalid: zero-knowledge proof is invalid")) - }) - }) - }) - }) - - Context("importing nym key", func() { - var NymPublicKeyImporter *handlers.NymPublicKeyImporter - - BeforeEach(func() { - NymPublicKeyImporter = &handlers.NymPublicKeyImporter{User: User} - }) - - It("nym key import is successful", func() { - raw, err := NymPublicKey.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw).NotTo(BeEmpty()) - - k, err := NymPublicKeyImporter.KeyImport(raw, nil) - Expect(err).NotTo(HaveOccurred()) - raw2, err := k.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw2).To(BeEquivalentTo(raw)) - }) - }) - }) -}) diff --git a/bccsp/idemix/bridge/math.go b/bccsp/idemix/bridge/math.go deleted file mode 100644 index f04d65c8d5e..00000000000 --- a/bccsp/idemix/bridge/math.go +++ /dev/null @@ -1,33 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ -package bridge - -import ( - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" - "github.com/hyperledger/fabric/idemix" -) - -// Big encapsulate an amcl big integer -type Big struct { - E *FP256BN.BIG -} - -func (b *Big) Bytes() ([]byte, error) { - return idemix.BigToBytes(b.E), nil -} - -// Ecp encapsulate an amcl elliptic curve point -type Ecp struct { - E *FP256BN.ECP -} - -func (o *Ecp) Bytes() ([]byte, error) { - var res []byte - res = append(res, idemix.BigToBytes(o.E.GetX())...) - res = append(res, idemix.BigToBytes(o.E.GetY())...) - - return res, nil -} diff --git a/bccsp/idemix/bridge/rand.go b/bccsp/idemix/bridge/rand.go deleted file mode 100644 index 629f416ed83..00000000000 --- a/bccsp/idemix/bridge/rand.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ -package bridge - -import ( - "github.com/hyperledger/fabric-amcl/amcl" - cryptolib "github.com/hyperledger/fabric/idemix" -) - -// NewRandOrPanic return a new amcl PRG or panic -func NewRandOrPanic() *amcl.RAND { - rng, err := cryptolib.GetRand() - if err != nil { - panic(err) - } - return rng -} diff --git a/bccsp/idemix/bridge/revocation.go b/bccsp/idemix/bridge/revocation.go deleted file mode 100644 index 83d73b137cd..00000000000 --- a/bccsp/idemix/bridge/revocation.go +++ /dev/null @@ -1,69 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ -package bridge - -import ( - "crypto/ecdsa" - - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" - "github.com/hyperledger/fabric/bccsp" - cryptolib "github.com/hyperledger/fabric/idemix" - "github.com/pkg/errors" -) - -// Revocation encapsulates the idemix algorithms for revocation -type Revocation struct{} - -// NewKey generate a new revocation key-pair. -func (*Revocation) NewKey() (*ecdsa.PrivateKey, error) { - return cryptolib.GenerateLongTermRevocationKey() -} - -// Sign generates a new CRI with the respect to the passed unrevoked handles, epoch, and revocation algorithm. -func (*Revocation) Sign(key *ecdsa.PrivateKey, unrevokedHandles [][]byte, epoch int, alg bccsp.RevocationAlgorithm) (res []byte, err error) { - defer func() { - if r := recover(); r != nil { - res = nil - err = errors.Errorf("failure [%s]", r) - } - }() - - handles := make([]*FP256BN.BIG, len(unrevokedHandles)) - for i := 0; i < len(unrevokedHandles); i++ { - handles[i] = FP256BN.FromBytes(unrevokedHandles[i]) - } - cri, err := cryptolib.CreateCRI(key, handles, epoch, cryptolib.RevocationAlgorithm(alg), NewRandOrPanic()) - if err != nil { - return nil, errors.WithMessage(err, "failed creating CRI") - } - - return proto.Marshal(cri) -} - -// Verify checks that the passed serialised CRI (criRaw) is valid with the respect to the passed revocation public key, -// epoch, and revocation algorithm. -func (*Revocation) Verify(pk *ecdsa.PublicKey, criRaw []byte, epoch int, alg bccsp.RevocationAlgorithm) (err error) { - defer func() { - if r := recover(); r != nil { - err = errors.Errorf("failure [%s]", r) - } - }() - - cri := &cryptolib.CredentialRevocationInformation{} - err = proto.Unmarshal(criRaw, cri) - if err != nil { - return err - } - - return cryptolib.VerifyEpochPK( - pk, - cri.EpochPk, - cri.EpochPkSig, - int(cri.Epoch), - cryptolib.RevocationAlgorithm(cri.RevocationAlg), - ) -} diff --git a/bccsp/idemix/bridge/signaturescheme.go b/bccsp/idemix/bridge/signaturescheme.go deleted file mode 100644 index 7ccd1a13e54..00000000000 --- a/bccsp/idemix/bridge/signaturescheme.go +++ /dev/null @@ -1,142 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ -package bridge - -import ( - "crypto/ecdsa" - - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-amcl/amcl" - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" - "github.com/hyperledger/fabric/bccsp" - "github.com/hyperledger/fabric/bccsp/idemix/handlers" - cryptolib "github.com/hyperledger/fabric/idemix" - "github.com/pkg/errors" -) - -// SignatureScheme encapsulates the idemix algorithms to sign and verify using an idemix credential. -type SignatureScheme struct { - NewRand func() *amcl.RAND -} - -// Sign produces an idemix-signature with the respect to the passed serialised credential (cred), -// user secret key (sk), pseudonym public key (Nym) and secret key (RNym), issuer public key (ipk), -// and attributes to be disclosed. -func (s *SignatureScheme) Sign(cred []byte, sk handlers.Big, Nym handlers.Ecp, RNym handlers.Big, ipk handlers.IssuerPublicKey, attributes []bccsp.IdemixAttribute, - msg []byte, rhIndex int, criRaw []byte) (res []byte, err error) { - defer func() { - if r := recover(); r != nil { - res = nil - err = errors.Errorf("failure [%s]", r) - } - }() - - isk, ok := sk.(*Big) - if !ok { - return nil, errors.Errorf("invalid user secret key, expected *Big, got [%T]", sk) - } - inym, ok := Nym.(*Ecp) - if !ok { - return nil, errors.Errorf("invalid nym public key, expected *Ecp, got [%T]", Nym) - } - irnym, ok := RNym.(*Big) - if !ok { - return nil, errors.Errorf("invalid nym secret key, expected *Big, got [%T]", RNym) - } - iipk, ok := ipk.(*IssuerPublicKey) - if !ok { - return nil, errors.Errorf("invalid issuer public key, expected *IssuerPublicKey, got [%T]", ipk) - } - - credential := &cryptolib.Credential{} - err = proto.Unmarshal(cred, credential) - if err != nil { - return nil, errors.Wrap(err, "failed unmarshalling credential") - } - - cri := &cryptolib.CredentialRevocationInformation{} - err = proto.Unmarshal(criRaw, cri) - if err != nil { - return nil, errors.Wrap(err, "failed unmarshalling credential revocation information") - } - - disclosure := make([]byte, len(attributes)) - for i := 0; i < len(attributes); i++ { - if attributes[i].Type == bccsp.IdemixHiddenAttribute { - disclosure[i] = 0 - } else { - disclosure[i] = 1 - } - } - - sig, err := cryptolib.NewSignature( - credential, - isk.E, - inym.E, - irnym.E, - iipk.PK, - disclosure, - msg, - rhIndex, - cri, - s.NewRand()) - if err != nil { - return nil, errors.WithMessage(err, "failed creating new signature") - } - - return proto.Marshal(sig) -} - -// Verify checks that an idemix signature is valid with the respect to the passed issuer public key, digest, attributes, -// revocation index (rhIndex), revocation public key, and epoch. -func (*SignatureScheme) Verify(ipk handlers.IssuerPublicKey, signature, digest []byte, attributes []bccsp.IdemixAttribute, rhIndex int, revocationPublicKey *ecdsa.PublicKey, epoch int) (err error) { - defer func() { - if r := recover(); r != nil { - err = errors.Errorf("failure [%s]", r) - } - }() - - iipk, ok := ipk.(*IssuerPublicKey) - if !ok { - return errors.Errorf("invalid issuer public key, expected *IssuerPublicKey, got [%T]", ipk) - } - - sig := &cryptolib.Signature{} - err = proto.Unmarshal(signature, sig) - if err != nil { - return err - } - - disclosure := make([]byte, len(attributes)) - attrValues := make([]*FP256BN.BIG, len(attributes)) - for i := 0; i < len(attributes); i++ { - switch attributes[i].Type { - case bccsp.IdemixHiddenAttribute: - disclosure[i] = 0 - attrValues[i] = nil - case bccsp.IdemixBytesAttribute: - disclosure[i] = 1 - attrValues[i] = cryptolib.HashModOrder(attributes[i].Value.([]byte)) - case bccsp.IdemixIntAttribute: - disclosure[i] = 1 - attrValues[i] = FP256BN.NewBIGint(attributes[i].Value.(int)) - default: - err = errors.Errorf("attribute type not allowed or supported [%v] at position [%d]", attributes[i].Type, i) - } - } - if err != nil { - return - } - - return sig.Ver( - disclosure, - iipk.PK, - digest, - attrValues, - rhIndex, - revocationPublicKey, - epoch) -} diff --git a/bccsp/idemix/bridge/user.go b/bccsp/idemix/bridge/user.go deleted file mode 100644 index d37cf27efc8..00000000000 --- a/bccsp/idemix/bridge/user.go +++ /dev/null @@ -1,86 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ -package bridge - -import ( - "github.com/hyperledger/fabric-amcl/amcl" - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" - "github.com/hyperledger/fabric/bccsp/idemix/handlers" - cryptolib "github.com/hyperledger/fabric/idemix" - "github.com/pkg/errors" -) - -// User encapsulates the idemix algorithms to generate user secret keys and pseudonym. -type User struct { - NewRand func() *amcl.RAND -} - -// NewKey generates an idemix user secret key -func (u *User) NewKey() (res handlers.Big, err error) { - defer func() { - if r := recover(); r != nil { - res = nil - err = errors.Errorf("failure [%s]", r) - } - }() - - res = &Big{E: cryptolib.RandModOrder(u.NewRand())} - - return -} - -func (*User) NewKeyFromBytes(raw []byte) (res handlers.Big, err error) { - if len(raw) != int(FP256BN.MODBYTES) { - return nil, errors.Errorf("invalid length, expected [%d], got [%d]", FP256BN.MODBYTES, len(raw)) - } - - res = &Big{E: FP256BN.FromBytes(raw)} - - return -} - -// MakeNym generates a new pseudonym key-pair derived from the passed user secret key (sk) and issuer public key (ipk) -func (u *User) MakeNym(sk handlers.Big, ipk handlers.IssuerPublicKey) (r1 handlers.Ecp, r2 handlers.Big, err error) { - defer func() { - if r := recover(); r != nil { - r1 = nil - r2 = nil - err = errors.Errorf("failure [%s]", r) - } - }() - - isk, ok := sk.(*Big) - if !ok { - return nil, nil, errors.Errorf("invalid user secret key, expected *Big, got [%T]", sk) - } - iipk, ok := ipk.(*IssuerPublicKey) - if !ok { - return nil, nil, errors.Errorf("invalid issuer public key, expected *IssuerPublicKey, got [%T]", ipk) - } - - ecp, big := cryptolib.MakeNym(isk.E, iipk.PK, u.NewRand()) - - r1 = &Ecp{E: ecp} - r2 = &Big{E: big} - - return -} - -func (*User) NewPublicNymFromBytes(raw []byte) (res handlers.Ecp, err error) { - defer func() { - if r := recover(); r != nil { - res = nil - err = errors.Errorf("failure [%s]", r) - } - }() - - // raw is the concatenation of two big integers - lHalve := len(raw) / 2 - - res = &Ecp{E: FP256BN.NewECPbigs(FP256BN.FromBytes(raw[:lHalve]), FP256BN.FromBytes(raw[lHalve:]))} - - return -} diff --git a/bccsp/idemix/handlers/cred_test.go b/bccsp/idemix/handlers/cred_test.go deleted file mode 100644 index cf2a8af7ec7..00000000000 --- a/bccsp/idemix/handlers/cred_test.go +++ /dev/null @@ -1,481 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ -package handlers_test - -import ( - "crypto/rand" - - "github.com/hyperledger/fabric/bccsp" - "github.com/hyperledger/fabric/bccsp/idemix/handlers" - "github.com/hyperledger/fabric/bccsp/idemix/handlers/mock" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/pkg/errors" -) - -var _ = Describe("Credential Request", func() { - Describe("when creating a credential request", func() { - var ( - CredentialRequestSigner *handlers.CredentialRequestSigner - fakeCredRequest *mock.CredRequest - ) - - BeforeEach(func() { - fakeCredRequest = &mock.CredRequest{} - CredentialRequestSigner = &handlers.CredentialRequestSigner{CredRequest: fakeCredRequest} - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - var fakeSignature []byte - BeforeEach(func() { - fakeSignature = []byte("fake signature") - fakeCredRequest.SignReturns(fakeSignature, nil) - }) - - It("returns no error and a signature", func() { - signature, err := CredentialRequestSigner.Sign( - handlers.NewUserSecretKey(nil, false), - nil, - &bccsp.IdemixCredentialRequestSignerOpts{IssuerPK: handlers.NewIssuerPublicKey(nil)}, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(signature).To(BeEquivalentTo(fakeSignature)) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - fakeCredRequest.SignReturns(nil, errors.New("sign error")) - }) - - It("returns an error", func() { - signature, err := CredentialRequestSigner.Sign( - handlers.NewUserSecretKey(nil, false), - nil, - &bccsp.IdemixCredentialRequestSignerOpts{IssuerPK: handlers.NewIssuerPublicKey(nil)}, - ) - Expect(err).To(MatchError("sign error")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the options are not well formed", func() { - Context("and the user secret key is nil", func() { - It("returns error", func() { - signature, err := CredentialRequestSigner.Sign( - nil, - nil, - &bccsp.IdemixCredentialRequestSignerOpts{IssuerPK: handlers.NewIssuerPublicKey(nil)}, - ) - Expect(err).To(MatchError("invalid key, expected *userSecretKey")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the user secret key is not of type *userSecretKey", func() { - It("returns error", func() { - signature, err := CredentialRequestSigner.Sign( - handlers.NewIssuerPublicKey(nil), - nil, - &bccsp.IdemixCredentialRequestSignerOpts{IssuerPK: handlers.NewIssuerPublicKey(nil)}, - ) - Expect(err).To(MatchError("invalid key, expected *userSecretKey")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the option is missing", func() { - It("returns error", func() { - signature, err := CredentialRequestSigner.Sign( - handlers.NewUserSecretKey(nil, false), - nil, - nil, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixCredentialRequestSignerOpts")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the option is not of type *bccsp.IdemixCredentialRequestSignerOpts", func() { - It("returns error", func() { - signature, err := CredentialRequestSigner.Sign( - handlers.NewUserSecretKey(nil, false), - nil, - &bccsp.IdemixSignerOpts{}, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixCredentialRequestSignerOpts")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the issuer public key is missing", func() { - It("returns error", func() { - signature, err := CredentialRequestSigner.Sign( - handlers.NewUserSecretKey(nil, false), - nil, - &bccsp.IdemixCredentialRequestSignerOpts{IssuerPK: nil}, - ) - Expect(err).To(MatchError("invalid options, missing issuer public key")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the issuer public key is not of type *issuerPublicKey", func() { - It("returns error", func() { - signature, err := CredentialRequestSigner.Sign( - handlers.NewUserSecretKey(nil, false), - nil, - &bccsp.IdemixCredentialRequestSignerOpts{IssuerPK: handlers.NewUserSecretKey(nil, false)}, - ) - Expect(err).To(MatchError("invalid options, expected IssuerPK as *issuerPublicKey")) - Expect(signature).To(BeNil()) - }) - }) - }) - }) - - Describe("when verifying a credential request", func() { - var ( - CredentialRequestVerifier *handlers.CredentialRequestVerifier - IssuerNonce []byte - fakeCredRequest *mock.CredRequest - ) - - BeforeEach(func() { - fakeCredRequest = &mock.CredRequest{} - IssuerNonce = make([]byte, 32) - n, err := rand.Read(IssuerNonce) - Expect(n).To(BeEquivalentTo(32)) - Expect(err).NotTo(HaveOccurred()) - CredentialRequestVerifier = &handlers.CredentialRequestVerifier{CredRequest: fakeCredRequest} - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - BeforeEach(func() { - fakeCredRequest.VerifyReturns(nil) - }) - - It("returns no error and valid signature", func() { - valid, err := CredentialRequestVerifier.Verify( - handlers.NewIssuerPublicKey(nil), - []byte("fake signature"), - nil, - &bccsp.IdemixCredentialRequestSignerOpts{IssuerNonce: IssuerNonce}, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(valid).To(BeTrue()) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - fakeCredRequest.VerifyReturns(errors.New("verify error")) - }) - - It("returns an error", func() { - valid, err := CredentialRequestVerifier.Verify( - handlers.NewIssuerPublicKey(nil), - []byte("fake signature"), - nil, - &bccsp.IdemixCredentialRequestSignerOpts{IssuerNonce: IssuerNonce}, - ) - Expect(err).To(MatchError("verify error")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the parameters are not well formed", func() { - Context("and the issuer public key is nil", func() { - It("returns error", func() { - valid, err := CredentialRequestVerifier.Verify( - nil, - []byte("fake signature"), - nil, - &bccsp.IdemixCredentialRequestSignerOpts{IssuerNonce: IssuerNonce}, - ) - Expect(err).To(MatchError("invalid key, expected *issuerPublicKey")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the issuer public key is not of type *issuerPublicKey", func() { - It("returns error", func() { - valid, err := CredentialRequestVerifier.Verify( - handlers.NewUserSecretKey(nil, false), - []byte("fake signature"), - nil, - &bccsp.IdemixCredentialRequestSignerOpts{IssuerNonce: IssuerNonce}, - ) - Expect(err).To(MatchError("invalid key, expected *issuerPublicKey")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and nil options are passed", func() { - It("returns error", func() { - valid, err := CredentialRequestVerifier.Verify( - handlers.NewIssuerPublicKey(nil), - []byte("fake signature"), - nil, - nil, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixCredentialRequestSignerOpts")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and non-valid options are passed", func() { - It("returns error", func() { - valid, err := CredentialRequestVerifier.Verify( - handlers.NewIssuerPublicKey(nil), - []byte("fake signature"), - nil, - &bccsp.IdemixCRISignerOpts{}, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixCredentialRequestSignerOpts")) - Expect(valid).To(BeFalse()) - }) - }) - }) - }) -}) - -var _ = Describe("Credential", func() { - Describe("when creating a credential", func() { - var ( - CredentialSigner *handlers.CredentialSigner - fakeCredential *mock.Credential - ) - - BeforeEach(func() { - fakeCredential = &mock.Credential{} - CredentialSigner = &handlers.CredentialSigner{Credential: fakeCredential} - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - var fakeSignature []byte - BeforeEach(func() { - fakeSignature = []byte("fake signature") - fakeCredential.SignReturns(fakeSignature, nil) - }) - - It("returns no error and a signature", func() { - signature, err := CredentialSigner.Sign( - handlers.NewIssuerSecretKey(nil, false), - nil, - &bccsp.IdemixCredentialSignerOpts{}, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(signature).To(BeEquivalentTo(fakeSignature)) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - fakeCredential.SignReturns(nil, errors.New("sign error")) - }) - - It("returns an error", func() { - signature, err := CredentialSigner.Sign( - handlers.NewIssuerSecretKey(nil, false), - nil, - &bccsp.IdemixCredentialSignerOpts{}, - ) - Expect(err).To(MatchError("sign error")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the parameters are not well formed", func() { - Context("and the issuer secret key is nil", func() { - It("returns error", func() { - signature, err := CredentialSigner.Sign( - nil, - nil, - &bccsp.IdemixCredentialSignerOpts{}, - ) - Expect(err).To(MatchError("invalid key, expected *issuerSecretKey")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the user secret key is not of type *issuerSecretKey", func() { - It("returns error", func() { - signature, err := CredentialSigner.Sign( - handlers.NewIssuerPublicKey(nil), - nil, - &bccsp.IdemixCredentialSignerOpts{}, - ) - Expect(err).To(MatchError("invalid key, expected *issuerSecretKey")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the opt is nil", func() { - It("returns error", func() { - signature, err := CredentialSigner.Sign( - handlers.NewIssuerSecretKey(nil, false), - nil, - nil, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixCredentialSignerOpts")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the opt is not of type *IdemixCredentialSignerOpts", func() { - It("returns error", func() { - signature, err := CredentialSigner.Sign( - handlers.NewIssuerSecretKey(nil, false), - nil, - &bccsp.IdemixCredentialRequestSignerOpts{}, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixCredentialSignerOpts")) - Expect(signature).To(BeNil()) - }) - }) - }) - }) - - Describe("when verifying a credential", func() { - var ( - CredentialVerifier *handlers.CredentialVerifier - fakeCredential *mock.Credential - ) - - BeforeEach(func() { - fakeCredential = &mock.Credential{} - CredentialVerifier = &handlers.CredentialVerifier{Credential: fakeCredential} - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - BeforeEach(func() { - fakeCredential.VerifyReturns(nil) - }) - - It("returns no error and valid signature", func() { - valid, err := CredentialVerifier.Verify( - handlers.NewUserSecretKey(nil, false), - []byte("fake signature"), - nil, - &bccsp.IdemixCredentialSignerOpts{IssuerPK: handlers.NewIssuerPublicKey(nil)}, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(valid).To(BeTrue()) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - fakeCredential.VerifyReturns(errors.New("verify error")) - }) - - It("returns an error", func() { - valid, err := CredentialVerifier.Verify( - handlers.NewUserSecretKey(nil, false), - []byte("fake signature"), - nil, - &bccsp.IdemixCredentialSignerOpts{IssuerPK: handlers.NewIssuerPublicKey(nil)}, - ) - Expect(err).To(MatchError("verify error")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the parameters are not well formed", func() { - Context("and the user secret key is nil", func() { - It("returns error", func() { - valid, err := CredentialVerifier.Verify( - nil, - []byte("fake signature"), - nil, - &bccsp.IdemixCredentialSignerOpts{IssuerPK: handlers.NewIssuerPublicKey(nil)}, - ) - Expect(err).To(MatchError("invalid key, expected *userSecretKey")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the user secret key is not of type *userSecretKey", func() { - It("returns error", func() { - valid, err := CredentialVerifier.Verify( - handlers.NewIssuerPublicKey(nil), - []byte("fake signature"), - nil, - &bccsp.IdemixCredentialSignerOpts{IssuerPK: handlers.NewIssuerPublicKey(nil)}, - ) - Expect(err).To(MatchError("invalid key, expected *userSecretKey")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the signature is empty", func() { - It("returns error", func() { - valid, err := CredentialVerifier.Verify( - handlers.NewUserSecretKey(nil, false), - nil, - nil, - &bccsp.IdemixCredentialSignerOpts{IssuerPK: handlers.NewIssuerPublicKey(nil)}, - ) - Expect(err).To(MatchError("invalid signature, it must not be empty")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the option is empty", func() { - It("returns error", func() { - valid, err := CredentialVerifier.Verify( - handlers.NewUserSecretKey(nil, false), - []byte("fake signature"), - nil, - nil, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixCredentialSignerOpts")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the option is not of type *IdemixCredentialSignerOpts", func() { - It("returns error", func() { - valid, err := CredentialVerifier.Verify( - handlers.NewUserSecretKey(nil, false), - []byte("fake signature"), - nil, - &bccsp.IdemixCredentialRequestSignerOpts{}, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixCredentialSignerOpts")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the option's issuer public key is empty", func() { - It("returns error", func() { - valid, err := CredentialVerifier.Verify( - handlers.NewUserSecretKey(nil, false), - []byte("fake signature"), - nil, - &bccsp.IdemixCredentialSignerOpts{}, - ) - Expect(err).To(MatchError("invalid options, missing issuer public key")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the option's issuer public key is not of type *issuerPublicKey", func() { - It("returns error", func() { - valid, err := CredentialVerifier.Verify( - handlers.NewUserSecretKey(nil, false), - []byte("fake signature"), - nil, - &bccsp.IdemixCredentialSignerOpts{IssuerPK: handlers.NewUserSecretKey(nil, false)}, - ) - Expect(err).To(MatchError("invalid issuer public key, expected *issuerPublicKey")) - Expect(valid).To(BeFalse()) - }) - }) - }) - }) -}) diff --git a/bccsp/idemix/handlers/idemix_suite_test.go b/bccsp/idemix/handlers/idemix_suite_test.go deleted file mode 100644 index b0baff5a2f9..00000000000 --- a/bccsp/idemix/handlers/idemix_suite_test.go +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ -package handlers_test - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -//go:generate counterfeiter -o mock/issuer.go -fake-name Issuer . Issuer -//go:generate counterfeiter -o mock/issuer_secret_key.go -fake-name IssuerSecretKey . IssuerSecretKey -//go:generate counterfeiter -o mock/issuer_public_key.go -fake-name IssuerPublicKey . IssuerPublicKey -//go:generate counterfeiter -o mock/user.go -fake-name User . User -//go:generate counterfeiter -o mock/big.go -fake-name Big . Big -//go:generate counterfeiter -o mock/ecp.go -fake-name Ecp . Ecp -//go:generate counterfeiter -o mock/credrequest.go -fake-name CredRequest . CredRequest -//go:generate counterfeiter -o mock/credential.go -fake-name Credential . Credential -//go:generate counterfeiter -o mock/revocation.go -fake-name Revocation . Revocation -//go:generate counterfeiter -o mock/signature_scheme.go -fake-name SignatureScheme . SignatureScheme -//go:generate counterfeiter -o mock/nymsignature_scheme.go -fake-name NymSignatureScheme . NymSignatureScheme - -func TestPlain(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Plain Suite") -} diff --git a/bccsp/idemix/handlers/issuer_test.go b/bccsp/idemix/handlers/issuer_test.go deleted file mode 100644 index cc978074be7..00000000000 --- a/bccsp/idemix/handlers/issuer_test.go +++ /dev/null @@ -1,254 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ -package handlers_test - -import ( - "github.com/hyperledger/fabric/bccsp/idemix/handlers" - - "github.com/hyperledger/fabric/bccsp" - "github.com/hyperledger/fabric/bccsp/idemix/handlers/mock" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/pkg/errors" -) - -var _ = Describe("Issuer", func() { - Describe("when creating an issuer key-pair", func() { - var ( - IssuerKeyGen *handlers.IssuerKeyGen - - fakeIssuer *mock.Issuer - IssuerSecretKey bccsp.Key - ) - - BeforeEach(func() { - fakeIssuer = &mock.Issuer{} - - IssuerKeyGen = &handlers.IssuerKeyGen{} - IssuerKeyGen.Issuer = fakeIssuer - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - var ( - sk bccsp.Key - fakeIssuerSecretKey *mock.IssuerSecretKey - SKI []byte - pkBytes []byte - ) - BeforeEach(func() { - SKI = []byte("a fake SKI") - pkBytes = []byte("a fake public") - - fakeIssuerPublicKey := &mock.IssuerPublicKey{} - fakeIssuerPublicKey.BytesReturns(pkBytes, nil) - fakeIssuerPublicKey.HashReturns(SKI) - - fakeIssuerSecretKey = &mock.IssuerSecretKey{} - fakeIssuerSecretKey.PublicReturns(fakeIssuerPublicKey) - fakeIssuerSecretKey.BytesReturns([]byte("private"), nil) - - fakeIssuer.NewKeyReturns(fakeIssuerSecretKey, nil) - - IssuerSecretKey = handlers.NewIssuerSecretKey(fakeIssuerSecretKey, false) - }) - - AfterEach(func() { - Expect(sk.Private()).To(BeTrue()) - Expect(sk.Symmetric()).To(BeFalse()) - Expect(sk.SKI()).NotTo(BeNil()) - Expect(sk.SKI()).To(BeEquivalentTo(SKI)) - - pk, err := sk.PublicKey() - Expect(err).NotTo(HaveOccurred()) - - Expect(pk.Private()).To(BeFalse()) - Expect(pk.Symmetric()).To(BeFalse()) - Expect(pk.SKI()).NotTo(BeNil()) - Expect(pk.SKI()).To(BeEquivalentTo(SKI)) - raw, err := pk.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw).NotTo(BeNil()) - Expect(raw).To(BeEquivalentTo(pkBytes)) - - pk2, err := pk.PublicKey() - Expect(err).NotTo(HaveOccurred()) - Expect(pk).To(BeEquivalentTo(pk2)) - }) - - Context("and the secret key is exportable", func() { - BeforeEach(func() { - IssuerKeyGen.Exportable = true - IssuerSecretKey = handlers.NewIssuerSecretKey(fakeIssuerSecretKey, true) - }) - - It("returns no error and a key", func() { - var err error - sk, err = IssuerKeyGen.KeyGen(&bccsp.IdemixIssuerKeyGenOpts{}) - Expect(err).NotTo(HaveOccurred()) - Expect(sk).To(BeEquivalentTo(IssuerSecretKey)) - - raw, err := sk.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw).NotTo(BeNil()) - Expect(raw).To(BeEquivalentTo([]byte("private"))) - }) - }) - - Context("and the secret key is not exportable", func() { - BeforeEach(func() { - IssuerKeyGen.Exportable = false - IssuerSecretKey = handlers.NewIssuerSecretKey(fakeIssuerSecretKey, false) - }) - - It("returns no error and a key", func() { - sk, err := IssuerKeyGen.KeyGen(&bccsp.IdemixIssuerKeyGenOpts{}) - Expect(err).NotTo(HaveOccurred()) - Expect(sk).To(BeEquivalentTo(IssuerSecretKey)) - - raw, err := sk.Bytes() - Expect(err).To(MatchError("not exportable")) - Expect(raw).To(BeNil()) - }) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - fakeIssuer.NewKeyReturns(nil, errors.New("new-key error")) - }) - - It("returns an error", func() { - keyPair, err := IssuerKeyGen.KeyGen(&bccsp.IdemixIssuerKeyGenOpts{}) - Expect(err).To(MatchError("new-key error")) - Expect(keyPair).To(BeNil()) - }) - }) - - Context("and the options are not well formed", func() { - Context("and the option is nil", func() { - It("returns error", func() { - sk, err := IssuerKeyGen.KeyGen(nil) - Expect(err).To(MatchError("invalid options, expected *bccsp.IdemixIssuerKeyGenOpts")) - Expect(sk).To(BeNil()) - }) - }) - - Context("and the option is not of type *bccsp.IdemixIssuerKeyGenOpts", func() { - It("returns error", func() { - sk, err := IssuerKeyGen.KeyGen(&bccsp.AESKeyGenOpts{}) - Expect(err).To(MatchError("invalid options, expected *bccsp.IdemixIssuerKeyGenOpts")) - Expect(sk).To(BeNil()) - }) - }) - }) - }) - - Describe("when importing an issuer public key", func() { - var ( - IssuerPublicKeyImporter *handlers.IssuerPublicKeyImporter - - fakeIssuer *mock.Issuer - IssuerPublicKey bccsp.Key - ) - - BeforeEach(func() { - fakeIssuer = &mock.Issuer{} - - IssuerPublicKeyImporter = &handlers.IssuerPublicKeyImporter{} - IssuerPublicKeyImporter.Issuer = fakeIssuer - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - var ( - pk bccsp.Key - fakeIssuerPublicKey *mock.IssuerPublicKey - SKI []byte - pkBytes []byte - fakeRaw []byte - ) - - BeforeEach(func() { - fakeRaw = []byte("a fake raw") - SKI = []byte("a fake SKI") - pkBytes = []byte("a fake public") - - fakeIssuerPublicKey = &mock.IssuerPublicKey{} - fakeIssuerPublicKey.BytesReturns(pkBytes, nil) - fakeIssuerPublicKey.HashReturns(SKI) - - fakeIssuer.NewPublicKeyFromBytesReturns(fakeIssuerPublicKey, nil) - }) - - Context("and the secret key is exportable", func() { - BeforeEach(func() { - IssuerPublicKey = handlers.NewIssuerPublicKey(fakeIssuerPublicKey) - }) - - It("returns no error and a key", func() { - var err error - pk, err = IssuerPublicKeyImporter.KeyImport(fakeRaw, &bccsp.IdemixIssuerPublicKeyImportOpts{}) - Expect(err).NotTo(HaveOccurred()) - Expect(pk).To(BeEquivalentTo(IssuerPublicKey)) - - raw, err := pk.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw).NotTo(BeNil()) - Expect(raw).To(BeEquivalentTo(pkBytes)) - - pk, err := pk.PublicKey() - Expect(err).NotTo(HaveOccurred()) - Expect(pk).To(BeEquivalentTo(IssuerPublicKey)) - }) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - fakeIssuer.NewPublicKeyFromBytesReturns(nil, errors.New("new-key error")) - }) - - It("returns an error", func() { - pk, err := IssuerPublicKeyImporter.KeyImport([]byte{1, 2, 3}, &bccsp.IdemixIssuerPublicKeyImportOpts{}) - Expect(err).To(MatchError("new-key error")) - Expect(pk).To(BeNil()) - }) - }) - - Context("and the arguments are not well formed", func() { - Context("and the raw is nil", func() { - It("returns error", func() { - pk, err := IssuerPublicKeyImporter.KeyImport(nil, &bccsp.IdemixIssuerPublicKeyImportOpts{}) - Expect(err).To(MatchError("invalid raw, expected byte array")) - Expect(pk).To(BeNil()) - }) - }) - - Context("and the raw is empty", func() { - It("returns error", func() { - pk, err := IssuerPublicKeyImporter.KeyImport([]byte{}, &bccsp.IdemixIssuerPublicKeyImportOpts{}) - Expect(err).To(MatchError("invalid raw, it must not be nil")) - Expect(pk).To(BeNil()) - }) - }) - - Context("and the option is nil", func() { - It("returns error", func() { - pk, err := IssuerPublicKeyImporter.KeyImport([]byte{1, 2, 3}, nil) - Expect(err).To(MatchError("invalid options, expected *bccsp.IdemixIssuerPublicKeyImportOpts")) - Expect(pk).To(BeNil()) - }) - }) - - Context("and the option is not of type *bccsp.IdemixIssuerPublicKeyImportOpts", func() { - It("returns error", func() { - pk, err := IssuerPublicKeyImporter.KeyImport([]byte{1, 2, 3}, &bccsp.IdemixNymPublicKeyImportOpts{}) - Expect(err).To(MatchError("invalid options, expected *bccsp.IdemixIssuerPublicKeyImportOpts")) - Expect(pk).To(BeNil()) - }) - }) - }) - }) -}) diff --git a/bccsp/idemix/handlers/mock/big.go b/bccsp/idemix/handlers/mock/big.go deleted file mode 100644 index a8bf7cd552d..00000000000 --- a/bccsp/idemix/handlers/mock/big.go +++ /dev/null @@ -1,106 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package mock - -import ( - "sync" - - "github.com/hyperledger/fabric/bccsp/idemix/handlers" -) - -type Big struct { - BytesStub func() ([]byte, error) - bytesMutex sync.RWMutex - bytesArgsForCall []struct { - } - bytesReturns struct { - result1 []byte - result2 error - } - bytesReturnsOnCall map[int]struct { - result1 []byte - result2 error - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *Big) Bytes() ([]byte, error) { - fake.bytesMutex.Lock() - ret, specificReturn := fake.bytesReturnsOnCall[len(fake.bytesArgsForCall)] - fake.bytesArgsForCall = append(fake.bytesArgsForCall, struct { - }{}) - fake.recordInvocation("Bytes", []interface{}{}) - fake.bytesMutex.Unlock() - if fake.BytesStub != nil { - return fake.BytesStub() - } - if specificReturn { - return ret.result1, ret.result2 - } - fakeReturns := fake.bytesReturns - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *Big) BytesCallCount() int { - fake.bytesMutex.RLock() - defer fake.bytesMutex.RUnlock() - return len(fake.bytesArgsForCall) -} - -func (fake *Big) BytesCalls(stub func() ([]byte, error)) { - fake.bytesMutex.Lock() - defer fake.bytesMutex.Unlock() - fake.BytesStub = stub -} - -func (fake *Big) BytesReturns(result1 []byte, result2 error) { - fake.bytesMutex.Lock() - defer fake.bytesMutex.Unlock() - fake.BytesStub = nil - fake.bytesReturns = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *Big) BytesReturnsOnCall(i int, result1 []byte, result2 error) { - fake.bytesMutex.Lock() - defer fake.bytesMutex.Unlock() - fake.BytesStub = nil - if fake.bytesReturnsOnCall == nil { - fake.bytesReturnsOnCall = make(map[int]struct { - result1 []byte - result2 error - }) - } - fake.bytesReturnsOnCall[i] = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *Big) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.bytesMutex.RLock() - defer fake.bytesMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *Big) recordInvocation(key string, args []interface{}) { - fake.invocationsMutex.Lock() - defer fake.invocationsMutex.Unlock() - if fake.invocations == nil { - fake.invocations = map[string][][]interface{}{} - } - if fake.invocations[key] == nil { - fake.invocations[key] = [][]interface{}{} - } - fake.invocations[key] = append(fake.invocations[key], args) -} - -var _ handlers.Big = new(Big) diff --git a/bccsp/idemix/handlers/mock/credential.go b/bccsp/idemix/handlers/mock/credential.go deleted file mode 100644 index aaf5873c48c..00000000000 --- a/bccsp/idemix/handlers/mock/credential.go +++ /dev/null @@ -1,219 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package mock - -import ( - "sync" - - "github.com/hyperledger/fabric/bccsp" - "github.com/hyperledger/fabric/bccsp/idemix/handlers" -) - -type Credential struct { - SignStub func(handlers.IssuerSecretKey, []byte, []bccsp.IdemixAttribute) ([]byte, error) - signMutex sync.RWMutex - signArgsForCall []struct { - arg1 handlers.IssuerSecretKey - arg2 []byte - arg3 []bccsp.IdemixAttribute - } - signReturns struct { - result1 []byte - result2 error - } - signReturnsOnCall map[int]struct { - result1 []byte - result2 error - } - VerifyStub func(handlers.Big, handlers.IssuerPublicKey, []byte, []bccsp.IdemixAttribute) error - verifyMutex sync.RWMutex - verifyArgsForCall []struct { - arg1 handlers.Big - arg2 handlers.IssuerPublicKey - arg3 []byte - arg4 []bccsp.IdemixAttribute - } - verifyReturns struct { - result1 error - } - verifyReturnsOnCall map[int]struct { - result1 error - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *Credential) Sign(arg1 handlers.IssuerSecretKey, arg2 []byte, arg3 []bccsp.IdemixAttribute) ([]byte, error) { - var arg2Copy []byte - if arg2 != nil { - arg2Copy = make([]byte, len(arg2)) - copy(arg2Copy, arg2) - } - var arg3Copy []bccsp.IdemixAttribute - if arg3 != nil { - arg3Copy = make([]bccsp.IdemixAttribute, len(arg3)) - copy(arg3Copy, arg3) - } - fake.signMutex.Lock() - ret, specificReturn := fake.signReturnsOnCall[len(fake.signArgsForCall)] - fake.signArgsForCall = append(fake.signArgsForCall, struct { - arg1 handlers.IssuerSecretKey - arg2 []byte - arg3 []bccsp.IdemixAttribute - }{arg1, arg2Copy, arg3Copy}) - fake.recordInvocation("Sign", []interface{}{arg1, arg2Copy, arg3Copy}) - fake.signMutex.Unlock() - if fake.SignStub != nil { - return fake.SignStub(arg1, arg2, arg3) - } - if specificReturn { - return ret.result1, ret.result2 - } - fakeReturns := fake.signReturns - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *Credential) SignCallCount() int { - fake.signMutex.RLock() - defer fake.signMutex.RUnlock() - return len(fake.signArgsForCall) -} - -func (fake *Credential) SignCalls(stub func(handlers.IssuerSecretKey, []byte, []bccsp.IdemixAttribute) ([]byte, error)) { - fake.signMutex.Lock() - defer fake.signMutex.Unlock() - fake.SignStub = stub -} - -func (fake *Credential) SignArgsForCall(i int) (handlers.IssuerSecretKey, []byte, []bccsp.IdemixAttribute) { - fake.signMutex.RLock() - defer fake.signMutex.RUnlock() - argsForCall := fake.signArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *Credential) SignReturns(result1 []byte, result2 error) { - fake.signMutex.Lock() - defer fake.signMutex.Unlock() - fake.SignStub = nil - fake.signReturns = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *Credential) SignReturnsOnCall(i int, result1 []byte, result2 error) { - fake.signMutex.Lock() - defer fake.signMutex.Unlock() - fake.SignStub = nil - if fake.signReturnsOnCall == nil { - fake.signReturnsOnCall = make(map[int]struct { - result1 []byte - result2 error - }) - } - fake.signReturnsOnCall[i] = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *Credential) Verify(arg1 handlers.Big, arg2 handlers.IssuerPublicKey, arg3 []byte, arg4 []bccsp.IdemixAttribute) error { - var arg3Copy []byte - if arg3 != nil { - arg3Copy = make([]byte, len(arg3)) - copy(arg3Copy, arg3) - } - var arg4Copy []bccsp.IdemixAttribute - if arg4 != nil { - arg4Copy = make([]bccsp.IdemixAttribute, len(arg4)) - copy(arg4Copy, arg4) - } - fake.verifyMutex.Lock() - ret, specificReturn := fake.verifyReturnsOnCall[len(fake.verifyArgsForCall)] - fake.verifyArgsForCall = append(fake.verifyArgsForCall, struct { - arg1 handlers.Big - arg2 handlers.IssuerPublicKey - arg3 []byte - arg4 []bccsp.IdemixAttribute - }{arg1, arg2, arg3Copy, arg4Copy}) - fake.recordInvocation("Verify", []interface{}{arg1, arg2, arg3Copy, arg4Copy}) - fake.verifyMutex.Unlock() - if fake.VerifyStub != nil { - return fake.VerifyStub(arg1, arg2, arg3, arg4) - } - if specificReturn { - return ret.result1 - } - fakeReturns := fake.verifyReturns - return fakeReturns.result1 -} - -func (fake *Credential) VerifyCallCount() int { - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - return len(fake.verifyArgsForCall) -} - -func (fake *Credential) VerifyCalls(stub func(handlers.Big, handlers.IssuerPublicKey, []byte, []bccsp.IdemixAttribute) error) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = stub -} - -func (fake *Credential) VerifyArgsForCall(i int) (handlers.Big, handlers.IssuerPublicKey, []byte, []bccsp.IdemixAttribute) { - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - argsForCall := fake.verifyArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 -} - -func (fake *Credential) VerifyReturns(result1 error) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = nil - fake.verifyReturns = struct { - result1 error - }{result1} -} - -func (fake *Credential) VerifyReturnsOnCall(i int, result1 error) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = nil - if fake.verifyReturnsOnCall == nil { - fake.verifyReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.verifyReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *Credential) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.signMutex.RLock() - defer fake.signMutex.RUnlock() - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *Credential) recordInvocation(key string, args []interface{}) { - fake.invocationsMutex.Lock() - defer fake.invocationsMutex.Unlock() - if fake.invocations == nil { - fake.invocations = map[string][][]interface{}{} - } - if fake.invocations[key] == nil { - fake.invocations[key] = [][]interface{}{} - } - fake.invocations[key] = append(fake.invocations[key], args) -} - -var _ handlers.Credential = new(Credential) diff --git a/bccsp/idemix/handlers/mock/credrequest.go b/bccsp/idemix/handlers/mock/credrequest.go deleted file mode 100644 index eab3274ed8d..00000000000 --- a/bccsp/idemix/handlers/mock/credrequest.go +++ /dev/null @@ -1,211 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package mock - -import ( - "sync" - - "github.com/hyperledger/fabric/bccsp/idemix/handlers" -) - -type CredRequest struct { - SignStub func(handlers.Big, handlers.IssuerPublicKey, []byte) ([]byte, error) - signMutex sync.RWMutex - signArgsForCall []struct { - arg1 handlers.Big - arg2 handlers.IssuerPublicKey - arg3 []byte - } - signReturns struct { - result1 []byte - result2 error - } - signReturnsOnCall map[int]struct { - result1 []byte - result2 error - } - VerifyStub func([]byte, handlers.IssuerPublicKey, []byte) error - verifyMutex sync.RWMutex - verifyArgsForCall []struct { - arg1 []byte - arg2 handlers.IssuerPublicKey - arg3 []byte - } - verifyReturns struct { - result1 error - } - verifyReturnsOnCall map[int]struct { - result1 error - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *CredRequest) Sign(arg1 handlers.Big, arg2 handlers.IssuerPublicKey, arg3 []byte) ([]byte, error) { - var arg3Copy []byte - if arg3 != nil { - arg3Copy = make([]byte, len(arg3)) - copy(arg3Copy, arg3) - } - fake.signMutex.Lock() - ret, specificReturn := fake.signReturnsOnCall[len(fake.signArgsForCall)] - fake.signArgsForCall = append(fake.signArgsForCall, struct { - arg1 handlers.Big - arg2 handlers.IssuerPublicKey - arg3 []byte - }{arg1, arg2, arg3Copy}) - fake.recordInvocation("Sign", []interface{}{arg1, arg2, arg3Copy}) - fake.signMutex.Unlock() - if fake.SignStub != nil { - return fake.SignStub(arg1, arg2, arg3) - } - if specificReturn { - return ret.result1, ret.result2 - } - fakeReturns := fake.signReturns - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *CredRequest) SignCallCount() int { - fake.signMutex.RLock() - defer fake.signMutex.RUnlock() - return len(fake.signArgsForCall) -} - -func (fake *CredRequest) SignCalls(stub func(handlers.Big, handlers.IssuerPublicKey, []byte) ([]byte, error)) { - fake.signMutex.Lock() - defer fake.signMutex.Unlock() - fake.SignStub = stub -} - -func (fake *CredRequest) SignArgsForCall(i int) (handlers.Big, handlers.IssuerPublicKey, []byte) { - fake.signMutex.RLock() - defer fake.signMutex.RUnlock() - argsForCall := fake.signArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *CredRequest) SignReturns(result1 []byte, result2 error) { - fake.signMutex.Lock() - defer fake.signMutex.Unlock() - fake.SignStub = nil - fake.signReturns = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *CredRequest) SignReturnsOnCall(i int, result1 []byte, result2 error) { - fake.signMutex.Lock() - defer fake.signMutex.Unlock() - fake.SignStub = nil - if fake.signReturnsOnCall == nil { - fake.signReturnsOnCall = make(map[int]struct { - result1 []byte - result2 error - }) - } - fake.signReturnsOnCall[i] = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *CredRequest) Verify(arg1 []byte, arg2 handlers.IssuerPublicKey, arg3 []byte) error { - var arg1Copy []byte - if arg1 != nil { - arg1Copy = make([]byte, len(arg1)) - copy(arg1Copy, arg1) - } - var arg3Copy []byte - if arg3 != nil { - arg3Copy = make([]byte, len(arg3)) - copy(arg3Copy, arg3) - } - fake.verifyMutex.Lock() - ret, specificReturn := fake.verifyReturnsOnCall[len(fake.verifyArgsForCall)] - fake.verifyArgsForCall = append(fake.verifyArgsForCall, struct { - arg1 []byte - arg2 handlers.IssuerPublicKey - arg3 []byte - }{arg1Copy, arg2, arg3Copy}) - fake.recordInvocation("Verify", []interface{}{arg1Copy, arg2, arg3Copy}) - fake.verifyMutex.Unlock() - if fake.VerifyStub != nil { - return fake.VerifyStub(arg1, arg2, arg3) - } - if specificReturn { - return ret.result1 - } - fakeReturns := fake.verifyReturns - return fakeReturns.result1 -} - -func (fake *CredRequest) VerifyCallCount() int { - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - return len(fake.verifyArgsForCall) -} - -func (fake *CredRequest) VerifyCalls(stub func([]byte, handlers.IssuerPublicKey, []byte) error) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = stub -} - -func (fake *CredRequest) VerifyArgsForCall(i int) ([]byte, handlers.IssuerPublicKey, []byte) { - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - argsForCall := fake.verifyArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *CredRequest) VerifyReturns(result1 error) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = nil - fake.verifyReturns = struct { - result1 error - }{result1} -} - -func (fake *CredRequest) VerifyReturnsOnCall(i int, result1 error) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = nil - if fake.verifyReturnsOnCall == nil { - fake.verifyReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.verifyReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *CredRequest) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.signMutex.RLock() - defer fake.signMutex.RUnlock() - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *CredRequest) recordInvocation(key string, args []interface{}) { - fake.invocationsMutex.Lock() - defer fake.invocationsMutex.Unlock() - if fake.invocations == nil { - fake.invocations = map[string][][]interface{}{} - } - if fake.invocations[key] == nil { - fake.invocations[key] = [][]interface{}{} - } - fake.invocations[key] = append(fake.invocations[key], args) -} - -var _ handlers.CredRequest = new(CredRequest) diff --git a/bccsp/idemix/handlers/mock/ecp.go b/bccsp/idemix/handlers/mock/ecp.go deleted file mode 100644 index aaab2010e45..00000000000 --- a/bccsp/idemix/handlers/mock/ecp.go +++ /dev/null @@ -1,106 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package mock - -import ( - "sync" - - "github.com/hyperledger/fabric/bccsp/idemix/handlers" -) - -type Ecp struct { - BytesStub func() ([]byte, error) - bytesMutex sync.RWMutex - bytesArgsForCall []struct { - } - bytesReturns struct { - result1 []byte - result2 error - } - bytesReturnsOnCall map[int]struct { - result1 []byte - result2 error - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *Ecp) Bytes() ([]byte, error) { - fake.bytesMutex.Lock() - ret, specificReturn := fake.bytesReturnsOnCall[len(fake.bytesArgsForCall)] - fake.bytesArgsForCall = append(fake.bytesArgsForCall, struct { - }{}) - fake.recordInvocation("Bytes", []interface{}{}) - fake.bytesMutex.Unlock() - if fake.BytesStub != nil { - return fake.BytesStub() - } - if specificReturn { - return ret.result1, ret.result2 - } - fakeReturns := fake.bytesReturns - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *Ecp) BytesCallCount() int { - fake.bytesMutex.RLock() - defer fake.bytesMutex.RUnlock() - return len(fake.bytesArgsForCall) -} - -func (fake *Ecp) BytesCalls(stub func() ([]byte, error)) { - fake.bytesMutex.Lock() - defer fake.bytesMutex.Unlock() - fake.BytesStub = stub -} - -func (fake *Ecp) BytesReturns(result1 []byte, result2 error) { - fake.bytesMutex.Lock() - defer fake.bytesMutex.Unlock() - fake.BytesStub = nil - fake.bytesReturns = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *Ecp) BytesReturnsOnCall(i int, result1 []byte, result2 error) { - fake.bytesMutex.Lock() - defer fake.bytesMutex.Unlock() - fake.BytesStub = nil - if fake.bytesReturnsOnCall == nil { - fake.bytesReturnsOnCall = make(map[int]struct { - result1 []byte - result2 error - }) - } - fake.bytesReturnsOnCall[i] = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *Ecp) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.bytesMutex.RLock() - defer fake.bytesMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *Ecp) recordInvocation(key string, args []interface{}) { - fake.invocationsMutex.Lock() - defer fake.invocationsMutex.Unlock() - if fake.invocations == nil { - fake.invocations = map[string][][]interface{}{} - } - if fake.invocations[key] == nil { - fake.invocations[key] = [][]interface{}{} - } - fake.invocations[key] = append(fake.invocations[key], args) -} - -var _ handlers.Ecp = new(Ecp) diff --git a/bccsp/idemix/handlers/mock/issuer.go b/bccsp/idemix/handlers/mock/issuer.go deleted file mode 100644 index 869c793f77b..00000000000 --- a/bccsp/idemix/handlers/mock/issuer.go +++ /dev/null @@ -1,210 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package mock - -import ( - "sync" - - "github.com/hyperledger/fabric/bccsp/idemix/handlers" -) - -type Issuer struct { - NewKeyStub func([]string) (handlers.IssuerSecretKey, error) - newKeyMutex sync.RWMutex - newKeyArgsForCall []struct { - arg1 []string - } - newKeyReturns struct { - result1 handlers.IssuerSecretKey - result2 error - } - newKeyReturnsOnCall map[int]struct { - result1 handlers.IssuerSecretKey - result2 error - } - NewPublicKeyFromBytesStub func([]byte, []string) (handlers.IssuerPublicKey, error) - newPublicKeyFromBytesMutex sync.RWMutex - newPublicKeyFromBytesArgsForCall []struct { - arg1 []byte - arg2 []string - } - newPublicKeyFromBytesReturns struct { - result1 handlers.IssuerPublicKey - result2 error - } - newPublicKeyFromBytesReturnsOnCall map[int]struct { - result1 handlers.IssuerPublicKey - result2 error - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *Issuer) NewKey(arg1 []string) (handlers.IssuerSecretKey, error) { - var arg1Copy []string - if arg1 != nil { - arg1Copy = make([]string, len(arg1)) - copy(arg1Copy, arg1) - } - fake.newKeyMutex.Lock() - ret, specificReturn := fake.newKeyReturnsOnCall[len(fake.newKeyArgsForCall)] - fake.newKeyArgsForCall = append(fake.newKeyArgsForCall, struct { - arg1 []string - }{arg1Copy}) - fake.recordInvocation("NewKey", []interface{}{arg1Copy}) - fake.newKeyMutex.Unlock() - if fake.NewKeyStub != nil { - return fake.NewKeyStub(arg1) - } - if specificReturn { - return ret.result1, ret.result2 - } - fakeReturns := fake.newKeyReturns - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *Issuer) NewKeyCallCount() int { - fake.newKeyMutex.RLock() - defer fake.newKeyMutex.RUnlock() - return len(fake.newKeyArgsForCall) -} - -func (fake *Issuer) NewKeyCalls(stub func([]string) (handlers.IssuerSecretKey, error)) { - fake.newKeyMutex.Lock() - defer fake.newKeyMutex.Unlock() - fake.NewKeyStub = stub -} - -func (fake *Issuer) NewKeyArgsForCall(i int) []string { - fake.newKeyMutex.RLock() - defer fake.newKeyMutex.RUnlock() - argsForCall := fake.newKeyArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *Issuer) NewKeyReturns(result1 handlers.IssuerSecretKey, result2 error) { - fake.newKeyMutex.Lock() - defer fake.newKeyMutex.Unlock() - fake.NewKeyStub = nil - fake.newKeyReturns = struct { - result1 handlers.IssuerSecretKey - result2 error - }{result1, result2} -} - -func (fake *Issuer) NewKeyReturnsOnCall(i int, result1 handlers.IssuerSecretKey, result2 error) { - fake.newKeyMutex.Lock() - defer fake.newKeyMutex.Unlock() - fake.NewKeyStub = nil - if fake.newKeyReturnsOnCall == nil { - fake.newKeyReturnsOnCall = make(map[int]struct { - result1 handlers.IssuerSecretKey - result2 error - }) - } - fake.newKeyReturnsOnCall[i] = struct { - result1 handlers.IssuerSecretKey - result2 error - }{result1, result2} -} - -func (fake *Issuer) NewPublicKeyFromBytes(arg1 []byte, arg2 []string) (handlers.IssuerPublicKey, error) { - var arg1Copy []byte - if arg1 != nil { - arg1Copy = make([]byte, len(arg1)) - copy(arg1Copy, arg1) - } - var arg2Copy []string - if arg2 != nil { - arg2Copy = make([]string, len(arg2)) - copy(arg2Copy, arg2) - } - fake.newPublicKeyFromBytesMutex.Lock() - ret, specificReturn := fake.newPublicKeyFromBytesReturnsOnCall[len(fake.newPublicKeyFromBytesArgsForCall)] - fake.newPublicKeyFromBytesArgsForCall = append(fake.newPublicKeyFromBytesArgsForCall, struct { - arg1 []byte - arg2 []string - }{arg1Copy, arg2Copy}) - fake.recordInvocation("NewPublicKeyFromBytes", []interface{}{arg1Copy, arg2Copy}) - fake.newPublicKeyFromBytesMutex.Unlock() - if fake.NewPublicKeyFromBytesStub != nil { - return fake.NewPublicKeyFromBytesStub(arg1, arg2) - } - if specificReturn { - return ret.result1, ret.result2 - } - fakeReturns := fake.newPublicKeyFromBytesReturns - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *Issuer) NewPublicKeyFromBytesCallCount() int { - fake.newPublicKeyFromBytesMutex.RLock() - defer fake.newPublicKeyFromBytesMutex.RUnlock() - return len(fake.newPublicKeyFromBytesArgsForCall) -} - -func (fake *Issuer) NewPublicKeyFromBytesCalls(stub func([]byte, []string) (handlers.IssuerPublicKey, error)) { - fake.newPublicKeyFromBytesMutex.Lock() - defer fake.newPublicKeyFromBytesMutex.Unlock() - fake.NewPublicKeyFromBytesStub = stub -} - -func (fake *Issuer) NewPublicKeyFromBytesArgsForCall(i int) ([]byte, []string) { - fake.newPublicKeyFromBytesMutex.RLock() - defer fake.newPublicKeyFromBytesMutex.RUnlock() - argsForCall := fake.newPublicKeyFromBytesArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 -} - -func (fake *Issuer) NewPublicKeyFromBytesReturns(result1 handlers.IssuerPublicKey, result2 error) { - fake.newPublicKeyFromBytesMutex.Lock() - defer fake.newPublicKeyFromBytesMutex.Unlock() - fake.NewPublicKeyFromBytesStub = nil - fake.newPublicKeyFromBytesReturns = struct { - result1 handlers.IssuerPublicKey - result2 error - }{result1, result2} -} - -func (fake *Issuer) NewPublicKeyFromBytesReturnsOnCall(i int, result1 handlers.IssuerPublicKey, result2 error) { - fake.newPublicKeyFromBytesMutex.Lock() - defer fake.newPublicKeyFromBytesMutex.Unlock() - fake.NewPublicKeyFromBytesStub = nil - if fake.newPublicKeyFromBytesReturnsOnCall == nil { - fake.newPublicKeyFromBytesReturnsOnCall = make(map[int]struct { - result1 handlers.IssuerPublicKey - result2 error - }) - } - fake.newPublicKeyFromBytesReturnsOnCall[i] = struct { - result1 handlers.IssuerPublicKey - result2 error - }{result1, result2} -} - -func (fake *Issuer) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.newKeyMutex.RLock() - defer fake.newKeyMutex.RUnlock() - fake.newPublicKeyFromBytesMutex.RLock() - defer fake.newPublicKeyFromBytesMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *Issuer) recordInvocation(key string, args []interface{}) { - fake.invocationsMutex.Lock() - defer fake.invocationsMutex.Unlock() - if fake.invocations == nil { - fake.invocations = map[string][][]interface{}{} - } - if fake.invocations[key] == nil { - fake.invocations[key] = [][]interface{}{} - } - fake.invocations[key] = append(fake.invocations[key], args) -} - -var _ handlers.Issuer = new(Issuer) diff --git a/bccsp/idemix/handlers/mock/issuer_public_key.go b/bccsp/idemix/handlers/mock/issuer_public_key.go deleted file mode 100644 index bb9275f3fe4..00000000000 --- a/bccsp/idemix/handlers/mock/issuer_public_key.go +++ /dev/null @@ -1,170 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package mock - -import ( - "sync" - - "github.com/hyperledger/fabric/bccsp/idemix/handlers" -) - -type IssuerPublicKey struct { - BytesStub func() ([]byte, error) - bytesMutex sync.RWMutex - bytesArgsForCall []struct { - } - bytesReturns struct { - result1 []byte - result2 error - } - bytesReturnsOnCall map[int]struct { - result1 []byte - result2 error - } - HashStub func() []byte - hashMutex sync.RWMutex - hashArgsForCall []struct { - } - hashReturns struct { - result1 []byte - } - hashReturnsOnCall map[int]struct { - result1 []byte - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *IssuerPublicKey) Bytes() ([]byte, error) { - fake.bytesMutex.Lock() - ret, specificReturn := fake.bytesReturnsOnCall[len(fake.bytesArgsForCall)] - fake.bytesArgsForCall = append(fake.bytesArgsForCall, struct { - }{}) - fake.recordInvocation("Bytes", []interface{}{}) - fake.bytesMutex.Unlock() - if fake.BytesStub != nil { - return fake.BytesStub() - } - if specificReturn { - return ret.result1, ret.result2 - } - fakeReturns := fake.bytesReturns - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *IssuerPublicKey) BytesCallCount() int { - fake.bytesMutex.RLock() - defer fake.bytesMutex.RUnlock() - return len(fake.bytesArgsForCall) -} - -func (fake *IssuerPublicKey) BytesCalls(stub func() ([]byte, error)) { - fake.bytesMutex.Lock() - defer fake.bytesMutex.Unlock() - fake.BytesStub = stub -} - -func (fake *IssuerPublicKey) BytesReturns(result1 []byte, result2 error) { - fake.bytesMutex.Lock() - defer fake.bytesMutex.Unlock() - fake.BytesStub = nil - fake.bytesReturns = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *IssuerPublicKey) BytesReturnsOnCall(i int, result1 []byte, result2 error) { - fake.bytesMutex.Lock() - defer fake.bytesMutex.Unlock() - fake.BytesStub = nil - if fake.bytesReturnsOnCall == nil { - fake.bytesReturnsOnCall = make(map[int]struct { - result1 []byte - result2 error - }) - } - fake.bytesReturnsOnCall[i] = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *IssuerPublicKey) Hash() []byte { - fake.hashMutex.Lock() - ret, specificReturn := fake.hashReturnsOnCall[len(fake.hashArgsForCall)] - fake.hashArgsForCall = append(fake.hashArgsForCall, struct { - }{}) - fake.recordInvocation("Hash", []interface{}{}) - fake.hashMutex.Unlock() - if fake.HashStub != nil { - return fake.HashStub() - } - if specificReturn { - return ret.result1 - } - fakeReturns := fake.hashReturns - return fakeReturns.result1 -} - -func (fake *IssuerPublicKey) HashCallCount() int { - fake.hashMutex.RLock() - defer fake.hashMutex.RUnlock() - return len(fake.hashArgsForCall) -} - -func (fake *IssuerPublicKey) HashCalls(stub func() []byte) { - fake.hashMutex.Lock() - defer fake.hashMutex.Unlock() - fake.HashStub = stub -} - -func (fake *IssuerPublicKey) HashReturns(result1 []byte) { - fake.hashMutex.Lock() - defer fake.hashMutex.Unlock() - fake.HashStub = nil - fake.hashReturns = struct { - result1 []byte - }{result1} -} - -func (fake *IssuerPublicKey) HashReturnsOnCall(i int, result1 []byte) { - fake.hashMutex.Lock() - defer fake.hashMutex.Unlock() - fake.HashStub = nil - if fake.hashReturnsOnCall == nil { - fake.hashReturnsOnCall = make(map[int]struct { - result1 []byte - }) - } - fake.hashReturnsOnCall[i] = struct { - result1 []byte - }{result1} -} - -func (fake *IssuerPublicKey) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.bytesMutex.RLock() - defer fake.bytesMutex.RUnlock() - fake.hashMutex.RLock() - defer fake.hashMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *IssuerPublicKey) recordInvocation(key string, args []interface{}) { - fake.invocationsMutex.Lock() - defer fake.invocationsMutex.Unlock() - if fake.invocations == nil { - fake.invocations = map[string][][]interface{}{} - } - if fake.invocations[key] == nil { - fake.invocations[key] = [][]interface{}{} - } - fake.invocations[key] = append(fake.invocations[key], args) -} - -var _ handlers.IssuerPublicKey = new(IssuerPublicKey) diff --git a/bccsp/idemix/handlers/mock/issuer_secret_key.go b/bccsp/idemix/handlers/mock/issuer_secret_key.go deleted file mode 100644 index fbf7bd4a5b9..00000000000 --- a/bccsp/idemix/handlers/mock/issuer_secret_key.go +++ /dev/null @@ -1,170 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package mock - -import ( - "sync" - - "github.com/hyperledger/fabric/bccsp/idemix/handlers" -) - -type IssuerSecretKey struct { - BytesStub func() ([]byte, error) - bytesMutex sync.RWMutex - bytesArgsForCall []struct { - } - bytesReturns struct { - result1 []byte - result2 error - } - bytesReturnsOnCall map[int]struct { - result1 []byte - result2 error - } - PublicStub func() handlers.IssuerPublicKey - publicMutex sync.RWMutex - publicArgsForCall []struct { - } - publicReturns struct { - result1 handlers.IssuerPublicKey - } - publicReturnsOnCall map[int]struct { - result1 handlers.IssuerPublicKey - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *IssuerSecretKey) Bytes() ([]byte, error) { - fake.bytesMutex.Lock() - ret, specificReturn := fake.bytesReturnsOnCall[len(fake.bytesArgsForCall)] - fake.bytesArgsForCall = append(fake.bytesArgsForCall, struct { - }{}) - fake.recordInvocation("Bytes", []interface{}{}) - fake.bytesMutex.Unlock() - if fake.BytesStub != nil { - return fake.BytesStub() - } - if specificReturn { - return ret.result1, ret.result2 - } - fakeReturns := fake.bytesReturns - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *IssuerSecretKey) BytesCallCount() int { - fake.bytesMutex.RLock() - defer fake.bytesMutex.RUnlock() - return len(fake.bytesArgsForCall) -} - -func (fake *IssuerSecretKey) BytesCalls(stub func() ([]byte, error)) { - fake.bytesMutex.Lock() - defer fake.bytesMutex.Unlock() - fake.BytesStub = stub -} - -func (fake *IssuerSecretKey) BytesReturns(result1 []byte, result2 error) { - fake.bytesMutex.Lock() - defer fake.bytesMutex.Unlock() - fake.BytesStub = nil - fake.bytesReturns = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *IssuerSecretKey) BytesReturnsOnCall(i int, result1 []byte, result2 error) { - fake.bytesMutex.Lock() - defer fake.bytesMutex.Unlock() - fake.BytesStub = nil - if fake.bytesReturnsOnCall == nil { - fake.bytesReturnsOnCall = make(map[int]struct { - result1 []byte - result2 error - }) - } - fake.bytesReturnsOnCall[i] = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *IssuerSecretKey) Public() handlers.IssuerPublicKey { - fake.publicMutex.Lock() - ret, specificReturn := fake.publicReturnsOnCall[len(fake.publicArgsForCall)] - fake.publicArgsForCall = append(fake.publicArgsForCall, struct { - }{}) - fake.recordInvocation("Public", []interface{}{}) - fake.publicMutex.Unlock() - if fake.PublicStub != nil { - return fake.PublicStub() - } - if specificReturn { - return ret.result1 - } - fakeReturns := fake.publicReturns - return fakeReturns.result1 -} - -func (fake *IssuerSecretKey) PublicCallCount() int { - fake.publicMutex.RLock() - defer fake.publicMutex.RUnlock() - return len(fake.publicArgsForCall) -} - -func (fake *IssuerSecretKey) PublicCalls(stub func() handlers.IssuerPublicKey) { - fake.publicMutex.Lock() - defer fake.publicMutex.Unlock() - fake.PublicStub = stub -} - -func (fake *IssuerSecretKey) PublicReturns(result1 handlers.IssuerPublicKey) { - fake.publicMutex.Lock() - defer fake.publicMutex.Unlock() - fake.PublicStub = nil - fake.publicReturns = struct { - result1 handlers.IssuerPublicKey - }{result1} -} - -func (fake *IssuerSecretKey) PublicReturnsOnCall(i int, result1 handlers.IssuerPublicKey) { - fake.publicMutex.Lock() - defer fake.publicMutex.Unlock() - fake.PublicStub = nil - if fake.publicReturnsOnCall == nil { - fake.publicReturnsOnCall = make(map[int]struct { - result1 handlers.IssuerPublicKey - }) - } - fake.publicReturnsOnCall[i] = struct { - result1 handlers.IssuerPublicKey - }{result1} -} - -func (fake *IssuerSecretKey) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.bytesMutex.RLock() - defer fake.bytesMutex.RUnlock() - fake.publicMutex.RLock() - defer fake.publicMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *IssuerSecretKey) recordInvocation(key string, args []interface{}) { - fake.invocationsMutex.Lock() - defer fake.invocationsMutex.Unlock() - if fake.invocations == nil { - fake.invocations = map[string][][]interface{}{} - } - if fake.invocations[key] == nil { - fake.invocations[key] = [][]interface{}{} - } - fake.invocations[key] = append(fake.invocations[key], args) -} - -var _ handlers.IssuerSecretKey = new(IssuerSecretKey) diff --git a/bccsp/idemix/handlers/mock/nymsignature_scheme.go b/bccsp/idemix/handlers/mock/nymsignature_scheme.go deleted file mode 100644 index 93f2cd9dc4a..00000000000 --- a/bccsp/idemix/handlers/mock/nymsignature_scheme.go +++ /dev/null @@ -1,217 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package mock - -import ( - "sync" - - "github.com/hyperledger/fabric/bccsp/idemix/handlers" -) - -type NymSignatureScheme struct { - SignStub func(handlers.Big, handlers.Ecp, handlers.Big, handlers.IssuerPublicKey, []byte) ([]byte, error) - signMutex sync.RWMutex - signArgsForCall []struct { - arg1 handlers.Big - arg2 handlers.Ecp - arg3 handlers.Big - arg4 handlers.IssuerPublicKey - arg5 []byte - } - signReturns struct { - result1 []byte - result2 error - } - signReturnsOnCall map[int]struct { - result1 []byte - result2 error - } - VerifyStub func(handlers.IssuerPublicKey, handlers.Ecp, []byte, []byte) error - verifyMutex sync.RWMutex - verifyArgsForCall []struct { - arg1 handlers.IssuerPublicKey - arg2 handlers.Ecp - arg3 []byte - arg4 []byte - } - verifyReturns struct { - result1 error - } - verifyReturnsOnCall map[int]struct { - result1 error - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *NymSignatureScheme) Sign(arg1 handlers.Big, arg2 handlers.Ecp, arg3 handlers.Big, arg4 handlers.IssuerPublicKey, arg5 []byte) ([]byte, error) { - var arg5Copy []byte - if arg5 != nil { - arg5Copy = make([]byte, len(arg5)) - copy(arg5Copy, arg5) - } - fake.signMutex.Lock() - ret, specificReturn := fake.signReturnsOnCall[len(fake.signArgsForCall)] - fake.signArgsForCall = append(fake.signArgsForCall, struct { - arg1 handlers.Big - arg2 handlers.Ecp - arg3 handlers.Big - arg4 handlers.IssuerPublicKey - arg5 []byte - }{arg1, arg2, arg3, arg4, arg5Copy}) - fake.recordInvocation("Sign", []interface{}{arg1, arg2, arg3, arg4, arg5Copy}) - fake.signMutex.Unlock() - if fake.SignStub != nil { - return fake.SignStub(arg1, arg2, arg3, arg4, arg5) - } - if specificReturn { - return ret.result1, ret.result2 - } - fakeReturns := fake.signReturns - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *NymSignatureScheme) SignCallCount() int { - fake.signMutex.RLock() - defer fake.signMutex.RUnlock() - return len(fake.signArgsForCall) -} - -func (fake *NymSignatureScheme) SignCalls(stub func(handlers.Big, handlers.Ecp, handlers.Big, handlers.IssuerPublicKey, []byte) ([]byte, error)) { - fake.signMutex.Lock() - defer fake.signMutex.Unlock() - fake.SignStub = stub -} - -func (fake *NymSignatureScheme) SignArgsForCall(i int) (handlers.Big, handlers.Ecp, handlers.Big, handlers.IssuerPublicKey, []byte) { - fake.signMutex.RLock() - defer fake.signMutex.RUnlock() - argsForCall := fake.signArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5 -} - -func (fake *NymSignatureScheme) SignReturns(result1 []byte, result2 error) { - fake.signMutex.Lock() - defer fake.signMutex.Unlock() - fake.SignStub = nil - fake.signReturns = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *NymSignatureScheme) SignReturnsOnCall(i int, result1 []byte, result2 error) { - fake.signMutex.Lock() - defer fake.signMutex.Unlock() - fake.SignStub = nil - if fake.signReturnsOnCall == nil { - fake.signReturnsOnCall = make(map[int]struct { - result1 []byte - result2 error - }) - } - fake.signReturnsOnCall[i] = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *NymSignatureScheme) Verify(arg1 handlers.IssuerPublicKey, arg2 handlers.Ecp, arg3 []byte, arg4 []byte) error { - var arg3Copy []byte - if arg3 != nil { - arg3Copy = make([]byte, len(arg3)) - copy(arg3Copy, arg3) - } - var arg4Copy []byte - if arg4 != nil { - arg4Copy = make([]byte, len(arg4)) - copy(arg4Copy, arg4) - } - fake.verifyMutex.Lock() - ret, specificReturn := fake.verifyReturnsOnCall[len(fake.verifyArgsForCall)] - fake.verifyArgsForCall = append(fake.verifyArgsForCall, struct { - arg1 handlers.IssuerPublicKey - arg2 handlers.Ecp - arg3 []byte - arg4 []byte - }{arg1, arg2, arg3Copy, arg4Copy}) - fake.recordInvocation("Verify", []interface{}{arg1, arg2, arg3Copy, arg4Copy}) - fake.verifyMutex.Unlock() - if fake.VerifyStub != nil { - return fake.VerifyStub(arg1, arg2, arg3, arg4) - } - if specificReturn { - return ret.result1 - } - fakeReturns := fake.verifyReturns - return fakeReturns.result1 -} - -func (fake *NymSignatureScheme) VerifyCallCount() int { - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - return len(fake.verifyArgsForCall) -} - -func (fake *NymSignatureScheme) VerifyCalls(stub func(handlers.IssuerPublicKey, handlers.Ecp, []byte, []byte) error) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = stub -} - -func (fake *NymSignatureScheme) VerifyArgsForCall(i int) (handlers.IssuerPublicKey, handlers.Ecp, []byte, []byte) { - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - argsForCall := fake.verifyArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 -} - -func (fake *NymSignatureScheme) VerifyReturns(result1 error) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = nil - fake.verifyReturns = struct { - result1 error - }{result1} -} - -func (fake *NymSignatureScheme) VerifyReturnsOnCall(i int, result1 error) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = nil - if fake.verifyReturnsOnCall == nil { - fake.verifyReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.verifyReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *NymSignatureScheme) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.signMutex.RLock() - defer fake.signMutex.RUnlock() - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *NymSignatureScheme) recordInvocation(key string, args []interface{}) { - fake.invocationsMutex.Lock() - defer fake.invocationsMutex.Unlock() - if fake.invocations == nil { - fake.invocations = map[string][][]interface{}{} - } - if fake.invocations[key] == nil { - fake.invocations[key] = [][]interface{}{} - } - fake.invocations[key] = append(fake.invocations[key], args) -} - -var _ handlers.NymSignatureScheme = new(NymSignatureScheme) diff --git a/bccsp/idemix/handlers/mock/revocation.go b/bccsp/idemix/handlers/mock/revocation.go deleted file mode 100644 index 14237ff4686..00000000000 --- a/bccsp/idemix/handlers/mock/revocation.go +++ /dev/null @@ -1,281 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package mock - -import ( - "crypto/ecdsa" - "sync" - - "github.com/hyperledger/fabric/bccsp" - "github.com/hyperledger/fabric/bccsp/idemix/handlers" -) - -type Revocation struct { - NewKeyStub func() (*ecdsa.PrivateKey, error) - newKeyMutex sync.RWMutex - newKeyArgsForCall []struct { - } - newKeyReturns struct { - result1 *ecdsa.PrivateKey - result2 error - } - newKeyReturnsOnCall map[int]struct { - result1 *ecdsa.PrivateKey - result2 error - } - SignStub func(*ecdsa.PrivateKey, [][]byte, int, bccsp.RevocationAlgorithm) ([]byte, error) - signMutex sync.RWMutex - signArgsForCall []struct { - arg1 *ecdsa.PrivateKey - arg2 [][]byte - arg3 int - arg4 bccsp.RevocationAlgorithm - } - signReturns struct { - result1 []byte - result2 error - } - signReturnsOnCall map[int]struct { - result1 []byte - result2 error - } - VerifyStub func(*ecdsa.PublicKey, []byte, int, bccsp.RevocationAlgorithm) error - verifyMutex sync.RWMutex - verifyArgsForCall []struct { - arg1 *ecdsa.PublicKey - arg2 []byte - arg3 int - arg4 bccsp.RevocationAlgorithm - } - verifyReturns struct { - result1 error - } - verifyReturnsOnCall map[int]struct { - result1 error - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *Revocation) NewKey() (*ecdsa.PrivateKey, error) { - fake.newKeyMutex.Lock() - ret, specificReturn := fake.newKeyReturnsOnCall[len(fake.newKeyArgsForCall)] - fake.newKeyArgsForCall = append(fake.newKeyArgsForCall, struct { - }{}) - fake.recordInvocation("NewKey", []interface{}{}) - fake.newKeyMutex.Unlock() - if fake.NewKeyStub != nil { - return fake.NewKeyStub() - } - if specificReturn { - return ret.result1, ret.result2 - } - fakeReturns := fake.newKeyReturns - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *Revocation) NewKeyCallCount() int { - fake.newKeyMutex.RLock() - defer fake.newKeyMutex.RUnlock() - return len(fake.newKeyArgsForCall) -} - -func (fake *Revocation) NewKeyCalls(stub func() (*ecdsa.PrivateKey, error)) { - fake.newKeyMutex.Lock() - defer fake.newKeyMutex.Unlock() - fake.NewKeyStub = stub -} - -func (fake *Revocation) NewKeyReturns(result1 *ecdsa.PrivateKey, result2 error) { - fake.newKeyMutex.Lock() - defer fake.newKeyMutex.Unlock() - fake.NewKeyStub = nil - fake.newKeyReturns = struct { - result1 *ecdsa.PrivateKey - result2 error - }{result1, result2} -} - -func (fake *Revocation) NewKeyReturnsOnCall(i int, result1 *ecdsa.PrivateKey, result2 error) { - fake.newKeyMutex.Lock() - defer fake.newKeyMutex.Unlock() - fake.NewKeyStub = nil - if fake.newKeyReturnsOnCall == nil { - fake.newKeyReturnsOnCall = make(map[int]struct { - result1 *ecdsa.PrivateKey - result2 error - }) - } - fake.newKeyReturnsOnCall[i] = struct { - result1 *ecdsa.PrivateKey - result2 error - }{result1, result2} -} - -func (fake *Revocation) Sign(arg1 *ecdsa.PrivateKey, arg2 [][]byte, arg3 int, arg4 bccsp.RevocationAlgorithm) ([]byte, error) { - var arg2Copy [][]byte - if arg2 != nil { - arg2Copy = make([][]byte, len(arg2)) - copy(arg2Copy, arg2) - } - fake.signMutex.Lock() - ret, specificReturn := fake.signReturnsOnCall[len(fake.signArgsForCall)] - fake.signArgsForCall = append(fake.signArgsForCall, struct { - arg1 *ecdsa.PrivateKey - arg2 [][]byte - arg3 int - arg4 bccsp.RevocationAlgorithm - }{arg1, arg2Copy, arg3, arg4}) - fake.recordInvocation("Sign", []interface{}{arg1, arg2Copy, arg3, arg4}) - fake.signMutex.Unlock() - if fake.SignStub != nil { - return fake.SignStub(arg1, arg2, arg3, arg4) - } - if specificReturn { - return ret.result1, ret.result2 - } - fakeReturns := fake.signReturns - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *Revocation) SignCallCount() int { - fake.signMutex.RLock() - defer fake.signMutex.RUnlock() - return len(fake.signArgsForCall) -} - -func (fake *Revocation) SignCalls(stub func(*ecdsa.PrivateKey, [][]byte, int, bccsp.RevocationAlgorithm) ([]byte, error)) { - fake.signMutex.Lock() - defer fake.signMutex.Unlock() - fake.SignStub = stub -} - -func (fake *Revocation) SignArgsForCall(i int) (*ecdsa.PrivateKey, [][]byte, int, bccsp.RevocationAlgorithm) { - fake.signMutex.RLock() - defer fake.signMutex.RUnlock() - argsForCall := fake.signArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 -} - -func (fake *Revocation) SignReturns(result1 []byte, result2 error) { - fake.signMutex.Lock() - defer fake.signMutex.Unlock() - fake.SignStub = nil - fake.signReturns = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *Revocation) SignReturnsOnCall(i int, result1 []byte, result2 error) { - fake.signMutex.Lock() - defer fake.signMutex.Unlock() - fake.SignStub = nil - if fake.signReturnsOnCall == nil { - fake.signReturnsOnCall = make(map[int]struct { - result1 []byte - result2 error - }) - } - fake.signReturnsOnCall[i] = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *Revocation) Verify(arg1 *ecdsa.PublicKey, arg2 []byte, arg3 int, arg4 bccsp.RevocationAlgorithm) error { - var arg2Copy []byte - if arg2 != nil { - arg2Copy = make([]byte, len(arg2)) - copy(arg2Copy, arg2) - } - fake.verifyMutex.Lock() - ret, specificReturn := fake.verifyReturnsOnCall[len(fake.verifyArgsForCall)] - fake.verifyArgsForCall = append(fake.verifyArgsForCall, struct { - arg1 *ecdsa.PublicKey - arg2 []byte - arg3 int - arg4 bccsp.RevocationAlgorithm - }{arg1, arg2Copy, arg3, arg4}) - fake.recordInvocation("Verify", []interface{}{arg1, arg2Copy, arg3, arg4}) - fake.verifyMutex.Unlock() - if fake.VerifyStub != nil { - return fake.VerifyStub(arg1, arg2, arg3, arg4) - } - if specificReturn { - return ret.result1 - } - fakeReturns := fake.verifyReturns - return fakeReturns.result1 -} - -func (fake *Revocation) VerifyCallCount() int { - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - return len(fake.verifyArgsForCall) -} - -func (fake *Revocation) VerifyCalls(stub func(*ecdsa.PublicKey, []byte, int, bccsp.RevocationAlgorithm) error) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = stub -} - -func (fake *Revocation) VerifyArgsForCall(i int) (*ecdsa.PublicKey, []byte, int, bccsp.RevocationAlgorithm) { - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - argsForCall := fake.verifyArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 -} - -func (fake *Revocation) VerifyReturns(result1 error) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = nil - fake.verifyReturns = struct { - result1 error - }{result1} -} - -func (fake *Revocation) VerifyReturnsOnCall(i int, result1 error) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = nil - if fake.verifyReturnsOnCall == nil { - fake.verifyReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.verifyReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *Revocation) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.newKeyMutex.RLock() - defer fake.newKeyMutex.RUnlock() - fake.signMutex.RLock() - defer fake.signMutex.RUnlock() - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *Revocation) recordInvocation(key string, args []interface{}) { - fake.invocationsMutex.Lock() - defer fake.invocationsMutex.Unlock() - if fake.invocations == nil { - fake.invocations = map[string][][]interface{}{} - } - if fake.invocations[key] == nil { - fake.invocations[key] = [][]interface{}{} - } - fake.invocations[key] = append(fake.invocations[key], args) -} - -var _ handlers.Revocation = new(Revocation) diff --git a/bccsp/idemix/handlers/mock/signature_scheme.go b/bccsp/idemix/handlers/mock/signature_scheme.go deleted file mode 100644 index 0dd68337486..00000000000 --- a/bccsp/idemix/handlers/mock/signature_scheme.go +++ /dev/null @@ -1,253 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package mock - -import ( - "crypto/ecdsa" - "sync" - - "github.com/hyperledger/fabric/bccsp" - "github.com/hyperledger/fabric/bccsp/idemix/handlers" -) - -type SignatureScheme struct { - SignStub func([]byte, handlers.Big, handlers.Ecp, handlers.Big, handlers.IssuerPublicKey, []bccsp.IdemixAttribute, []byte, int, []byte) ([]byte, error) - signMutex sync.RWMutex - signArgsForCall []struct { - arg1 []byte - arg2 handlers.Big - arg3 handlers.Ecp - arg4 handlers.Big - arg5 handlers.IssuerPublicKey - arg6 []bccsp.IdemixAttribute - arg7 []byte - arg8 int - arg9 []byte - } - signReturns struct { - result1 []byte - result2 error - } - signReturnsOnCall map[int]struct { - result1 []byte - result2 error - } - VerifyStub func(handlers.IssuerPublicKey, []byte, []byte, []bccsp.IdemixAttribute, int, *ecdsa.PublicKey, int) error - verifyMutex sync.RWMutex - verifyArgsForCall []struct { - arg1 handlers.IssuerPublicKey - arg2 []byte - arg3 []byte - arg4 []bccsp.IdemixAttribute - arg5 int - arg6 *ecdsa.PublicKey - arg7 int - } - verifyReturns struct { - result1 error - } - verifyReturnsOnCall map[int]struct { - result1 error - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *SignatureScheme) Sign(arg1 []byte, arg2 handlers.Big, arg3 handlers.Ecp, arg4 handlers.Big, arg5 handlers.IssuerPublicKey, arg6 []bccsp.IdemixAttribute, arg7 []byte, arg8 int, arg9 []byte) ([]byte, error) { - var arg1Copy []byte - if arg1 != nil { - arg1Copy = make([]byte, len(arg1)) - copy(arg1Copy, arg1) - } - var arg6Copy []bccsp.IdemixAttribute - if arg6 != nil { - arg6Copy = make([]bccsp.IdemixAttribute, len(arg6)) - copy(arg6Copy, arg6) - } - var arg7Copy []byte - if arg7 != nil { - arg7Copy = make([]byte, len(arg7)) - copy(arg7Copy, arg7) - } - var arg9Copy []byte - if arg9 != nil { - arg9Copy = make([]byte, len(arg9)) - copy(arg9Copy, arg9) - } - fake.signMutex.Lock() - ret, specificReturn := fake.signReturnsOnCall[len(fake.signArgsForCall)] - fake.signArgsForCall = append(fake.signArgsForCall, struct { - arg1 []byte - arg2 handlers.Big - arg3 handlers.Ecp - arg4 handlers.Big - arg5 handlers.IssuerPublicKey - arg6 []bccsp.IdemixAttribute - arg7 []byte - arg8 int - arg9 []byte - }{arg1Copy, arg2, arg3, arg4, arg5, arg6Copy, arg7Copy, arg8, arg9Copy}) - fake.recordInvocation("Sign", []interface{}{arg1Copy, arg2, arg3, arg4, arg5, arg6Copy, arg7Copy, arg8, arg9Copy}) - fake.signMutex.Unlock() - if fake.SignStub != nil { - return fake.SignStub(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - } - if specificReturn { - return ret.result1, ret.result2 - } - fakeReturns := fake.signReturns - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *SignatureScheme) SignCallCount() int { - fake.signMutex.RLock() - defer fake.signMutex.RUnlock() - return len(fake.signArgsForCall) -} - -func (fake *SignatureScheme) SignCalls(stub func([]byte, handlers.Big, handlers.Ecp, handlers.Big, handlers.IssuerPublicKey, []bccsp.IdemixAttribute, []byte, int, []byte) ([]byte, error)) { - fake.signMutex.Lock() - defer fake.signMutex.Unlock() - fake.SignStub = stub -} - -func (fake *SignatureScheme) SignArgsForCall(i int) ([]byte, handlers.Big, handlers.Ecp, handlers.Big, handlers.IssuerPublicKey, []bccsp.IdemixAttribute, []byte, int, []byte) { - fake.signMutex.RLock() - defer fake.signMutex.RUnlock() - argsForCall := fake.signArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6, argsForCall.arg7, argsForCall.arg8, argsForCall.arg9 -} - -func (fake *SignatureScheme) SignReturns(result1 []byte, result2 error) { - fake.signMutex.Lock() - defer fake.signMutex.Unlock() - fake.SignStub = nil - fake.signReturns = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *SignatureScheme) SignReturnsOnCall(i int, result1 []byte, result2 error) { - fake.signMutex.Lock() - defer fake.signMutex.Unlock() - fake.SignStub = nil - if fake.signReturnsOnCall == nil { - fake.signReturnsOnCall = make(map[int]struct { - result1 []byte - result2 error - }) - } - fake.signReturnsOnCall[i] = struct { - result1 []byte - result2 error - }{result1, result2} -} - -func (fake *SignatureScheme) Verify(arg1 handlers.IssuerPublicKey, arg2 []byte, arg3 []byte, arg4 []bccsp.IdemixAttribute, arg5 int, arg6 *ecdsa.PublicKey, arg7 int) error { - var arg2Copy []byte - if arg2 != nil { - arg2Copy = make([]byte, len(arg2)) - copy(arg2Copy, arg2) - } - var arg3Copy []byte - if arg3 != nil { - arg3Copy = make([]byte, len(arg3)) - copy(arg3Copy, arg3) - } - var arg4Copy []bccsp.IdemixAttribute - if arg4 != nil { - arg4Copy = make([]bccsp.IdemixAttribute, len(arg4)) - copy(arg4Copy, arg4) - } - fake.verifyMutex.Lock() - ret, specificReturn := fake.verifyReturnsOnCall[len(fake.verifyArgsForCall)] - fake.verifyArgsForCall = append(fake.verifyArgsForCall, struct { - arg1 handlers.IssuerPublicKey - arg2 []byte - arg3 []byte - arg4 []bccsp.IdemixAttribute - arg5 int - arg6 *ecdsa.PublicKey - arg7 int - }{arg1, arg2Copy, arg3Copy, arg4Copy, arg5, arg6, arg7}) - fake.recordInvocation("Verify", []interface{}{arg1, arg2Copy, arg3Copy, arg4Copy, arg5, arg6, arg7}) - fake.verifyMutex.Unlock() - if fake.VerifyStub != nil { - return fake.VerifyStub(arg1, arg2, arg3, arg4, arg5, arg6, arg7) - } - if specificReturn { - return ret.result1 - } - fakeReturns := fake.verifyReturns - return fakeReturns.result1 -} - -func (fake *SignatureScheme) VerifyCallCount() int { - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - return len(fake.verifyArgsForCall) -} - -func (fake *SignatureScheme) VerifyCalls(stub func(handlers.IssuerPublicKey, []byte, []byte, []bccsp.IdemixAttribute, int, *ecdsa.PublicKey, int) error) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = stub -} - -func (fake *SignatureScheme) VerifyArgsForCall(i int) (handlers.IssuerPublicKey, []byte, []byte, []bccsp.IdemixAttribute, int, *ecdsa.PublicKey, int) { - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - argsForCall := fake.verifyArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6, argsForCall.arg7 -} - -func (fake *SignatureScheme) VerifyReturns(result1 error) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = nil - fake.verifyReturns = struct { - result1 error - }{result1} -} - -func (fake *SignatureScheme) VerifyReturnsOnCall(i int, result1 error) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = nil - if fake.verifyReturnsOnCall == nil { - fake.verifyReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.verifyReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *SignatureScheme) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.signMutex.RLock() - defer fake.signMutex.RUnlock() - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *SignatureScheme) recordInvocation(key string, args []interface{}) { - fake.invocationsMutex.Lock() - defer fake.invocationsMutex.Unlock() - if fake.invocations == nil { - fake.invocations = map[string][][]interface{}{} - } - if fake.invocations[key] == nil { - fake.invocations[key] = [][]interface{}{} - } - fake.invocations[key] = append(fake.invocations[key], args) -} - -var _ handlers.SignatureScheme = new(SignatureScheme) diff --git a/bccsp/idemix/handlers/mock/user.go b/bccsp/idemix/handlers/mock/user.go deleted file mode 100644 index 075e4da20aa..00000000000 --- a/bccsp/idemix/handlers/mock/user.go +++ /dev/null @@ -1,357 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package mock - -import ( - "sync" - - "github.com/hyperledger/fabric/bccsp/idemix/handlers" -) - -type User struct { - MakeNymStub func(handlers.Big, handlers.IssuerPublicKey) (handlers.Ecp, handlers.Big, error) - makeNymMutex sync.RWMutex - makeNymArgsForCall []struct { - arg1 handlers.Big - arg2 handlers.IssuerPublicKey - } - makeNymReturns struct { - result1 handlers.Ecp - result2 handlers.Big - result3 error - } - makeNymReturnsOnCall map[int]struct { - result1 handlers.Ecp - result2 handlers.Big - result3 error - } - NewKeyStub func() (handlers.Big, error) - newKeyMutex sync.RWMutex - newKeyArgsForCall []struct { - } - newKeyReturns struct { - result1 handlers.Big - result2 error - } - newKeyReturnsOnCall map[int]struct { - result1 handlers.Big - result2 error - } - NewKeyFromBytesStub func([]byte) (handlers.Big, error) - newKeyFromBytesMutex sync.RWMutex - newKeyFromBytesArgsForCall []struct { - arg1 []byte - } - newKeyFromBytesReturns struct { - result1 handlers.Big - result2 error - } - newKeyFromBytesReturnsOnCall map[int]struct { - result1 handlers.Big - result2 error - } - NewPublicNymFromBytesStub func([]byte) (handlers.Ecp, error) - newPublicNymFromBytesMutex sync.RWMutex - newPublicNymFromBytesArgsForCall []struct { - arg1 []byte - } - newPublicNymFromBytesReturns struct { - result1 handlers.Ecp - result2 error - } - newPublicNymFromBytesReturnsOnCall map[int]struct { - result1 handlers.Ecp - result2 error - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *User) MakeNym(arg1 handlers.Big, arg2 handlers.IssuerPublicKey) (handlers.Ecp, handlers.Big, error) { - fake.makeNymMutex.Lock() - ret, specificReturn := fake.makeNymReturnsOnCall[len(fake.makeNymArgsForCall)] - fake.makeNymArgsForCall = append(fake.makeNymArgsForCall, struct { - arg1 handlers.Big - arg2 handlers.IssuerPublicKey - }{arg1, arg2}) - fake.recordInvocation("MakeNym", []interface{}{arg1, arg2}) - fake.makeNymMutex.Unlock() - if fake.MakeNymStub != nil { - return fake.MakeNymStub(arg1, arg2) - } - if specificReturn { - return ret.result1, ret.result2, ret.result3 - } - fakeReturns := fake.makeNymReturns - return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 -} - -func (fake *User) MakeNymCallCount() int { - fake.makeNymMutex.RLock() - defer fake.makeNymMutex.RUnlock() - return len(fake.makeNymArgsForCall) -} - -func (fake *User) MakeNymCalls(stub func(handlers.Big, handlers.IssuerPublicKey) (handlers.Ecp, handlers.Big, error)) { - fake.makeNymMutex.Lock() - defer fake.makeNymMutex.Unlock() - fake.MakeNymStub = stub -} - -func (fake *User) MakeNymArgsForCall(i int) (handlers.Big, handlers.IssuerPublicKey) { - fake.makeNymMutex.RLock() - defer fake.makeNymMutex.RUnlock() - argsForCall := fake.makeNymArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 -} - -func (fake *User) MakeNymReturns(result1 handlers.Ecp, result2 handlers.Big, result3 error) { - fake.makeNymMutex.Lock() - defer fake.makeNymMutex.Unlock() - fake.MakeNymStub = nil - fake.makeNymReturns = struct { - result1 handlers.Ecp - result2 handlers.Big - result3 error - }{result1, result2, result3} -} - -func (fake *User) MakeNymReturnsOnCall(i int, result1 handlers.Ecp, result2 handlers.Big, result3 error) { - fake.makeNymMutex.Lock() - defer fake.makeNymMutex.Unlock() - fake.MakeNymStub = nil - if fake.makeNymReturnsOnCall == nil { - fake.makeNymReturnsOnCall = make(map[int]struct { - result1 handlers.Ecp - result2 handlers.Big - result3 error - }) - } - fake.makeNymReturnsOnCall[i] = struct { - result1 handlers.Ecp - result2 handlers.Big - result3 error - }{result1, result2, result3} -} - -func (fake *User) NewKey() (handlers.Big, error) { - fake.newKeyMutex.Lock() - ret, specificReturn := fake.newKeyReturnsOnCall[len(fake.newKeyArgsForCall)] - fake.newKeyArgsForCall = append(fake.newKeyArgsForCall, struct { - }{}) - fake.recordInvocation("NewKey", []interface{}{}) - fake.newKeyMutex.Unlock() - if fake.NewKeyStub != nil { - return fake.NewKeyStub() - } - if specificReturn { - return ret.result1, ret.result2 - } - fakeReturns := fake.newKeyReturns - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *User) NewKeyCallCount() int { - fake.newKeyMutex.RLock() - defer fake.newKeyMutex.RUnlock() - return len(fake.newKeyArgsForCall) -} - -func (fake *User) NewKeyCalls(stub func() (handlers.Big, error)) { - fake.newKeyMutex.Lock() - defer fake.newKeyMutex.Unlock() - fake.NewKeyStub = stub -} - -func (fake *User) NewKeyReturns(result1 handlers.Big, result2 error) { - fake.newKeyMutex.Lock() - defer fake.newKeyMutex.Unlock() - fake.NewKeyStub = nil - fake.newKeyReturns = struct { - result1 handlers.Big - result2 error - }{result1, result2} -} - -func (fake *User) NewKeyReturnsOnCall(i int, result1 handlers.Big, result2 error) { - fake.newKeyMutex.Lock() - defer fake.newKeyMutex.Unlock() - fake.NewKeyStub = nil - if fake.newKeyReturnsOnCall == nil { - fake.newKeyReturnsOnCall = make(map[int]struct { - result1 handlers.Big - result2 error - }) - } - fake.newKeyReturnsOnCall[i] = struct { - result1 handlers.Big - result2 error - }{result1, result2} -} - -func (fake *User) NewKeyFromBytes(arg1 []byte) (handlers.Big, error) { - var arg1Copy []byte - if arg1 != nil { - arg1Copy = make([]byte, len(arg1)) - copy(arg1Copy, arg1) - } - fake.newKeyFromBytesMutex.Lock() - ret, specificReturn := fake.newKeyFromBytesReturnsOnCall[len(fake.newKeyFromBytesArgsForCall)] - fake.newKeyFromBytesArgsForCall = append(fake.newKeyFromBytesArgsForCall, struct { - arg1 []byte - }{arg1Copy}) - fake.recordInvocation("NewKeyFromBytes", []interface{}{arg1Copy}) - fake.newKeyFromBytesMutex.Unlock() - if fake.NewKeyFromBytesStub != nil { - return fake.NewKeyFromBytesStub(arg1) - } - if specificReturn { - return ret.result1, ret.result2 - } - fakeReturns := fake.newKeyFromBytesReturns - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *User) NewKeyFromBytesCallCount() int { - fake.newKeyFromBytesMutex.RLock() - defer fake.newKeyFromBytesMutex.RUnlock() - return len(fake.newKeyFromBytesArgsForCall) -} - -func (fake *User) NewKeyFromBytesCalls(stub func([]byte) (handlers.Big, error)) { - fake.newKeyFromBytesMutex.Lock() - defer fake.newKeyFromBytesMutex.Unlock() - fake.NewKeyFromBytesStub = stub -} - -func (fake *User) NewKeyFromBytesArgsForCall(i int) []byte { - fake.newKeyFromBytesMutex.RLock() - defer fake.newKeyFromBytesMutex.RUnlock() - argsForCall := fake.newKeyFromBytesArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *User) NewKeyFromBytesReturns(result1 handlers.Big, result2 error) { - fake.newKeyFromBytesMutex.Lock() - defer fake.newKeyFromBytesMutex.Unlock() - fake.NewKeyFromBytesStub = nil - fake.newKeyFromBytesReturns = struct { - result1 handlers.Big - result2 error - }{result1, result2} -} - -func (fake *User) NewKeyFromBytesReturnsOnCall(i int, result1 handlers.Big, result2 error) { - fake.newKeyFromBytesMutex.Lock() - defer fake.newKeyFromBytesMutex.Unlock() - fake.NewKeyFromBytesStub = nil - if fake.newKeyFromBytesReturnsOnCall == nil { - fake.newKeyFromBytesReturnsOnCall = make(map[int]struct { - result1 handlers.Big - result2 error - }) - } - fake.newKeyFromBytesReturnsOnCall[i] = struct { - result1 handlers.Big - result2 error - }{result1, result2} -} - -func (fake *User) NewPublicNymFromBytes(arg1 []byte) (handlers.Ecp, error) { - var arg1Copy []byte - if arg1 != nil { - arg1Copy = make([]byte, len(arg1)) - copy(arg1Copy, arg1) - } - fake.newPublicNymFromBytesMutex.Lock() - ret, specificReturn := fake.newPublicNymFromBytesReturnsOnCall[len(fake.newPublicNymFromBytesArgsForCall)] - fake.newPublicNymFromBytesArgsForCall = append(fake.newPublicNymFromBytesArgsForCall, struct { - arg1 []byte - }{arg1Copy}) - fake.recordInvocation("NewPublicNymFromBytes", []interface{}{arg1Copy}) - fake.newPublicNymFromBytesMutex.Unlock() - if fake.NewPublicNymFromBytesStub != nil { - return fake.NewPublicNymFromBytesStub(arg1) - } - if specificReturn { - return ret.result1, ret.result2 - } - fakeReturns := fake.newPublicNymFromBytesReturns - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *User) NewPublicNymFromBytesCallCount() int { - fake.newPublicNymFromBytesMutex.RLock() - defer fake.newPublicNymFromBytesMutex.RUnlock() - return len(fake.newPublicNymFromBytesArgsForCall) -} - -func (fake *User) NewPublicNymFromBytesCalls(stub func([]byte) (handlers.Ecp, error)) { - fake.newPublicNymFromBytesMutex.Lock() - defer fake.newPublicNymFromBytesMutex.Unlock() - fake.NewPublicNymFromBytesStub = stub -} - -func (fake *User) NewPublicNymFromBytesArgsForCall(i int) []byte { - fake.newPublicNymFromBytesMutex.RLock() - defer fake.newPublicNymFromBytesMutex.RUnlock() - argsForCall := fake.newPublicNymFromBytesArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *User) NewPublicNymFromBytesReturns(result1 handlers.Ecp, result2 error) { - fake.newPublicNymFromBytesMutex.Lock() - defer fake.newPublicNymFromBytesMutex.Unlock() - fake.NewPublicNymFromBytesStub = nil - fake.newPublicNymFromBytesReturns = struct { - result1 handlers.Ecp - result2 error - }{result1, result2} -} - -func (fake *User) NewPublicNymFromBytesReturnsOnCall(i int, result1 handlers.Ecp, result2 error) { - fake.newPublicNymFromBytesMutex.Lock() - defer fake.newPublicNymFromBytesMutex.Unlock() - fake.NewPublicNymFromBytesStub = nil - if fake.newPublicNymFromBytesReturnsOnCall == nil { - fake.newPublicNymFromBytesReturnsOnCall = make(map[int]struct { - result1 handlers.Ecp - result2 error - }) - } - fake.newPublicNymFromBytesReturnsOnCall[i] = struct { - result1 handlers.Ecp - result2 error - }{result1, result2} -} - -func (fake *User) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.makeNymMutex.RLock() - defer fake.makeNymMutex.RUnlock() - fake.newKeyMutex.RLock() - defer fake.newKeyMutex.RUnlock() - fake.newKeyFromBytesMutex.RLock() - defer fake.newKeyFromBytesMutex.RUnlock() - fake.newPublicNymFromBytesMutex.RLock() - defer fake.newPublicNymFromBytesMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *User) recordInvocation(key string, args []interface{}) { - fake.invocationsMutex.Lock() - defer fake.invocationsMutex.Unlock() - if fake.invocations == nil { - fake.invocations = map[string][][]interface{}{} - } - if fake.invocations[key] == nil { - fake.invocations[key] = [][]interface{}{} - } - fake.invocations[key] = append(fake.invocations[key], args) -} - -var _ handlers.User = new(User) diff --git a/bccsp/idemix/handlers/nym.go b/bccsp/idemix/handlers/nym.go deleted file mode 100644 index 40aae595fbf..00000000000 --- a/bccsp/idemix/handlers/nym.go +++ /dev/null @@ -1,166 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ -package handlers - -import ( - "crypto/sha256" - - "github.com/hyperledger/fabric/bccsp" - "github.com/pkg/errors" -) - -// nymSecretKey contains the nym secret key -type nymSecretKey struct { - // SKI of this key - ski []byte - // sk is the idemix reference to the nym secret - sk Big - // pk is the idemix reference to the nym public part - pk Ecp - // exportable if true, sk can be exported via the Bytes function - exportable bool -} - -func computeSKI(serialise func() ([]byte, error)) ([]byte, error) { - raw, err := serialise() - if err != nil { - return nil, err - } - - hash := sha256.New() - hash.Write(raw) - return hash.Sum(nil), nil -} - -func NewNymSecretKey(sk Big, pk Ecp, exportable bool) (*nymSecretKey, error) { - ski, err := computeSKI(sk.Bytes) - if err != nil { - return nil, err - } - - return &nymSecretKey{ski: ski, sk: sk, pk: pk, exportable: exportable}, nil -} - -func (k *nymSecretKey) Bytes() ([]byte, error) { - if k.exportable { - return k.sk.Bytes() - } - - return nil, errors.New("not supported") -} - -func (k *nymSecretKey) SKI() []byte { - c := make([]byte, len(k.ski)) - copy(c, k.ski) - return c -} - -func (*nymSecretKey) Symmetric() bool { - return false -} - -func (*nymSecretKey) Private() bool { - return true -} - -func (k *nymSecretKey) PublicKey() (bccsp.Key, error) { - ski, err := computeSKI(k.pk.Bytes) - if err != nil { - return nil, err - } - return &nymPublicKey{ski: ski, pk: k.pk}, nil -} - -type nymPublicKey struct { - // SKI of this key - ski []byte - // pk is the idemix reference to the nym public part - pk Ecp -} - -func NewNymPublicKey(pk Ecp) *nymPublicKey { - return &nymPublicKey{pk: pk} -} - -func (k *nymPublicKey) Bytes() ([]byte, error) { - return k.pk.Bytes() -} - -func (k *nymPublicKey) SKI() []byte { - c := make([]byte, len(k.ski)) - copy(c, k.ski) - return c -} - -func (*nymPublicKey) Symmetric() bool { - return false -} - -func (*nymPublicKey) Private() bool { - return false -} - -func (k *nymPublicKey) PublicKey() (bccsp.Key, error) { - return k, nil -} - -// NymKeyDerivation derives nyms -type NymKeyDerivation struct { - // Exportable is a flag to allow an issuer secret key to be marked as Exportable. - // If a secret key is marked as Exportable, its Bytes method will return the key's byte representation. - Exportable bool - // User implements the underlying cryptographic algorithms - User User -} - -func (kd *NymKeyDerivation) KeyDeriv(k bccsp.Key, opts bccsp.KeyDerivOpts) (dk bccsp.Key, err error) { - userSecretKey, ok := k.(*userSecretKey) - if !ok { - return nil, errors.New("invalid key, expected *userSecretKey") - } - nymKeyDerivationOpts, ok := opts.(*bccsp.IdemixNymKeyDerivationOpts) - if !ok { - return nil, errors.New("invalid options, expected *IdemixNymKeyDerivationOpts") - } - if nymKeyDerivationOpts.IssuerPK == nil { - return nil, errors.New("invalid options, missing issuer public key") - } - issuerPK, ok := nymKeyDerivationOpts.IssuerPK.(*issuerPublicKey) - if !ok { - return nil, errors.New("invalid options, expected IssuerPK as *issuerPublicKey") - } - - Nym, RandNym, err := kd.User.MakeNym(userSecretKey.sk, issuerPK.pk) - if err != nil { - return nil, err - } - - return NewNymSecretKey(RandNym, Nym, kd.Exportable) -} - -// NymPublicKeyImporter imports nym public keys -type NymPublicKeyImporter struct { - // User implements the underlying cryptographic algorithms - User User -} - -func (i *NymPublicKeyImporter) KeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.Key, err error) { - bytes, ok := raw.([]byte) - if !ok { - return nil, errors.New("invalid raw, expected byte array") - } - - if len(bytes) == 0 { - return nil, errors.New("invalid raw, it must not be nil") - } - - pk, err := i.User.NewPublicNymFromBytes(bytes) - if err != nil { - return nil, err - } - - return &nymPublicKey{pk: pk}, nil -} diff --git a/bccsp/idemix/handlers/nymsigner_test.go b/bccsp/idemix/handlers/nymsigner_test.go deleted file mode 100644 index 8a72aa1ba09..00000000000 --- a/bccsp/idemix/handlers/nymsigner_test.go +++ /dev/null @@ -1,336 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ -package handlers_test - -import ( - "errors" - - "github.com/hyperledger/fabric/bccsp" - "github.com/hyperledger/fabric/bccsp/idemix/handlers" - "github.com/hyperledger/fabric/bccsp/idemix/handlers/mock" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Nym Signature", func() { - Describe("when creating a signature", func() { - var ( - NymSigner *handlers.NymSigner - fakeSignatureScheme *mock.NymSignatureScheme - nymSK bccsp.Key - ) - - BeforeEach(func() { - fakeSignatureScheme = &mock.NymSignatureScheme{} - NymSigner = &handlers.NymSigner{NymSignatureScheme: fakeSignatureScheme} - - var err error - sk := &mock.Big{} - sk.BytesReturns([]byte{1, 2, 3, 4}, nil) - nymSK, err = handlers.NewNymSecretKey(sk, nil, false) - Expect(err).NotTo(HaveOccurred()) - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - var fakeSignature []byte - BeforeEach(func() { - fakeSignature = []byte("fake signature") - fakeSignatureScheme.SignReturns(fakeSignature, nil) - }) - - It("returns no error and a signature", func() { - signature, err := NymSigner.Sign( - handlers.NewUserSecretKey(nil, false), - []byte("a digest"), - &bccsp.IdemixNymSignerOpts{ - Nym: nymSK, - IssuerPK: handlers.NewIssuerPublicKey(nil), - }, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(signature).To(BeEquivalentTo(fakeSignature)) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - fakeSignatureScheme.SignReturns(nil, errors.New("sign error")) - }) - - It("returns an error", func() { - signature, err := NymSigner.Sign( - handlers.NewUserSecretKey(nil, false), - []byte("a digest"), - &bccsp.IdemixNymSignerOpts{ - Nym: nymSK, - IssuerPK: handlers.NewIssuerPublicKey(nil), - }, - ) - Expect(err).To(MatchError("sign error")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the parameters are not well formed", func() { - Context("and the user secret key is nil", func() { - It("returns error", func() { - signature, err := NymSigner.Sign( - nil, - []byte("a digest"), - &bccsp.IdemixNymSignerOpts{ - Nym: nymSK, - IssuerPK: handlers.NewIssuerPublicKey(nil), - }, - ) - Expect(err).To(MatchError("invalid key, expected *userSecretKey")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the user secret key is not of type *userSecretKey", func() { - It("returns error", func() { - signature, err := NymSigner.Sign( - handlers.NewIssuerPublicKey(nil), - []byte("a digest"), - &bccsp.IdemixNymSignerOpts{ - Nym: nymSK, - IssuerPK: handlers.NewIssuerPublicKey(nil), - }, - ) - Expect(err).To(MatchError("invalid key, expected *userSecretKey")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the option is nil", func() { - It("returns error", func() { - signature, err := NymSigner.Sign( - handlers.NewUserSecretKey(nil, false), - []byte("a digest"), - nil, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixNymSignerOpts")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the option is not of type *IdemixNymSignerOpts", func() { - It("returns error", func() { - signature, err := NymSigner.Sign( - handlers.NewUserSecretKey(nil, false), - []byte("a digest"), - &bccsp.IdemixCRISignerOpts{}, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixNymSignerOpts")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the nym is nil", func() { - It("returns error", func() { - signature, err := NymSigner.Sign( - handlers.NewUserSecretKey(nil, false), - []byte("a digest"), - &bccsp.IdemixNymSignerOpts{ - IssuerPK: handlers.NewIssuerPublicKey(nil), - }, - ) - Expect(err).To(MatchError("invalid options, missing nym key")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the nym is not of type *nymSecretKey", func() { - It("returns error", func() { - signature, err := NymSigner.Sign( - handlers.NewUserSecretKey(nil, false), - []byte("a digest"), - &bccsp.IdemixNymSignerOpts{ - Nym: handlers.NewIssuerPublicKey(nil), - IssuerPK: handlers.NewIssuerPublicKey(nil), - }, - ) - Expect(err).To(MatchError("invalid nym key, expected *nymSecretKey")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the IssuerPk is nil", func() { - It("returns error", func() { - signature, err := NymSigner.Sign( - handlers.NewUserSecretKey(nil, false), - []byte("a digest"), - &bccsp.IdemixNymSignerOpts{ - Nym: nymSK, - }, - ) - Expect(err).To(MatchError("invalid options, missing issuer public key")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the IssuerPk is not of type *issuerPublicKey", func() { - It("returns error", func() { - signature, err := NymSigner.Sign( - handlers.NewUserSecretKey(nil, false), - []byte("a digest"), - &bccsp.IdemixNymSignerOpts{ - Nym: nymSK, - IssuerPK: handlers.NewUserSecretKey(nil, false), - }, - ) - Expect(err).To(MatchError("invalid issuer public key, expected *issuerPublicKey")) - Expect(signature).To(BeNil()) - }) - }) - }) - }) - - Describe("when verifying a signature", func() { - var ( - NymVerifier *handlers.NymVerifier - fakeSignatureScheme *mock.NymSignatureScheme - ) - - BeforeEach(func() { - fakeSignatureScheme = &mock.NymSignatureScheme{} - NymVerifier = &handlers.NymVerifier{NymSignatureScheme: fakeSignatureScheme} - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - BeforeEach(func() { - fakeSignatureScheme.VerifyReturns(nil) - }) - - It("returns no error and valid signature", func() { - valid, err := NymVerifier.Verify( - handlers.NewNymPublicKey(nil), - []byte("a signature"), - []byte("a digest"), - &bccsp.IdemixNymSignerOpts{ - IssuerPK: handlers.NewIssuerPublicKey(nil), - }, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(valid).To(BeTrue()) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - fakeSignatureScheme.VerifyReturns(errors.New("verify error")) - }) - - It("returns an error", func() { - valid, err := NymVerifier.Verify( - handlers.NewNymPublicKey(nil), - []byte("a signature"), - []byte("a digest"), - &bccsp.IdemixNymSignerOpts{ - IssuerPK: handlers.NewIssuerPublicKey(nil), - }, - ) - Expect(err).To(MatchError("verify error")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the parameters are not well formed", func() { - Context("and the nym public key is nil", func() { - It("returns error", func() { - valid, err := NymVerifier.Verify( - nil, - []byte("fake signature"), - nil, - &bccsp.IdemixNymSignerOpts{IssuerPK: handlers.NewIssuerPublicKey(nil)}, - ) - Expect(err).To(MatchError("invalid key, expected *nymPublicKey")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the nym public key is not of type *nymPublicKey", func() { - It("returns error", func() { - valid, err := NymVerifier.Verify( - handlers.NewUserSecretKey(nil, false), - []byte("fake signature"), - nil, - &bccsp.IdemixNymSignerOpts{IssuerPK: handlers.NewIssuerPublicKey(nil)}, - ) - Expect(err).To(MatchError("invalid key, expected *nymPublicKey")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the signature is empty", func() { - It("returns error", func() { - valid, err := NymVerifier.Verify( - handlers.NewNymPublicKey(nil), - nil, - []byte("a digest"), - &bccsp.IdemixNymSignerOpts{IssuerPK: handlers.NewIssuerPublicKey(nil)}, - ) - Expect(err).To(MatchError("invalid signature, it must not be empty")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the option is empty", func() { - It("returns error", func() { - valid, err := NymVerifier.Verify( - handlers.NewNymPublicKey(nil), - []byte("a signature"), - []byte("a digest"), - nil, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixNymSignerOpts")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the option is not of type *IdemixNymSignerOpts", func() { - It("returns error", func() { - valid, err := NymVerifier.Verify( - handlers.NewNymPublicKey(nil), - []byte("a signature"), - []byte("a digest"), - &bccsp.IdemixCredentialRequestSignerOpts{}, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixNymSignerOpts")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the option's issuer public key is empty", func() { - It("returns error", func() { - valid, err := NymVerifier.Verify( - handlers.NewNymPublicKey(nil), - []byte("fake signature"), - nil, - &bccsp.IdemixNymSignerOpts{}, - ) - Expect(err).To(MatchError("invalid options, missing issuer public key")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the option's issuer public key is not of type *issuerPublicKey", func() { - It("returns error", func() { - valid, err := NymVerifier.Verify( - handlers.NewNymPublicKey(nil), - []byte("fake signature"), - nil, - &bccsp.IdemixNymSignerOpts{ - IssuerPK: handlers.NewNymPublicKey(nil), - }, - ) - Expect(err).To(MatchError("invalid issuer public key, expected *issuerPublicKey")) - Expect(valid).To(BeFalse()) - }) - }) - }) - }) -}) diff --git a/bccsp/idemix/handlers/revocation_test.go b/bccsp/idemix/handlers/revocation_test.go deleted file mode 100644 index 798773a1314..00000000000 --- a/bccsp/idemix/handlers/revocation_test.go +++ /dev/null @@ -1,411 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ -package handlers_test - -import ( - "crypto/ecdsa" - "crypto/elliptic" - "crypto/rand" - "crypto/sha256" - "crypto/x509" - "encoding/pem" - "math/big" - - "github.com/hyperledger/fabric/bccsp/idemix/handlers" - - "github.com/hyperledger/fabric/bccsp" - "github.com/hyperledger/fabric/bccsp/idemix/handlers/mock" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/pkg/errors" -) - -var _ = Describe("Revocation", func() { - Describe("when creating a revocation key-pair", func() { - var ( - RevocationKeyGen *handlers.RevocationKeyGen - - fakeRevocation *mock.Revocation - fakeRevocationSecretKey bccsp.Key - ) - - BeforeEach(func() { - fakeRevocation = &mock.Revocation{} - - RevocationKeyGen = &handlers.RevocationKeyGen{} - RevocationKeyGen.Revocation = fakeRevocation - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - var ( - sk bccsp.Key - idemixRevocationKey *ecdsa.PrivateKey - SKI []byte - pkBytes []byte - ) - BeforeEach(func() { - idemixRevocationKey = &ecdsa.PrivateKey{ - PublicKey: ecdsa.PublicKey{ - Curve: elliptic.P256(), - X: big.NewInt(1), Y: big.NewInt(1), - }, - D: big.NewInt(1), - } - - raw := elliptic.Marshal(idemixRevocationKey.Curve, idemixRevocationKey.PublicKey.X, idemixRevocationKey.PublicKey.Y) - hash := sha256.New() - hash.Write(raw) - SKI = hash.Sum(nil) - - var err error - pkBytes, err = x509.MarshalPKIXPublicKey(&idemixRevocationKey.PublicKey) - Expect(err).NotTo(HaveOccurred()) - - fakeRevocation.NewKeyReturns(idemixRevocationKey, nil) - - fakeRevocationSecretKey = handlers.NewRevocationSecretKey(idemixRevocationKey, false) - }) - - AfterEach(func() { - Expect(sk.Private()).To(BeTrue()) - Expect(sk.Symmetric()).To(BeFalse()) - Expect(sk.SKI()).NotTo(BeNil()) - Expect(sk.SKI()).To(BeEquivalentTo(SKI)) - - pk, err := sk.PublicKey() - Expect(err).NotTo(HaveOccurred()) - - Expect(pk.Private()).To(BeFalse()) - Expect(pk.Symmetric()).To(BeFalse()) - Expect(pk.SKI()).NotTo(BeNil()) - Expect(pk.SKI()).To(BeEquivalentTo(SKI)) - raw, err := pk.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw).NotTo(BeNil()) - Expect(raw).To(BeEquivalentTo(pkBytes)) - - pk2, err := pk.PublicKey() - Expect(err).NotTo(HaveOccurred()) - Expect(pk).To(BeEquivalentTo(pk2)) - }) - - Context("and the secret key is exportable", func() { - BeforeEach(func() { - RevocationKeyGen.Exportable = true - fakeRevocationSecretKey = handlers.NewRevocationSecretKey(idemixRevocationKey, true) - }) - - It("returns no error and a key", func() { - var err error - sk, err = RevocationKeyGen.KeyGen(&bccsp.IdemixRevocationKeyGenOpts{}) - Expect(err).NotTo(HaveOccurred()) - Expect(sk).To(BeEquivalentTo(fakeRevocationSecretKey)) - - raw, err := sk.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw).NotTo(BeNil()) - Expect(raw).To(BeEquivalentTo(idemixRevocationKey.D.Bytes())) - }) - }) - - Context("and the secret key is not exportable", func() { - BeforeEach(func() { - RevocationKeyGen.Exportable = false - fakeRevocationSecretKey = handlers.NewRevocationSecretKey(idemixRevocationKey, false) - }) - - It("returns no error and a key", func() { - sk, err := RevocationKeyGen.KeyGen(&bccsp.IdemixRevocationKeyGenOpts{}) - Expect(err).NotTo(HaveOccurred()) - Expect(sk).To(BeEquivalentTo(fakeRevocationSecretKey)) - - raw, err := sk.Bytes() - Expect(err).To(MatchError("not exportable")) - Expect(raw).To(BeNil()) - }) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - fakeRevocation.NewKeyReturns(nil, errors.New("new-key error")) - }) - - It("returns an error", func() { - keyPair, err := RevocationKeyGen.KeyGen(&bccsp.IdemixRevocationKeyGenOpts{}) - Expect(err).To(MatchError("new-key error")) - Expect(keyPair).To(BeNil()) - }) - }) - }) - - Context("when importing a revocation public key", func() { - var RevocationPublicKeyImporter *handlers.RevocationPublicKeyImporter - - BeforeEach(func() { - RevocationPublicKeyImporter = &handlers.RevocationPublicKeyImporter{} - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - var ( - raw []byte - pemBytes []byte - ) - - BeforeEach(func() { - key, err := ecdsa.GenerateKey(elliptic.P384(), rand.Reader) - Expect(err).NotTo(HaveOccurred()) - - raw, err = x509.MarshalPKIXPublicKey(key.Public()) - Expect(err).NotTo(HaveOccurred()) - - pemBytes = pem.EncodeToMemory( - &pem.Block{ - Type: "PUBLIC KEY", - Bytes: raw, - }, - ) - }) - - It("import is successful", func() { - k, err := RevocationPublicKeyImporter.KeyImport(pemBytes, nil) - Expect(err).NotTo(HaveOccurred()) - - bytes, err := k.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(bytes).To(BeEquivalentTo(raw)) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - It("returns an error on nil raw", func() { - k, err := RevocationPublicKeyImporter.KeyImport(nil, nil) - Expect(err).To(MatchError("invalid raw, expected byte array")) - Expect(k).To(BeNil()) - }) - - It("returns an error on empty raw", func() { - k, err := RevocationPublicKeyImporter.KeyImport([]byte{}, nil) - Expect(err).To(MatchError("invalid raw, it must not be nil")) - Expect(k).To(BeNil()) - }) - - It("returns an error on invalid raw", func() { - k, err := RevocationPublicKeyImporter.KeyImport(RevocationPublicKeyImporter, nil) - Expect(err).To(MatchError("invalid raw, expected byte array")) - Expect(k).To(BeNil()) - }) - - It("returns an error", func() { - k, err := RevocationPublicKeyImporter.KeyImport([]byte("fake-raw"), nil) - Expect(err).To(MatchError("Failed to decode revocation ECDSA public key")) - Expect(k).To(BeNil()) - }) - }) - }) -}) - -var _ = Describe("CRI", func() { - Describe("when creating a CRI", func() { - var ( - CriSigner *handlers.CriSigner - fakeRevocation *mock.Revocation - ) - - BeforeEach(func() { - fakeRevocation = &mock.Revocation{} - CriSigner = &handlers.CriSigner{Revocation: fakeRevocation} - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - var fakeSignature []byte - BeforeEach(func() { - fakeSignature = []byte("fake signature") - fakeRevocation.SignReturns(fakeSignature, nil) - }) - - It("returns no error and a signature", func() { - signature, err := CriSigner.Sign( - handlers.NewRevocationSecretKey(nil, false), - nil, - &bccsp.IdemixCRISignerOpts{}, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(signature).To(BeEquivalentTo(fakeSignature)) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - fakeRevocation.SignReturns(nil, errors.New("sign error")) - }) - - It("returns an error", func() { - signature, err := CriSigner.Sign( - handlers.NewRevocationSecretKey(nil, false), - nil, - &bccsp.IdemixCRISignerOpts{}, - ) - Expect(err).To(MatchError("sign error")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the parameters are not well formed", func() { - Context("and the revocation secret key is nil", func() { - It("returns error", func() { - signature, err := CriSigner.Sign( - nil, - nil, - nil, - ) - Expect(err).To(MatchError("invalid key, expected *revocationSecretKey")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the revocation secret key is not of type *revocationSecretKey", func() { - It("returns error", func() { - signature, err := CriSigner.Sign( - handlers.NewIssuerPublicKey(nil), - nil, - nil, - ) - Expect(err).To(MatchError("invalid key, expected *revocationSecretKey")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - }) - - It("returns an error", func() { - signature, err := CriSigner.Sign( - handlers.NewRevocationSecretKey(nil, false), - nil, - nil, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixCRISignerOpts")) - Expect(signature).To(BeNil()) - }) - }) - }) - }) - - Describe("when verifying a CRI", func() { - var ( - CriVerifier *handlers.CriVerifier - fakeRevocation *mock.Revocation - ) - - BeforeEach(func() { - fakeRevocation = &mock.Revocation{} - CriVerifier = &handlers.CriVerifier{Revocation: fakeRevocation} - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - BeforeEach(func() { - fakeRevocation.VerifyReturns(nil) - }) - - It("returns no error and valid signature", func() { - valid, err := CriVerifier.Verify( - handlers.NewRevocationPublicKey(nil), - []byte("fake signature"), - nil, - &bccsp.IdemixCRISignerOpts{}, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(valid).To(BeTrue()) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - fakeRevocation.VerifyReturns(errors.New("verify error")) - }) - - It("returns an error", func() { - valid, err := CriVerifier.Verify( - handlers.NewRevocationPublicKey(nil), - []byte("fake signature"), - nil, - &bccsp.IdemixCRISignerOpts{}, - ) - Expect(err).To(MatchError("verify error")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the parameters are not well formed", func() { - Context("and the user secret key is nil", func() { - It("returns error", func() { - valid, err := CriVerifier.Verify( - nil, - []byte("fake signature"), - nil, - &bccsp.IdemixCRISignerOpts{}, - ) - Expect(err).To(MatchError("invalid key, expected *revocationPublicKey")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the user secret key is not of type *revocationPublicKey", func() { - It("returns error", func() { - valid, err := CriVerifier.Verify( - handlers.NewIssuerPublicKey(nil), - []byte("fake signature"), - nil, - &bccsp.IdemixCRISignerOpts{}, - ) - Expect(err).To(MatchError("invalid key, expected *revocationPublicKey")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the signature is empty", func() { - It("returns error", func() { - valid, err := CriVerifier.Verify( - handlers.NewRevocationPublicKey(nil), - nil, - nil, - &bccsp.IdemixCRISignerOpts{}, - ) - Expect(err).To(MatchError("invalid signature, it must not be empty")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the option is empty", func() { - It("returns error", func() { - valid, err := CriVerifier.Verify( - handlers.NewRevocationPublicKey(nil), - []byte("fake signature"), - nil, - nil, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixCRISignerOpts")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the option is not of type *IdemixCRISignerOpts", func() { - It("returns error", func() { - valid, err := CriVerifier.Verify( - handlers.NewRevocationPublicKey(nil), - []byte("fake signature"), - nil, - &bccsp.IdemixCredentialRequestSignerOpts{}, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixCRISignerOpts")) - Expect(valid).To(BeFalse()) - }) - }) - }) - }) -}) diff --git a/bccsp/idemix/handlers/signer_test.go b/bccsp/idemix/handlers/signer_test.go deleted file mode 100644 index 5b6e95a2f49..00000000000 --- a/bccsp/idemix/handlers/signer_test.go +++ /dev/null @@ -1,336 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ -package handlers_test - -import ( - "errors" - - "github.com/hyperledger/fabric/bccsp" - "github.com/hyperledger/fabric/bccsp/idemix/handlers" - "github.com/hyperledger/fabric/bccsp/idemix/handlers/mock" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Signature", func() { - Describe("when creating a signature", func() { - var ( - Signer *handlers.Signer - fakeSignatureScheme *mock.SignatureScheme - nymSK bccsp.Key - ) - - BeforeEach(func() { - fakeSignatureScheme = &mock.SignatureScheme{} - Signer = &handlers.Signer{SignatureScheme: fakeSignatureScheme} - - var err error - sk := &mock.Big{} - sk.BytesReturns([]byte{1, 2, 3, 4}, nil) - nymSK, err = handlers.NewNymSecretKey(sk, nil, false) - Expect(err).NotTo(HaveOccurred()) - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - var fakeSignature []byte - BeforeEach(func() { - fakeSignature = []byte("fake signature") - fakeSignatureScheme.SignReturns(fakeSignature, nil) - }) - - It("returns no error and a signature", func() { - signature, err := Signer.Sign( - handlers.NewUserSecretKey(nil, false), - []byte("a digest"), - &bccsp.IdemixSignerOpts{ - Nym: nymSK, - IssuerPK: handlers.NewIssuerPublicKey(nil), - }, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(signature).To(BeEquivalentTo(fakeSignature)) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - fakeSignatureScheme.SignReturns(nil, errors.New("sign error")) - }) - - It("returns an error", func() { - signature, err := Signer.Sign( - handlers.NewUserSecretKey(nil, false), - []byte("a digest"), - &bccsp.IdemixSignerOpts{ - Nym: nymSK, - IssuerPK: handlers.NewIssuerPublicKey(nil), - }, - ) - Expect(err).To(MatchError("sign error")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the parameters are not well formed", func() { - Context("and the user secret key is nil", func() { - It("returns error", func() { - signature, err := Signer.Sign( - nil, - []byte("a digest"), - &bccsp.IdemixSignerOpts{ - Nym: nymSK, - IssuerPK: handlers.NewIssuerPublicKey(nil), - }, - ) - Expect(err).To(MatchError("invalid key, expected *userSecretKey")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the user secret key is not of type *userSecretKey", func() { - It("returns error", func() { - signature, err := Signer.Sign( - handlers.NewIssuerPublicKey(nil), - []byte("a digest"), - &bccsp.IdemixSignerOpts{ - Nym: nymSK, - IssuerPK: handlers.NewIssuerPublicKey(nil), - }, - ) - Expect(err).To(MatchError("invalid key, expected *userSecretKey")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the option is nil", func() { - It("returns error", func() { - signature, err := Signer.Sign( - handlers.NewUserSecretKey(nil, false), - []byte("a digest"), - nil, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixSignerOpts")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the option is not of type *IdemixSignerOpts", func() { - It("returns error", func() { - signature, err := Signer.Sign( - handlers.NewUserSecretKey(nil, false), - []byte("a digest"), - &bccsp.IdemixCRISignerOpts{}, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixSignerOpts")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the nym is nil", func() { - It("returns error", func() { - signature, err := Signer.Sign( - handlers.NewUserSecretKey(nil, false), - []byte("a digest"), - &bccsp.IdemixSignerOpts{ - IssuerPK: handlers.NewIssuerPublicKey(nil), - }, - ) - Expect(err).To(MatchError("invalid options, missing nym key")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the nym is not of type *nymSecretKey", func() { - It("returns error", func() { - signature, err := Signer.Sign( - handlers.NewUserSecretKey(nil, false), - []byte("a digest"), - &bccsp.IdemixSignerOpts{ - Nym: handlers.NewIssuerPublicKey(nil), - IssuerPK: handlers.NewIssuerPublicKey(nil), - }, - ) - Expect(err).To(MatchError("invalid nym key, expected *nymSecretKey")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the IssuerPk is nil", func() { - It("returns error", func() { - signature, err := Signer.Sign( - handlers.NewUserSecretKey(nil, false), - []byte("a digest"), - &bccsp.IdemixSignerOpts{ - Nym: nymSK, - }, - ) - Expect(err).To(MatchError("invalid options, missing issuer public key")) - Expect(signature).To(BeNil()) - }) - }) - - Context("and the IssuerPk is not of type *issuerPublicKey", func() { - It("returns error", func() { - signature, err := Signer.Sign( - handlers.NewUserSecretKey(nil, false), - []byte("a digest"), - &bccsp.IdemixSignerOpts{ - Nym: nymSK, - IssuerPK: handlers.NewUserSecretKey(nil, false), - }, - ) - Expect(err).To(MatchError("invalid issuer public key, expected *issuerPublicKey")) - Expect(signature).To(BeNil()) - }) - }) - }) - }) - - Describe("when verifying a signature", func() { - var ( - Verifier *handlers.Verifier - fakeSignatureScheme *mock.SignatureScheme - ) - - BeforeEach(func() { - fakeSignatureScheme = &mock.SignatureScheme{} - Verifier = &handlers.Verifier{SignatureScheme: fakeSignatureScheme} - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - BeforeEach(func() { - fakeSignatureScheme.VerifyReturns(nil) - }) - - It("returns no error and valid signature", func() { - valid, err := Verifier.Verify( - handlers.NewIssuerPublicKey(nil), - []byte("a signature"), - []byte("a digest"), - &bccsp.IdemixSignerOpts{ - RevocationPublicKey: handlers.NewRevocationPublicKey(nil), - }, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(valid).To(BeTrue()) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - fakeSignatureScheme.VerifyReturns(errors.New("verify error")) - }) - - It("returns an error", func() { - valid, err := Verifier.Verify( - handlers.NewIssuerPublicKey(nil), - []byte("a signature"), - []byte("a digest"), - &bccsp.IdemixSignerOpts{ - RevocationPublicKey: handlers.NewRevocationPublicKey(nil), - }, - ) - Expect(err).To(MatchError("verify error")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the parameters are not well formed", func() { - Context("and the issuer public key is nil", func() { - It("returns error", func() { - valid, err := Verifier.Verify( - nil, - []byte("fake signature"), - nil, - &bccsp.IdemixSignerOpts{IssuerPK: handlers.NewIssuerPublicKey(nil)}, - ) - Expect(err).To(MatchError("invalid key, expected *issuerPublicKey")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the issuer public key is not of type *issuerPublicKey", func() { - It("returns error", func() { - valid, err := Verifier.Verify( - handlers.NewUserSecretKey(nil, false), - []byte("fake signature"), - nil, - &bccsp.IdemixSignerOpts{IssuerPK: handlers.NewIssuerPublicKey(nil)}, - ) - Expect(err).To(MatchError("invalid key, expected *issuerPublicKey")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the signature is empty", func() { - It("returns error", func() { - valid, err := Verifier.Verify( - handlers.NewIssuerPublicKey(nil), - nil, - []byte("a digest"), - &bccsp.IdemixSignerOpts{ - RevocationPublicKey: handlers.NewRevocationPublicKey(nil), - }, - ) - Expect(err).To(MatchError("invalid signature, it must not be empty")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the option is empty", func() { - It("returns error", func() { - valid, err := Verifier.Verify( - handlers.NewIssuerPublicKey(nil), - []byte("a signature"), - []byte("a digest"), - nil, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixSignerOpts")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the option is not of type *IdemixSignerOpts", func() { - It("returns error", func() { - valid, err := Verifier.Verify( - handlers.NewIssuerPublicKey(nil), - []byte("a signature"), - []byte("a digest"), - &bccsp.IdemixCredentialRequestSignerOpts{}, - ) - Expect(err).To(MatchError("invalid options, expected *IdemixSignerOpts")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the option's revocation public key is empty", func() { - It("returns error", func() { - valid, err := Verifier.Verify( - handlers.NewIssuerPublicKey(nil), - []byte("fake signature"), - nil, - &bccsp.IdemixSignerOpts{}, - ) - Expect(err).To(MatchError("invalid options, expected *revocationPublicKey")) - Expect(valid).To(BeFalse()) - }) - }) - - Context("and the option's revocation public key is not of type *revocationPublicKey", func() { - It("returns error", func() { - valid, err := Verifier.Verify( - handlers.NewIssuerPublicKey(nil), - []byte("fake signature"), - nil, - &bccsp.IdemixSignerOpts{RevocationPublicKey: handlers.NewUserSecretKey(nil, false)}, - ) - Expect(err).To(MatchError("invalid options, expected *revocationPublicKey")) - Expect(valid).To(BeFalse()) - }) - }) - }) - }) -}) diff --git a/bccsp/idemix/handlers/user_test.go b/bccsp/idemix/handlers/user_test.go deleted file mode 100644 index 08ef3c3c2a3..00000000000 --- a/bccsp/idemix/handlers/user_test.go +++ /dev/null @@ -1,401 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ -package handlers_test - -import ( - "crypto/sha256" - - "github.com/hyperledger/fabric/bccsp" - "github.com/hyperledger/fabric/bccsp/idemix/handlers" - "github.com/hyperledger/fabric/bccsp/idemix/handlers/mock" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/pkg/errors" -) - -var _ = Describe("User", func() { - var ( - fakeUser *mock.User - fakeUserSecretKey bccsp.Key - ) - - BeforeEach(func() { - fakeUser = &mock.User{} - }) - - Describe("when creating a user key", func() { - var UserKeyGen *handlers.UserKeyGen - - BeforeEach(func() { - UserKeyGen = &handlers.UserKeyGen{} - UserKeyGen.User = fakeUser - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - var ( - sk bccsp.Key - fakeIdemixKey *mock.Big - SKI []byte - ) - BeforeEach(func() { - fakeIdemixKey = &mock.Big{} - fakeIdemixKey.BytesReturns([]byte{1, 2, 3, 4}, nil) - - fakeUser.NewKeyReturns(fakeIdemixKey, nil) - hash := sha256.New() - hash.Write([]byte{1, 2, 3, 4}) - SKI = hash.Sum(nil) - - fakeUserSecretKey = handlers.NewUserSecretKey(fakeIdemixKey, false) - }) - - AfterEach(func() { - Expect(sk.Private()).To(BeTrue()) - Expect(sk.Symmetric()).To(BeTrue()) - Expect(sk.SKI()).NotTo(BeNil()) - Expect(sk.SKI()).To(BeEquivalentTo(SKI)) - - pk, err := sk.PublicKey() - Expect(err).To(MatchError("cannot call this method on a symmetric key")) - Expect(pk).To(BeNil()) - }) - - Context("and the secret key is exportable", func() { - BeforeEach(func() { - UserKeyGen.Exportable = true - fakeUserSecretKey = handlers.NewUserSecretKey(fakeIdemixKey, true) - }) - - It("returns no error and a key", func() { - var err error - sk, err = UserKeyGen.KeyGen(&bccsp.IdemixUserSecretKeyGenOpts{}) - Expect(err).NotTo(HaveOccurred()) - Expect(sk).To(BeEquivalentTo(fakeUserSecretKey)) - - raw, err := sk.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw).NotTo(BeNil()) - Expect(raw).To(BeEquivalentTo([]byte{1, 2, 3, 4})) - }) - }) - - Context("and the secret key is not exportable", func() { - BeforeEach(func() { - UserKeyGen.Exportable = false - fakeUserSecretKey = handlers.NewUserSecretKey(fakeIdemixKey, false) - }) - - It("returns no error and a key", func() { - sk, err := UserKeyGen.KeyGen(&bccsp.IdemixUserSecretKeyGenOpts{}) - Expect(err).NotTo(HaveOccurred()) - Expect(sk).To(BeEquivalentTo(fakeUserSecretKey)) - - raw, err := sk.Bytes() - Expect(err).To(MatchError("not exportable")) - Expect(raw).To(BeNil()) - }) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - fakeUser.NewKeyReturns(nil, errors.New("new-key error")) - }) - - It("returns an error", func() { - keyPair, err := UserKeyGen.KeyGen(&bccsp.IdemixUserSecretKeyGenOpts{}) - Expect(err).To(MatchError("new-key error")) - Expect(keyPair).To(BeNil()) - }) - }) - }) - - Describe("when deriving a new pseudonym", func() { - var ( - NymKeyDerivation *handlers.NymKeyDerivation - fakeIssuerPublicKey bccsp.Key - ) - - BeforeEach(func() { - NymKeyDerivation = &handlers.NymKeyDerivation{} - NymKeyDerivation.User = fakeUser - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - var ( - nym bccsp.Key - userKey *mock.Big - fakeNym bccsp.Key - result2 *mock.Big - result1 *mock.Ecp - ) - - BeforeEach(func() { - result2 = &mock.Big{} - result2.BytesReturns([]byte{1, 2, 3, 4}, nil) - result1 = &mock.Ecp{} - result1.BytesReturns([]byte{5, 6, 7, 8}, nil) - - fakeUser.MakeNymReturns(result1, result2, nil) - }) - - AfterEach(func() { - Expect(nym.Private()).To(BeTrue()) - Expect(nym.Symmetric()).To(BeFalse()) - Expect(nym.SKI()).NotTo(BeNil()) - - pk, err := nym.PublicKey() - Expect(err).NotTo(HaveOccurred()) - - Expect(pk.Private()).To(BeFalse()) - Expect(pk.Symmetric()).To(BeFalse()) - Expect(pk.SKI()).NotTo(BeNil()) - raw, err := pk.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw).NotTo(BeNil()) - - pk2, err := pk.PublicKey() - Expect(err).NotTo(HaveOccurred()) - Expect(pk).To(BeEquivalentTo(pk2)) - }) - - Context("and the secret key is exportable", func() { - BeforeEach(func() { - var err error - NymKeyDerivation.Exportable = true - fakeUserSecretKey = handlers.NewUserSecretKey(userKey, true) - fakeIssuerPublicKey = handlers.NewIssuerPublicKey(nil) - fakeNym, err = handlers.NewNymSecretKey(result2, result1, true) - Expect(err).NotTo(HaveOccurred()) - }) - - It("returns no error and a key", func() { - var err error - nym, err = NymKeyDerivation.KeyDeriv(fakeUserSecretKey, &bccsp.IdemixNymKeyDerivationOpts{IssuerPK: fakeIssuerPublicKey}) - Expect(err).NotTo(HaveOccurred()) - Expect(nym).To(BeEquivalentTo(fakeNym)) - - raw, err := nym.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(raw).NotTo(BeNil()) - }) - }) - - Context("and the secret key is not exportable", func() { - BeforeEach(func() { - var err error - NymKeyDerivation.Exportable = false - fakeUserSecretKey = handlers.NewUserSecretKey(userKey, false) - fakeNym, err = handlers.NewNymSecretKey(result2, result1, false) - Expect(err).NotTo(HaveOccurred()) - }) - - It("returns no error and a key", func() { - var err error - nym, err = NymKeyDerivation.KeyDeriv(fakeUserSecretKey, &bccsp.IdemixNymKeyDerivationOpts{IssuerPK: fakeIssuerPublicKey}) - Expect(err).NotTo(HaveOccurred()) - Expect(nym).To(BeEquivalentTo(fakeNym)) - - raw, err := nym.Bytes() - Expect(err).To(HaveOccurred()) - Expect(raw).To(BeNil()) - }) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - fakeUserSecretKey = handlers.NewUserSecretKey(nil, true) - fakeIssuerPublicKey = handlers.NewIssuerPublicKey(nil) - fakeUser.MakeNymReturns(nil, nil, errors.New("make-nym error")) - }) - - It("returns an error", func() { - nym, err := NymKeyDerivation.KeyDeriv(fakeUserSecretKey, &bccsp.IdemixNymKeyDerivationOpts{IssuerPK: fakeIssuerPublicKey}) - Expect(err).To(MatchError("make-nym error")) - Expect(nym).To(BeNil()) - }) - }) - - Context("and the options are not well formed", func() { - Context("and the user secret key is nil", func() { - It("returns error", func() { - nym, err := NymKeyDerivation.KeyDeriv(nil, &bccsp.IdemixNymKeyDerivationOpts{}) - Expect(err).To(MatchError("invalid key, expected *userSecretKey")) - Expect(nym).To(BeNil()) - }) - }) - - Context("and the user secret key is not of type *userSecretKey", func() { - It("returns error", func() { - nym, err := NymKeyDerivation.KeyDeriv(handlers.NewIssuerPublicKey(nil), &bccsp.IdemixNymKeyDerivationOpts{}) - Expect(err).To(MatchError("invalid key, expected *userSecretKey")) - Expect(nym).To(BeNil()) - }) - }) - - Context("and the option is missing", func() { - BeforeEach(func() { - fakeUserSecretKey = handlers.NewUserSecretKey(nil, false) - }) - - It("returns error", func() { - nym, err := NymKeyDerivation.KeyDeriv(fakeUserSecretKey, nil) - Expect(err).To(MatchError("invalid options, expected *IdemixNymKeyDerivationOpts")) - Expect(nym).To(BeNil()) - }) - }) - - Context("and the option is not of type *bccsp.IdemixNymKeyDerivationOpts", func() { - BeforeEach(func() { - fakeUserSecretKey = handlers.NewUserSecretKey(nil, false) - }) - - It("returns error", func() { - nym, err := NymKeyDerivation.KeyDeriv(fakeUserSecretKey, &bccsp.AESKeyGenOpts{}) - Expect(err).To(MatchError("invalid options, expected *IdemixNymKeyDerivationOpts")) - Expect(nym).To(BeNil()) - }) - }) - - Context("and the issuer public key is missing", func() { - BeforeEach(func() { - fakeUserSecretKey = handlers.NewUserSecretKey(nil, false) - }) - - It("returns error", func() { - nym, err := NymKeyDerivation.KeyDeriv(fakeUserSecretKey, &bccsp.IdemixNymKeyDerivationOpts{}) - Expect(err).To(MatchError("invalid options, missing issuer public key")) - Expect(nym).To(BeNil()) - }) - }) - - Context("and the issuer public key is not of type *issuerPublicKey", func() { - BeforeEach(func() { - fakeUserSecretKey = handlers.NewUserSecretKey(nil, false) - }) - - It("returns error", func() { - nym, err := NymKeyDerivation.KeyDeriv(fakeUserSecretKey, &bccsp.IdemixNymKeyDerivationOpts{IssuerPK: fakeUserSecretKey}) - Expect(err).To(MatchError("invalid options, expected IssuerPK as *issuerPublicKey")) - Expect(nym).To(BeNil()) - }) - }) - }) - }) - - Context("when importing a user key", func() { - var UserKeyImporter *handlers.UserKeyImporter - - BeforeEach(func() { - UserKeyImporter = &handlers.UserKeyImporter{Exportable: true, User: fakeUser} - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - BeforeEach(func() { - sk := &mock.Big{} - sk.BytesReturns([]byte("fake-pk-bytes"), nil) - - fakeUser.NewKeyFromBytesReturns(sk, nil) - }) - - It("import is successful", func() { - k, err := UserKeyImporter.KeyImport([]byte("fake-raw"), nil) - Expect(err).NotTo(HaveOccurred()) - - bytes, err := k.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(bytes).To(BeEquivalentTo([]byte("fake-pk-bytes"))) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - fakeUser.NewKeyFromBytesReturns(nil, errors.New("new-public-key-nym-import-err")) - }) - - It("returns an error on nil raw", func() { - k, err := UserKeyImporter.KeyImport(nil, nil) - Expect(err).To(MatchError("invalid raw, expected byte array")) - Expect(k).To(BeNil()) - }) - - It("returns an error on empty raw", func() { - k, err := UserKeyImporter.KeyImport([]byte{}, nil) - Expect(err).To(MatchError("invalid raw, it must not be nil")) - Expect(k).To(BeNil()) - }) - - It("returns an error on invalid raw", func() { - k, err := UserKeyImporter.KeyImport(UserKeyImporter, nil) - Expect(err).To(MatchError("invalid raw, expected byte array")) - Expect(k).To(BeNil()) - }) - - It("returns an error", func() { - k, err := UserKeyImporter.KeyImport([]byte("fake-raw"), nil) - Expect(err).To(MatchError("new-public-key-nym-import-err")) - Expect(k).To(BeNil()) - }) - }) - }) - - Context("when importing a nym public key", func() { - var NymPublicKeyImporter *handlers.NymPublicKeyImporter - - BeforeEach(func() { - NymPublicKeyImporter = &handlers.NymPublicKeyImporter{User: fakeUser} - }) - - Context("and the underlying cryptographic algorithm succeed", func() { - BeforeEach(func() { - ecp := &mock.Ecp{} - ecp.BytesReturns([]byte("fake-pk-bytes"), nil) - - fakeUser.NewPublicNymFromBytesReturns(ecp, nil) - }) - - It("import is successful", func() { - k, err := NymPublicKeyImporter.KeyImport([]byte("fake-raw"), nil) - Expect(err).NotTo(HaveOccurred()) - - bytes, err := k.Bytes() - Expect(err).NotTo(HaveOccurred()) - Expect(bytes).To(BeEquivalentTo([]byte("fake-pk-bytes"))) - }) - }) - - Context("and the underlying cryptographic algorithm fails", func() { - BeforeEach(func() { - fakeUser.NewPublicNymFromBytesReturns(nil, errors.New("new-public-key-nym-import-err")) - }) - - It("returns an error on nil raw", func() { - k, err := NymPublicKeyImporter.KeyImport(nil, nil) - Expect(err).To(MatchError("invalid raw, expected byte array")) - Expect(k).To(BeNil()) - }) - - It("returns an error on empty raw", func() { - k, err := NymPublicKeyImporter.KeyImport([]byte{}, nil) - Expect(err).To(MatchError("invalid raw, it must not be nil")) - Expect(k).To(BeNil()) - }) - - It("returns an error on invalid raw", func() { - k, err := NymPublicKeyImporter.KeyImport(NymPublicKeyImporter, nil) - Expect(err).To(MatchError("invalid raw, expected byte array")) - Expect(k).To(BeNil()) - }) - - It("returns an error", func() { - k, err := NymPublicKeyImporter.KeyImport([]byte("fake-raw"), nil) - Expect(err).To(MatchError("new-public-key-nym-import-err")) - Expect(k).To(BeNil()) - }) - }) - }) -}) diff --git a/bccsp/idemix/idemix_suite_test.go b/bccsp/idemix/idemix_suite_test.go deleted file mode 100644 index c5a92d8290b..00000000000 --- a/bccsp/idemix/idemix_suite_test.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ -package idemix_test - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestPlain(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Plain Suite") -} diff --git a/cmd/idemixgen/main.go b/cmd/idemixgen/main.go deleted file mode 100644 index adb198d1be5..00000000000 --- a/cmd/idemixgen/main.go +++ /dev/null @@ -1,203 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package main - -// idemixgen is a command line tool that generates the CA's keys and -// generates MSP configs for siging and for verification -// This tool can be used to setup the peers and CA to support -// the Identity Mixer MSP - -import ( - "crypto/ecdsa" - "crypto/x509" - "encoding/pem" - "fmt" - "io/ioutil" - "os" - "path/filepath" - - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric/common/tools/idemixgen/idemixca" - "github.com/hyperledger/fabric/common/tools/idemixgen/metadata" - "github.com/hyperledger/fabric/idemix" - "github.com/hyperledger/fabric/msp" - "github.com/pkg/errors" - "gopkg.in/alecthomas/kingpin.v2" -) - -const ( - IdemixDirIssuer = "ca" - IdemixConfigIssuerSecretKey = "IssuerSecretKey" - IdemixConfigRevocationKey = "RevocationKey" -) - -// command line flags -var ( - app = kingpin.New("idemixgen", "Utility for generating key material to be used with the Identity Mixer MSP in Hyperledger Fabric") - - outputDir = app.Flag("output", "The output directory in which to place artifacts").Default("idemix-config").String() - - genIssuerKey = app.Command("ca-keygen", "Generate CA key material") - genSignerConfig = app.Command("signerconfig", "Generate a default signer for this Idemix MSP") - genCAInput = genSignerConfig.Flag("ca-input", "The folder where CA's secrets are stored").String() - genCredOU = genSignerConfig.Flag("org-unit", "The Organizational Unit of the default signer").Short('u').String() - genCredIsAdmin = genSignerConfig.Flag("admin", "Make the default signer admin").Short('a').Bool() - genCredEnrollmentId = genSignerConfig.Flag("enrollmentId", "The enrollment id of the default signer").Short('e').String() - genCredRevocationHandle = genSignerConfig.Flag("revocationHandle", "The handle used to revoke this signer").Short('r').Int() - - version = app.Command("version", "Show version information") -) - -func main() { - app.HelpFlag.Short('h') - - switch kingpin.MustParse(app.Parse(os.Args[1:])) { - - case genIssuerKey.FullCommand(): - isk, ipk, err := idemixca.GenerateIssuerKey() - handleError(err) - - revocationKey, err := idemix.GenerateLongTermRevocationKey() - handleError(err) - encodedRevocationSK, err := x509.MarshalECPrivateKey(revocationKey) - handleError(err) - pemEncodedRevocationSK := pem.EncodeToMemory(&pem.Block{Type: "PRIVATE KEY", Bytes: encodedRevocationSK}) - handleError(err) - encodedRevocationPK, err := x509.MarshalPKIXPublicKey(revocationKey.Public()) - handleError(err) - pemEncodedRevocationPK := pem.EncodeToMemory(&pem.Block{Type: "PUBLIC KEY", Bytes: encodedRevocationPK}) - - // Prevent overwriting the existing key - path := filepath.Join(*outputDir, IdemixDirIssuer) - checkDirectoryNotExists(path, fmt.Sprintf("Directory %s already exists", path)) - - path = filepath.Join(*outputDir, msp.IdemixConfigDirMsp) - checkDirectoryNotExists(path, fmt.Sprintf("Directory %s already exists", path)) - - // write private and public keys to the file - handleError(os.MkdirAll(filepath.Join(*outputDir, IdemixDirIssuer), 0o770)) - handleError(os.MkdirAll(filepath.Join(*outputDir, msp.IdemixConfigDirMsp), 0o770)) - writeFile(filepath.Join(*outputDir, IdemixDirIssuer, IdemixConfigIssuerSecretKey), isk) - writeFile(filepath.Join(*outputDir, IdemixDirIssuer, IdemixConfigRevocationKey), pemEncodedRevocationSK) - writeFile(filepath.Join(*outputDir, IdemixDirIssuer, msp.IdemixConfigFileIssuerPublicKey), ipk) - writeFile(filepath.Join(*outputDir, msp.IdemixConfigDirMsp, msp.IdemixConfigFileRevocationPublicKey), pemEncodedRevocationPK) - writeFile(filepath.Join(*outputDir, msp.IdemixConfigDirMsp, msp.IdemixConfigFileIssuerPublicKey), ipk) - - case genSignerConfig.FullCommand(): - roleMask := 0 - if *genCredIsAdmin { - roleMask = msp.GetRoleMaskFromIdemixRole(msp.ADMIN) - } else { - roleMask = msp.GetRoleMaskFromIdemixRole(msp.MEMBER) - } - if *genCAInput == "" { - genCAInput = outputDir - } - ipk, ipkRaw := readIssuerKey() - rsk := readRevocationKey() - rpk := readRevocationPublicKey() - - config, err := idemixca.GenerateSignerConfig( - roleMask, - *genCredOU, - *genCredEnrollmentId, - *genCredRevocationHandle, - ipk, rsk, - ) - handleError(err) - - path := filepath.Join(*outputDir, msp.IdemixConfigDirUser) - checkDirectoryNotExists(path, fmt.Sprintf("This MSP config already contains a directory \"%s\"", path)) - - // Write config to file - handleError(os.MkdirAll(filepath.Join(*outputDir, msp.IdemixConfigDirUser), 0o770)) - writeFile(filepath.Join(*outputDir, msp.IdemixConfigDirUser, msp.IdemixConfigFileSigner), config) - - // Write CA public info in case genCAInput != outputDir - if *genCAInput != *outputDir { - handleError(os.MkdirAll(filepath.Join(*outputDir, msp.IdemixConfigDirMsp), 0o770)) - writeFile(filepath.Join(*outputDir, msp.IdemixConfigDirMsp, msp.IdemixConfigFileRevocationPublicKey), rpk) - writeFile(filepath.Join(*outputDir, msp.IdemixConfigDirMsp, msp.IdemixConfigFileIssuerPublicKey), ipkRaw) - } - - case version.FullCommand(): - printVersion() - - } -} - -func printVersion() { - fmt.Println(metadata.GetVersionInfo()) -} - -// writeFile writes bytes to a file and panics in case of an error -func writeFile(path string, contents []byte) { - handleError(ioutil.WriteFile(path, contents, 0o640)) -} - -// readIssuerKey reads the issuer key from the current directory -func readIssuerKey() (*idemix.IssuerKey, []byte) { - path := filepath.Join(*genCAInput, IdemixDirIssuer, IdemixConfigIssuerSecretKey) - isk, err := ioutil.ReadFile(path) - if err != nil { - handleError(errors.Wrapf(err, "failed to open issuer secret key file: %s", path)) - } - path = filepath.Join(*genCAInput, IdemixDirIssuer, msp.IdemixConfigFileIssuerPublicKey) - ipkBytes, err := ioutil.ReadFile(path) - if err != nil { - handleError(errors.Wrapf(err, "failed to open issuer public key file: %s", path)) - } - ipk := &idemix.IssuerPublicKey{} - handleError(proto.Unmarshal(ipkBytes, ipk)) - key := &idemix.IssuerKey{Isk: isk, Ipk: ipk} - - return key, ipkBytes -} - -func readRevocationKey() *ecdsa.PrivateKey { - path := filepath.Join(*genCAInput, IdemixDirIssuer, IdemixConfigRevocationKey) - keyBytes, err := ioutil.ReadFile(path) - if err != nil { - handleError(errors.Wrapf(err, "failed to open revocation secret key file: %s", path)) - } - - block, _ := pem.Decode(keyBytes) - if block == nil { - handleError(errors.Errorf("failed to decode ECDSA private key")) - } - key, err := x509.ParseECPrivateKey(block.Bytes) - handleError(err) - - return key -} - -func readRevocationPublicKey() []byte { - path := filepath.Join(*genCAInput, msp.IdemixConfigDirMsp, msp.IdemixConfigFileRevocationPublicKey) - keyBytes, err := ioutil.ReadFile(path) - if err != nil { - handleError(errors.Wrapf(err, "failed to open revocation secret key file: %s", path)) - } - - return keyBytes -} - -// checkDirectoryNotExists checks whether a directory with the given path already exists and exits if this is the case -func checkDirectoryNotExists(path string, errorMessage string) { - _, err := os.Stat(path) - if err == nil { - handleError(errors.New(errorMessage)) - } -} - -//lint:file-ignore SA5011 handleError is unconventional - -func handleError(err error) { - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} diff --git a/common/tools/idemixgen/idemixca/idemixca.go b/common/tools/idemixgen/idemixca/idemixca.go deleted file mode 100644 index c162f026ce5..00000000000 --- a/common/tools/idemixgen/idemixca/idemixca.go +++ /dev/null @@ -1,98 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package idemixca - -import ( - "crypto/ecdsa" - - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" - m "github.com/hyperledger/fabric-protos-go/msp" - "github.com/hyperledger/fabric/idemix" - "github.com/hyperledger/fabric/msp" - "github.com/pkg/errors" -) - -// GenerateIssuerKey invokes Idemix library to generate an issuer (CA) signing key pair. -// Currently four attributes are supported by the issuer: -// AttributeNameOU is the organization unit name -// AttributeNameRole is the role (member or admin) name -// AttributeNameEnrollmentId is the enrollment id -// AttributeNameRevocationHandle contains the revocation handle, which can be used to revoke this user -// Generated keys are serialized to bytes. -func GenerateIssuerKey() ([]byte, []byte, error) { - rng, err := idemix.GetRand() - if err != nil { - return nil, nil, err - } - AttributeNames := []string{msp.AttributeNameOU, msp.AttributeNameRole, msp.AttributeNameEnrollmentId, msp.AttributeNameRevocationHandle} - key, err := idemix.NewIssuerKey(AttributeNames, rng) - if err != nil { - return nil, nil, errors.WithMessage(err, "cannot generate CA key") - } - ipkSerialized, err := proto.Marshal(key.Ipk) - - return key.Isk, ipkSerialized, err -} - -// GenerateSignerConfig creates a new signer config. -// It generates a fresh user secret and issues a credential -// with four attributes (described above) using the CA's key pair. -func GenerateSignerConfig(roleMask int, ouString string, enrollmentId string, revocationHandle int, key *idemix.IssuerKey, revKey *ecdsa.PrivateKey) ([]byte, error) { - attrs := make([]*FP256BN.BIG, 4) - - if ouString == "" { - return nil, errors.Errorf("the OU attribute value is empty") - } - - if enrollmentId == "" { - return nil, errors.Errorf("the enrollment id value is empty") - } - - attrs[msp.AttributeIndexOU] = idemix.HashModOrder([]byte(ouString)) - attrs[msp.AttributeIndexRole] = FP256BN.NewBIGint(roleMask) - attrs[msp.AttributeIndexEnrollmentId] = idemix.HashModOrder([]byte(enrollmentId)) - attrs[msp.AttributeIndexRevocationHandle] = FP256BN.NewBIGint(revocationHandle) - - rng, err := idemix.GetRand() - if err != nil { - return nil, errors.WithMessage(err, "Error getting PRNG") - } - sk := idemix.RandModOrder(rng) - ni := idemix.BigToBytes(idemix.RandModOrder(rng)) - msg := idemix.NewCredRequest(sk, ni, key.Ipk, rng) - cred, err := idemix.NewCredential(key, msg, attrs, rng) - if err != nil { - return nil, errors.WithMessage(err, "failed to generate a credential") - } - - credBytes, err := proto.Marshal(cred) - if err != nil { - return nil, errors.WithMessage(err, "failed to marshal credential") - } - - // NOTE currently, idemixca creates CRI's with "ALG_NO_REVOCATION" - cri, err := idemix.CreateCRI(revKey, []*FP256BN.BIG{FP256BN.NewBIGint(revocationHandle)}, 0, idemix.ALG_NO_REVOCATION, rng) - if err != nil { - return nil, err - } - criBytes, err := proto.Marshal(cri) - if err != nil { - return nil, errors.WithMessage(err, "failed to marshal CRI") - } - - signer := &m.IdemixMSPSignerConfig{ - Cred: credBytes, - Sk: idemix.BigToBytes(sk), - OrganizationalUnitIdentifier: ouString, - Role: int32(roleMask), - EnrollmentId: enrollmentId, - CredentialRevocationInformation: criBytes, - } - - return proto.Marshal(signer) -} diff --git a/common/tools/idemixgen/idemixca/idemixca_test.go b/common/tools/idemixgen/idemixca/idemixca_test.go deleted file mode 100644 index 8bd58903f70..00000000000 --- a/common/tools/idemixgen/idemixca/idemixca_test.go +++ /dev/null @@ -1,130 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package idemixca - -import ( - "crypto/x509" - "encoding/pem" - "io/ioutil" - "os" - "path/filepath" - "testing" - - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric/bccsp/sw" - "github.com/hyperledger/fabric/idemix" - m "github.com/hyperledger/fabric/msp" - "github.com/pkg/errors" - "github.com/stretchr/testify/require" -) - -var testDir = filepath.Join(os.TempDir(), "idemixca-test") - -func TestIdemixCa(t *testing.T) { - cleanup() - - isk, ipkBytes, err := GenerateIssuerKey() - require.NoError(t, err) - - revocationkey, err := idemix.GenerateLongTermRevocationKey() - require.NoError(t, err) - - ipk := &idemix.IssuerPublicKey{} - err = proto.Unmarshal(ipkBytes, ipk) - require.NoError(t, err) - - encodedRevocationPK, err := x509.MarshalPKIXPublicKey(revocationkey.Public()) - require.NoError(t, err) - pemEncodedRevocationPK := pem.EncodeToMemory(&pem.Block{Type: "PUBLIC KEY", Bytes: encodedRevocationPK}) - - writeVerifierToFile(ipkBytes, pemEncodedRevocationPK) - - key := &idemix.IssuerKey{Isk: isk, Ipk: ipk} - - conf, err := GenerateSignerConfig(m.GetRoleMaskFromIdemixRole(m.MEMBER), "OU1", "enrollmentid1", 1, key, revocationkey) - require.NoError(t, err) - cleanupSigner() - require.NoError(t, writeSignerToFile(conf)) - require.NoError(t, setupMSP()) - - conf, err = GenerateSignerConfig(m.GetRoleMaskFromIdemixRole(m.ADMIN), "OU1", "enrollmentid2", 1234, key, revocationkey) - require.NoError(t, err) - cleanupSigner() - require.NoError(t, writeSignerToFile(conf)) - require.NoError(t, setupMSP()) - - // Without the verifier dir present, setup should give an error - cleanupVerifier() - require.Error(t, setupMSP()) - - _, err = GenerateSignerConfig(m.GetRoleMaskFromIdemixRole(m.ADMIN), "", "enrollmentid", 1, key, revocationkey) - require.EqualError(t, err, "the OU attribute value is empty") - - _, err = GenerateSignerConfig(m.GetRoleMaskFromIdemixRole(m.ADMIN), "OU1", "", 1, key, revocationkey) - require.EqualError(t, err, "the enrollment id value is empty") -} - -func cleanup() error { - // clean up any previous files - err := os.RemoveAll(testDir) - if err != nil { - return nil - } - return os.Mkdir(testDir, os.ModePerm) -} - -func cleanupSigner() { - os.RemoveAll(filepath.Join(testDir, m.IdemixConfigDirUser)) -} - -func cleanupVerifier() { - os.RemoveAll(filepath.Join(testDir, m.IdemixConfigDirMsp)) -} - -func writeVerifierToFile(ipkBytes []byte, revpkBytes []byte) error { - err := os.Mkdir(filepath.Join(testDir, m.IdemixConfigDirMsp), os.ModePerm) - if err != nil { - return err - } - err = ioutil.WriteFile(filepath.Join(testDir, m.IdemixConfigDirMsp, m.IdemixConfigFileIssuerPublicKey), ipkBytes, 0o644) - if err != nil { - return err - } - - return ioutil.WriteFile(filepath.Join(testDir, m.IdemixConfigDirMsp, m.IdemixConfigFileRevocationPublicKey), revpkBytes, 0o644) -} - -func writeSignerToFile(signerBytes []byte) error { - err := os.Mkdir(filepath.Join(testDir, m.IdemixConfigDirUser), os.ModePerm) - if err != nil { - return err - } - return ioutil.WriteFile(filepath.Join(testDir, m.IdemixConfigDirUser, m.IdemixConfigFileSigner), signerBytes, 0o644) -} - -// setupMSP tests whether we can successfully setup an idemix msp -// with the generated config bytes -func setupMSP() error { - cryptoProvider, err := sw.NewDefaultSecurityLevelWithKeystore(sw.NewDummyKeyStore()) - if err != nil { - return err - } - // setup an idemix msp from the test directory - msp, err := m.New( - &m.IdemixNewOpts{NewBaseOpts: m.NewBaseOpts{Version: m.MSPv1_1}}, - cryptoProvider, - ) - if err != nil { - return errors.Wrap(err, "Getting MSP failed") - } - mspConfig, err := m.GetIdemixMspConfig(testDir, "TestName") - if err != nil { - return err - } - - return msp.Setup(mspConfig) -} diff --git a/common/tools/idemixgen/metadata/metadata.go b/common/tools/idemixgen/metadata/metadata.go deleted file mode 100644 index f6989312b00..00000000000 --- a/common/tools/idemixgen/metadata/metadata.go +++ /dev/null @@ -1,27 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package metadata - -import ( - "fmt" - "runtime" - - "github.com/hyperledger/fabric/common/metadata" -) - -const ProgramName = "idemixgen" - -var ( - CommitSHA = metadata.CommitSHA - Version = metadata.Version -) - -func GetVersionInfo() string { - return fmt.Sprintf("%s:\n Version: %s\n Commit SHA: %s\n Go version: %s\n OS/Arch: %s", - ProgramName, Version, CommitSHA, runtime.Version(), - fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)) -} diff --git a/common/tools/idemixgen/metadata/metadata_test.go b/common/tools/idemixgen/metadata/metadata_test.go deleted file mode 100644 index d98c134fba2..00000000000 --- a/common/tools/idemixgen/metadata/metadata_test.go +++ /dev/null @@ -1,26 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package metadata_test - -import ( - "fmt" - "runtime" - "testing" - - "github.com/hyperledger/fabric/common/tools/idemixgen/metadata" - "github.com/stretchr/testify/require" -) - -func TestGetVersionInfo(t *testing.T) { - testSHA := "abcdefg" - metadata.CommitSHA = testSHA - - expected := fmt.Sprintf("%s:\n Version: %s\n Commit SHA: %s\n Go version: %s\n OS/Arch: %s", - metadata.ProgramName, metadata.Version, testSHA, runtime.Version(), - fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)) - require.Equal(t, expected, metadata.GetVersionInfo()) -} diff --git a/discovery/support/config/support_test.go b/discovery/support/config/support_test.go index cfcf4a75960..d9c4fef062b 100644 --- a/discovery/support/config/support_test.go +++ b/discovery/support/config/support_test.go @@ -45,7 +45,7 @@ func TestMSPIDMapping(t *testing.T) { require.NoError(t, err) defer os.Remove(cryptogen) - idemixgen, err := gexec.Build("github.com/hyperledger/fabric/cmd/idemixgen") + idemixgen, err := gexec.Build("github.com/IBM/idemix/tools/idemixgen", "-mod=mod") require.NoError(t, err) defer os.Remove(idemixgen) diff --git a/discovery/test/integration_test.go b/discovery/test/integration_test.go index 11608ddcc32..9b9c91c2ab5 100644 --- a/discovery/test/integration_test.go +++ b/discovery/test/integration_test.go @@ -625,7 +625,7 @@ func buildBinaries() error { return errors.WithStack(err) } - idemixgen, err = gexec.Build("github.com/hyperledger/fabric/cmd/idemixgen") + idemixgen, err = gexec.Build("github.com/IBM/idemix/tools/idemixgen", "-mod=mod") if err != nil { return errors.WithStack(err) } diff --git a/go.mod b/go.mod index f4f1ec58763..95ab283ba13 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.14 require ( code.cloudfoundry.org/clock v1.0.0 github.com/DataDog/zstd v1.4.5 // indirect + github.com/IBM/idemix v0.0.0-20210930104432-e4a1410f5353 github.com/Knetic/govaluate v3.0.0+incompatible github.com/Shopify/sarama v1.20.1 github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect @@ -26,11 +27,10 @@ require ( github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 github.com/hashicorp/go-version v1.2.0 github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hyperledger/fabric-amcl v0.0.0-20200424173818-327c9e2cf77a github.com/hyperledger/fabric-chaincode-go v0.0.0-20201119163726-f8ef75b17719 github.com/hyperledger/fabric-config v0.1.0 github.com/hyperledger/fabric-lib-go v1.0.0 - github.com/hyperledger/fabric-protos-go v0.0.0-20210903093419-e9e1b9f969d8 + github.com/hyperledger/fabric-protos-go v0.0.0-20210911123859-041d13f0980c github.com/kr/pretty v0.2.1 github.com/magiconair/properties v1.8.1 // indirect github.com/mattn/go-runewidth v0.0.4 // indirect @@ -59,8 +59,7 @@ require ( go.etcd.io/etcd v0.5.0-alpha.5.0.20181228115726-23731bf9ba55 go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.16.0 - golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad - golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect + golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 golang.org/x/tools v0.0.0-20200131233409-575de47986ce google.golang.org/grpc v1.31.0 gopkg.in/alecthomas/kingpin.v2 v2.2.6 diff --git a/go.sum b/go.sum index 8f137522a2d..bbd2a082c73 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,10 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= +github.com/IBM/idemix v0.0.0-20210930104432-e4a1410f5353 h1:gOG+V3F5J7gsWzHAoNSHAiYV2o3OvgM7uTrF7BUSt2Y= +github.com/IBM/idemix v0.0.0-20210930104432-e4a1410f5353/go.mod h1:Fazy7pMxGGdXRRSFgTipzH4Q02bIEPatJa3km9H3w78= +github.com/IBM/mathlib v0.0.0-20210928081244-f5486459a290 h1:usgCPts8YnOT6ba6CQLPzQ5Yb1crnQ8iU132Zm679IM= +github.com/IBM/mathlib v0.0.0-20210928081244-f5486459a290/go.mod h1:grSmaMdY3LbW9QwqMrzuTUCHjES4rzT4Dm7q6yIL9vs= github.com/Knetic/govaluate v3.0.0+incompatible h1:7o6+MAPhYTCF0+fdvoz1xDedhRb4f6s9Tn1Tt7/WTEg= github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.4.15-0.20200908182639-5b44b70ab3ab/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw= @@ -27,8 +31,9 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 h1:Hs82Z41s6SdL1CELW+XaDYmOH4hkBN4/N9og/AsOv7E= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20210912230133-d1bdfacee922 h1:8ypNbf5sd3Sm3cKJ9waOGoQv6dKAFiFty9L6NP1AqJ4= +github.com/alecthomas/units v0.0.0-20210912230133-d1bdfacee922/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -42,6 +47,9 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/cilium/ebpf v0.0.0-20200110133405-4032b1d8aae3/go.mod h1:MA5e5Lr8slmEg9bt0VpxxWqJlO4iwu3FBdHUzV7wQVg= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/consensys/bavard v0.1.8-0.20210329205436-c3e862ba4e5f/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ= +github.com/consensys/gnark-crypto v0.4.0 h1:KHf7Ta876Ys6L8+i0DLRRKOAa3PfJ8oobAX1CEeIa4A= +github.com/consensys/gnark-crypto v0.4.0/go.mod h1:wK/gpXP9B06qTzTVML71GhKD1ygP9xOzukbI68NJqsQ= github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59 h1:qWj4qVYZ95vLWwqyNJCQg7rDsG5wPdze0UaPolH7DUk= github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59/go.mod h1:pA0z1pT8KYB3TCXK/ocprsh7MAkoW8bZVzPdih9snmM= github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw= @@ -151,8 +159,8 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hyperledger/fabric-amcl v0.0.0-20200424173818-327c9e2cf77a h1:JAKZdGuUIjVmES0X31YUD7UqMR2rz/kxLluJuGvsXPk= -github.com/hyperledger/fabric-amcl v0.0.0-20200424173818-327c9e2cf77a/go.mod h1:X+DIyUsaTmalOpmpQfIvFZjKHQedrURQ5t4YqquX7lE= +github.com/hyperledger/fabric-amcl v0.0.0-20210603140002-2670f91851c8 h1:BCR8ZlOZ+deUbWxyY6fpoY8LbB7PR5wGGwCTvWQOU2g= +github.com/hyperledger/fabric-amcl v0.0.0-20210603140002-2670f91851c8/go.mod h1:X+DIyUsaTmalOpmpQfIvFZjKHQedrURQ5t4YqquX7lE= github.com/hyperledger/fabric-chaincode-go v0.0.0-20201119163726-f8ef75b17719 h1:FQ9AMLVSFt5QW2YBLraXW5V4Au6aFFpSl4xKFARM58Y= github.com/hyperledger/fabric-chaincode-go v0.0.0-20201119163726-f8ef75b17719/go.mod h1:N7H3sA7Tx4k/YzFq7U0EPdqJtqvM4Kild0JoCc7C0Dc= github.com/hyperledger/fabric-config v0.1.0 h1:TsR3y5xEoUmXWfp8tcDycjJhVvXEHiV5kfZIxuIte08= @@ -161,8 +169,8 @@ github.com/hyperledger/fabric-lib-go v1.0.0 h1:UL1w7c9LvHZUSkIvHTDGklxFv2kTeva1Q github.com/hyperledger/fabric-lib-go v1.0.0/go.mod h1:H362nMlunurmHwkYqR5uHL2UDWbQdbfz74n8kbCFsqc= github.com/hyperledger/fabric-protos-go v0.0.0-20190919234611-2a87503ac7c9/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0= github.com/hyperledger/fabric-protos-go v0.0.0-20200424173316-dd554ba3746e/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0= -github.com/hyperledger/fabric-protos-go v0.0.0-20210903093419-e9e1b9f969d8 h1:6Qt3MdBqww+aJCDaUDIOhA6EcDhQln5l8wqBXehM96A= -github.com/hyperledger/fabric-protos-go v0.0.0-20210903093419-e9e1b9f969d8/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0= +github.com/hyperledger/fabric-protos-go v0.0.0-20210911123859-041d13f0980c h1:QPhSriw6EzMOj/d7gcGiKEvozVvQ5HLk9UWie4KAvSs= +github.com/hyperledger/fabric-protos-go v0.0.0-20210911123859-041d13f0980c/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= @@ -186,6 +194,8 @@ github.com/kr/pty v1.0.0/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= @@ -341,8 +351,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY= -golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w= +golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -363,8 +373,8 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20210119194325-5f4716e94777 h1:003p0dJM77cxMSyCPFphvZf/Y5/NXf5fzg6ufd1/Oew= -golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -395,10 +405,10 @@ golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200922070232-aee5d888a860/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210326220804-49726bf1d181 h1:64ChN/hjER/taL4YJuA+gpLfIMT+/NFherRZixbxOhg= +golang.org/x/sys v0.0.0-20210326220804-49726bf1d181/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201113234701-d7a72108b828/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/idemix/idemix_test.go b/idemix/idemix_test.go deleted file mode 100644 index d249f45f555..00000000000 --- a/idemix/idemix_test.go +++ /dev/null @@ -1,164 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package idemix - -import ( - "bytes" - "testing" - - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" - "github.com/stretchr/testify/require" -) - -func TestIdemix(t *testing.T) { - // Test weak BB sigs: - // Test KeyGen - rng, err := GetRand() - require.NoError(t, err) - wbbsk, wbbpk := WBBKeyGen(rng) - - // Get random message - testmsg := RandModOrder(rng) - - // Test Signing - wbbsig := WBBSign(wbbsk, testmsg) - - // Test Verification - err = WBBVerify(wbbpk, wbbsig, testmsg) - require.NoError(t, err) - - // Test idemix functionality - AttributeNames := []string{"Attr1", "Attr2", "Attr3", "Attr4", "Attr5"} - attrs := make([]*FP256BN.BIG, len(AttributeNames)) - for i := range AttributeNames { - attrs[i] = FP256BN.NewBIGint(i) - } - - // Test issuer key generation - if err != nil { - t.Fatalf("Error getting rng: \"%s\"", err) - return - } - // Create a new key pair - key, err := NewIssuerKey(AttributeNames, rng) - if err != nil { - t.Fatalf("Issuer key generation should have succeeded but gave error \"%s\"", err) - return - } - - // Check that the key is valid - err = key.GetIpk().Check() - if err != nil { - t.Fatalf("Issuer public key should be valid") - return - } - - // Make sure Check() is invalid for a public key with invalid proof - proofC := key.Ipk.GetProofC() - key.Ipk.ProofC = BigToBytes(RandModOrder(rng)) - require.Error(t, key.Ipk.Check(), "public key with broken zero-knowledge proof should be invalid") - - // Make sure Check() is invalid for a public key with incorrect number of HAttrs - hAttrs := key.Ipk.GetHAttrs() - key.Ipk.HAttrs = key.Ipk.HAttrs[:0] - require.Error(t, key.Ipk.Check(), "public key with incorrect number of HAttrs should be invalid") - key.Ipk.HAttrs = hAttrs - - // Restore IPk to be valid - key.Ipk.ProofC = proofC - h := key.Ipk.GetHash() - require.NoError(t, key.Ipk.Check(), "restored public key should be valid") - require.Zero(t, bytes.Compare(h, key.Ipk.GetHash()), "IPK hash changed on ipk Check") - - // Create public with duplicate attribute names should fail - _, err = NewIssuerKey([]string{"Attr1", "Attr2", "Attr1"}, rng) - require.Error(t, err, "issuer key generation should fail with duplicate attribute names") - - // Test issuance - sk := RandModOrder(rng) - ni := RandModOrder(rng) - m := NewCredRequest(sk, BigToBytes(ni), key.Ipk, rng) - - cred, err := NewCredential(key, m, attrs, rng) - require.NoError(t, err, "Failed to issue a credential: \"%s\"", err) - - require.NoError(t, cred.Ver(sk, key.Ipk), "credential should be valid") - - // Issuing a credential with the incorrect amount of attributes should fail - _, err = NewCredential(key, m, []*FP256BN.BIG{}, rng) - require.Error(t, err, "issuing a credential with the incorrect amount of attributes should fail") - - // Breaking the ZK proof of the CredRequest should make it invalid - proofC = m.GetProofC() - m.ProofC = BigToBytes(RandModOrder(rng)) - require.Error(t, m.Check(key.Ipk), "CredRequest with broken ZK proof should not be valid") - - // Creating a credential from a broken CredRequest should fail - _, err = NewCredential(key, m, attrs, rng) - require.Error(t, err, "creating a credential from an invalid CredRequest should fail") - m.ProofC = proofC - - // A credential with nil attribute should be invalid - attrsBackup := cred.GetAttrs() - cred.Attrs = [][]byte{nil, nil, nil, nil, nil} - require.Error(t, cred.Ver(sk, key.Ipk), "credential with nil attribute should be invalid") - cred.Attrs = attrsBackup - - // Generate a revocation key pair - revocationKey, err := GenerateLongTermRevocationKey() - require.NoError(t, err) - - // Create CRI that contains no revocation mechanism - epoch := 0 - cri, err := CreateCRI(revocationKey, []*FP256BN.BIG{}, epoch, ALG_NO_REVOCATION, rng) - require.NoError(t, err) - err = VerifyEpochPK(&revocationKey.PublicKey, cri.EpochPk, cri.EpochPkSig, int(cri.Epoch), RevocationAlgorithm(cri.RevocationAlg)) - require.NoError(t, err) - - // make sure that epoch pk is not valid in future epoch - err = VerifyEpochPK(&revocationKey.PublicKey, cri.EpochPk, cri.EpochPkSig, int(cri.Epoch)+1, RevocationAlgorithm(cri.RevocationAlg)) - require.Error(t, err) - - // Test bad input - _, err = CreateCRI(nil, []*FP256BN.BIG{}, epoch, ALG_NO_REVOCATION, rng) - require.Error(t, err) - _, err = CreateCRI(revocationKey, []*FP256BN.BIG{}, epoch, ALG_NO_REVOCATION, nil) - require.Error(t, err) - - // Test signing no disclosure - Nym, RandNym := MakeNym(sk, key.Ipk, rng) - - disclosure := []byte{0, 0, 0, 0, 0} - msg := []byte{1, 2, 3, 4, 5} - rhindex := 4 - sig, err := NewSignature(cred, sk, Nym, RandNym, key.Ipk, disclosure, msg, rhindex, cri, rng) - require.NoError(t, err) - - err = sig.Ver(disclosure, key.Ipk, msg, nil, 0, &revocationKey.PublicKey, epoch) - if err != nil { - t.Fatalf("Signature should be valid but verification returned error: %s", err) - return - } - - // Test signing selective disclosure - disclosure = []byte{0, 1, 1, 1, 0} - sig, err = NewSignature(cred, sk, Nym, RandNym, key.Ipk, disclosure, msg, rhindex, cri, rng) - require.NoError(t, err) - - err = sig.Ver(disclosure, key.Ipk, msg, attrs, rhindex, &revocationKey.PublicKey, epoch) - require.NoError(t, err) - - // Test NymSignatures - nymsig, err := NewNymSignature(sk, Nym, RandNym, key.Ipk, []byte("testing"), rng) - require.NoError(t, err) - - err = nymsig.Ver(Nym, key.Ipk, []byte("testing")) - if err != nil { - t.Fatalf("NymSig should be valid but verification returned error: %s", err) - return - } -} diff --git a/idemix/nymsignature.go b/idemix/nymsignature.go deleted file mode 100644 index a12a999360f..00000000000 --- a/idemix/nymsignature.go +++ /dev/null @@ -1,110 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package idemix - -import ( - "github.com/hyperledger/fabric-amcl/amcl" - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" - "github.com/pkg/errors" -) - -// NewSignature creates a new idemix pseudonym signature -func NewNymSignature(sk *FP256BN.BIG, Nym *FP256BN.ECP, RNym *FP256BN.BIG, ipk *IssuerPublicKey, msg []byte, rng *amcl.RAND) (*NymSignature, error) { - // Validate inputs - if sk == nil || Nym == nil || RNym == nil || ipk == nil || rng == nil { - return nil, errors.Errorf("cannot create NymSignature: received nil input") - } - - Nonce := RandModOrder(rng) - - HRand := EcpFromProto(ipk.HRand) - HSk := EcpFromProto(ipk.HSk) - - // The rest of this function constructs the non-interactive zero knowledge proof proving that - // the signer 'owns' this pseudonym, i.e., it knows the secret key and randomness on which it is based. - // Recall that (Nym,RNym) is the output of MakeNym. Therefore, Nym = h_{sk}^sk \cdot h_r^r - - // Sample the randomness needed for the proof - rSk := RandModOrder(rng) - rRNym := RandModOrder(rng) - - // Step 1: First message (t-values) - t := HSk.Mul2(rSk, HRand, rRNym) // t = h_{sk}^{r_sk} \cdot h_r^{r_{RNym} - - // Step 2: Compute the Fiat-Shamir hash, forming the challenge of the ZKP. - // proofData will hold the data being hashed, it consists of: - // - the signature label - // - 2 elements of G1 each taking 2*FieldBytes+1 bytes - // - one bigint (hash of the issuer public key) of length FieldBytes - // - disclosed attributes - // - message being signed - proofData := make([]byte, len(signLabel)+2*(2*FieldBytes+1)+FieldBytes+len(msg)) - index := 0 - index = appendBytesString(proofData, index, signLabel) - index = appendBytesG1(proofData, index, t) - index = appendBytesG1(proofData, index, Nym) - copy(proofData[index:], ipk.Hash) - index = index + FieldBytes - copy(proofData[index:], msg) - c := HashModOrder(proofData) - // combine the previous hash and the nonce and hash again to compute the final Fiat-Shamir value 'ProofC' - index = 0 - proofData = proofData[:2*FieldBytes] - index = appendBytesBig(proofData, index, c) - appendBytesBig(proofData, index, Nonce) - ProofC := HashModOrder(proofData) - - // Step 3: reply to the challenge message (s-values) - ProofSSk := Modadd(rSk, FP256BN.Modmul(ProofC, sk, GroupOrder), GroupOrder) // s_{sk} = r_{sk} + C \cdot sk - ProofSRNym := Modadd(rRNym, FP256BN.Modmul(ProofC, RNym, GroupOrder), GroupOrder) // s_{RNym} = r_{RNym} + C \cdot RNym - - // The signature consists of the Fiat-Shamir hash (ProofC), the s-values (ProofSSk, ProofSRNym), and the nonce. - return &NymSignature{ - ProofC: BigToBytes(ProofC), - ProofSSk: BigToBytes(ProofSSk), - ProofSRNym: BigToBytes(ProofSRNym), - Nonce: BigToBytes(Nonce), - }, nil -} - -// Ver verifies an idemix NymSignature -func (sig *NymSignature) Ver(nym *FP256BN.ECP, ipk *IssuerPublicKey, msg []byte) error { - ProofC := FP256BN.FromBytes(sig.GetProofC()) - ProofSSk := FP256BN.FromBytes(sig.GetProofSSk()) - ProofSRNym := FP256BN.FromBytes(sig.GetProofSRNym()) - Nonce := FP256BN.FromBytes(sig.GetNonce()) - - HRand := EcpFromProto(ipk.HRand) - HSk := EcpFromProto(ipk.HSk) - - // Verify Proof - - // Recompute t-values using s-values - t := HSk.Mul2(ProofSSk, HRand, ProofSRNym) - t.Sub(nym.Mul(ProofC)) // t = h_{sk}^{s_{sk} \ cdot h_r^{s_{RNym} - - // Recompute challenge - proofData := make([]byte, len(signLabel)+2*(2*FieldBytes+1)+FieldBytes+len(msg)) - index := 0 - index = appendBytesString(proofData, index, signLabel) - index = appendBytesG1(proofData, index, t) - index = appendBytesG1(proofData, index, nym) - copy(proofData[index:], ipk.Hash) - index = index + FieldBytes - copy(proofData[index:], msg) - c := HashModOrder(proofData) - index = 0 - proofData = proofData[:2*FieldBytes] - index = appendBytesBig(proofData, index, c) - appendBytesBig(proofData, index, Nonce) - - if *ProofC != *HashModOrder(proofData) { - return errors.Errorf("pseudonym signature invalid: zero-knowledge proof is invalid") - } - - return nil -} diff --git a/idemix/signature.go b/idemix/signature.go deleted file mode 100644 index 521480e9af1..00000000000 --- a/idemix/signature.go +++ /dev/null @@ -1,406 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package idemix - -import ( - "crypto/ecdsa" - "sort" - - "github.com/hyperledger/fabric-amcl/amcl" - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" - "github.com/pkg/errors" -) - -// signLabel is the label used in zero-knowledge proof (ZKP) to identify that this ZKP is a signature of knowledge -const signLabel = "sign" - -// A signature that is produced using an Identity Mixer credential is a so-called signature of knowledge -// (for details see C.P.Schnorr "Efficient Identification and Signatures for Smart Cards") -// An Identity Mixer signature is a signature of knowledge that signs a message and proves (in zero-knowledge) -// the knowledge of the user secret (and possibly attributes) signed inside a credential -// that was issued by a certain issuer (referred to with the issuer public key) -// The signature is verified using the message being signed and the public key of the issuer -// Some of the attributes from the credential can be selectively disclosed or different statements can be proven about -// credential attributes without disclosing them in the clear -// The difference between a standard signature using X.509 certificates and an Identity Mixer signature is -// the advanced privacy features provided by Identity Mixer (due to zero-knowledge proofs): -// - Unlinkability of the signatures produced with the same credential -// - Selective attribute disclosure and predicates over attributes - -// Make a slice of all the attribute indices that will not be disclosed -func hiddenIndices(Disclosure []byte) []int { - HiddenIndices := make([]int, 0) - for index, disclose := range Disclosure { - if disclose == 0 { - HiddenIndices = append(HiddenIndices, index) - } - } - return HiddenIndices -} - -// NewSignature creates a new idemix signature (Schnorr-type signature) -// The []byte Disclosure steers which attributes are disclosed: -// if Disclosure[i] == 0 then attribute i remains hidden and otherwise it is disclosed. -// We require the revocation handle to remain undisclosed (i.e., Disclosure[rhIndex] == 0). -// We use the zero-knowledge proof by http://eprint.iacr.org/2016/663.pdf, Sec. 4.5 to prove knowledge of a BBS+ signature -func NewSignature(cred *Credential, sk *FP256BN.BIG, Nym *FP256BN.ECP, RNym *FP256BN.BIG, ipk *IssuerPublicKey, Disclosure []byte, msg []byte, rhIndex int, cri *CredentialRevocationInformation, rng *amcl.RAND) (*Signature, error) { - // Validate inputs - if cred == nil || sk == nil || Nym == nil || RNym == nil || ipk == nil || rng == nil || cri == nil { - return nil, errors.Errorf("cannot create idemix signature: received nil input") - } - - if rhIndex < 0 || rhIndex >= len(ipk.AttributeNames) || len(Disclosure) != len(ipk.AttributeNames) { - return nil, errors.Errorf("cannot create idemix signature: received invalid input") - } - - if cri.RevocationAlg != int32(ALG_NO_REVOCATION) && Disclosure[rhIndex] == 1 { - return nil, errors.Errorf("Attribute %d is disclosed but also used as revocation handle attribute, which should remain hidden.", rhIndex) - } - - // locate the indices of the attributes to hide and sample randomness for them - HiddenIndices := hiddenIndices(Disclosure) - - // Generate required randomness r_1, r_2 - r1 := RandModOrder(rng) - r2 := RandModOrder(rng) - // Set r_3 as \frac{1}{r_1} - r3 := FP256BN.NewBIGcopy(r1) - r3.Invmodp(GroupOrder) - - // Sample a nonce - Nonce := RandModOrder(rng) - - // Parse credential - A := EcpFromProto(cred.A) - B := EcpFromProto(cred.B) - - // Randomize credential - - // Compute A' as A^{r_!} - APrime := FP256BN.G1mul(A, r1) - - // Compute ABar as A'^{-e} b^{r1} - ABar := FP256BN.G1mul(B, r1) - ABar.Sub(FP256BN.G1mul(APrime, FP256BN.FromBytes(cred.E))) - - // Compute B' as b^{r1} / h_r^{r2}, where h_r is h_r - BPrime := FP256BN.G1mul(B, r1) - HRand := EcpFromProto(ipk.HRand) - // Parse h_{sk} from ipk - HSk := EcpFromProto(ipk.HSk) - - BPrime.Sub(FP256BN.G1mul(HRand, r2)) - - S := FP256BN.FromBytes(cred.S) - E := FP256BN.FromBytes(cred.E) - - // Compute s' as s - r_2 \cdot r_3 - sPrime := Modsub(S, FP256BN.Modmul(r2, r3, GroupOrder), GroupOrder) - - // The rest of this function constructs the non-interactive zero knowledge proof - // that links the signature, the non-disclosed attributes and the nym. - - // Sample the randomness used to compute the commitment values (aka t-values) for the ZKP - rSk := RandModOrder(rng) - re := RandModOrder(rng) - rR2 := RandModOrder(rng) - rR3 := RandModOrder(rng) - rSPrime := RandModOrder(rng) - rRNym := RandModOrder(rng) - - rAttrs := make([]*FP256BN.BIG, len(HiddenIndices)) - for i := range HiddenIndices { - rAttrs[i] = RandModOrder(rng) - } - - // First compute the non-revocation proof. - // The challenge of the ZKP needs to depend on it, as well. - prover, err := getNonRevocationProver(RevocationAlgorithm(cri.RevocationAlg)) - if err != nil { - return nil, err - } - nonRevokedProofHashData, err := prover.getFSContribution( - FP256BN.FromBytes(cred.Attrs[rhIndex]), - rAttrs[sort.SearchInts(HiddenIndices, rhIndex)], - cri, - rng, - ) - if err != nil { - return nil, errors.Wrap(err, "failed to compute non-revoked proof") - } - - // Step 1: First message (t-values) - - // t1 is related to knowledge of the credential (recall, it is a BBS+ signature) - t1 := APrime.Mul2(re, HRand, rR2) // A'^{r_E} \cdot h_r^{r_{r2}} - - // t2: is related to knowledge of the non-disclosed attributes that signed in (A,B,S,E) - t2 := FP256BN.G1mul(HRand, rSPrime) // h_r^{r_{s'}} - t2.Add(BPrime.Mul2(rR3, HSk, rSk)) // B'^{r_{r3}} \cdot h_{sk}^{r_{sk}} - for i := 0; i < len(HiddenIndices)/2; i++ { - t2.Add( - // \cdot h_{2 \cdot i}^{r_{attrs,i} - EcpFromProto(ipk.HAttrs[HiddenIndices[2*i]]).Mul2( - rAttrs[2*i], - EcpFromProto(ipk.HAttrs[HiddenIndices[2*i+1]]), - rAttrs[2*i+1], - ), - ) - } - if len(HiddenIndices)%2 != 0 { - t2.Add(FP256BN.G1mul(EcpFromProto(ipk.HAttrs[HiddenIndices[len(HiddenIndices)-1]]), rAttrs[len(HiddenIndices)-1])) - } - - // t3 is related to the knowledge of the secrets behind the pseudonym, which is also signed in (A,B,S,E) - t3 := HSk.Mul2(rSk, HRand, rRNym) // h_{sk}^{r_{sk}} \cdot h_r^{r_{rnym}} - - // Step 2: Compute the Fiat-Shamir hash, forming the challenge of the ZKP. - - // Compute the Fiat-Shamir hash, forming the challenge of the ZKP. - // proofData is the data being hashed, it consists of: - // the signature label - // 7 elements of G1 each taking 2*FieldBytes+1 bytes - // one bigint (hash of the issuer public key) of length FieldBytes - // disclosed attributes - // message being signed - // the amount of bytes needed for the nonrevocation proof - proofData := make([]byte, len(signLabel)+7*(2*FieldBytes+1)+FieldBytes+len(Disclosure)+len(msg)+ProofBytes[RevocationAlgorithm(cri.RevocationAlg)]) - index := 0 - index = appendBytesString(proofData, index, signLabel) - index = appendBytesG1(proofData, index, t1) - index = appendBytesG1(proofData, index, t2) - index = appendBytesG1(proofData, index, t3) - index = appendBytesG1(proofData, index, APrime) - index = appendBytesG1(proofData, index, ABar) - index = appendBytesG1(proofData, index, BPrime) - index = appendBytesG1(proofData, index, Nym) - index = appendBytes(proofData, index, nonRevokedProofHashData) - copy(proofData[index:], ipk.Hash) - index = index + FieldBytes - copy(proofData[index:], Disclosure) - index = index + len(Disclosure) - copy(proofData[index:], msg) - c := HashModOrder(proofData) - - // add the previous hash and the nonce and hash again to compute a second hash (C value) - index = 0 - proofData = proofData[:2*FieldBytes] - index = appendBytesBig(proofData, index, c) - appendBytesBig(proofData, index, Nonce) - ProofC := HashModOrder(proofData) - - // Step 3: reply to the challenge message (s-values) - ProofSSk := Modadd(rSk, FP256BN.Modmul(ProofC, sk, GroupOrder), GroupOrder) // s_sk = rSK + C \cdot sk - ProofSE := Modsub(re, FP256BN.Modmul(ProofC, E, GroupOrder), GroupOrder) // s_e = re + C \cdot E - ProofSR2 := Modadd(rR2, FP256BN.Modmul(ProofC, r2, GroupOrder), GroupOrder) // s_r2 = rR2 + C \cdot r2 - ProofSR3 := Modsub(rR3, FP256BN.Modmul(ProofC, r3, GroupOrder), GroupOrder) // s_r3 = rR3 + C \cdot r3 - ProofSSPrime := Modadd(rSPrime, FP256BN.Modmul(ProofC, sPrime, GroupOrder), GroupOrder) // s_S' = rSPrime + C \cdot sPrime - ProofSRNym := Modadd(rRNym, FP256BN.Modmul(ProofC, RNym, GroupOrder), GroupOrder) // s_RNym = rRNym + C \cdot RNym - ProofSAttrs := make([][]byte, len(HiddenIndices)) - for i, j := range HiddenIndices { - ProofSAttrs[i] = BigToBytes( - // s_attrsi = rAttrsi + C \cdot cred.Attrs[j] - Modadd(rAttrs[i], FP256BN.Modmul(ProofC, FP256BN.FromBytes(cred.Attrs[j]), GroupOrder), GroupOrder), - ) - } - - // Compute the revocation part - nonRevokedProof, err := prover.getNonRevokedProof(ProofC) - if err != nil { - return nil, err - } - - // We are done. Return signature - return &Signature{ - APrime: EcpToProto(APrime), - ABar: EcpToProto(ABar), - BPrime: EcpToProto(BPrime), - ProofC: BigToBytes(ProofC), - ProofSSk: BigToBytes(ProofSSk), - ProofSE: BigToBytes(ProofSE), - ProofSR2: BigToBytes(ProofSR2), - ProofSR3: BigToBytes(ProofSR3), - ProofSSPrime: BigToBytes(ProofSSPrime), - ProofSAttrs: ProofSAttrs, - Nonce: BigToBytes(Nonce), - Nym: EcpToProto(Nym), - ProofSRNym: BigToBytes(ProofSRNym), - RevocationEpochPk: cri.EpochPk, - RevocationPkSig: cri.EpochPkSig, - Epoch: cri.Epoch, - NonRevocationProof: nonRevokedProof, - }, - nil -} - -// Ver verifies an idemix signature -// Disclosure steers which attributes it expects to be disclosed -// attributeValues contains the desired attribute values. -// This function will check that if attribute i is disclosed, the i-th attribute equals attributeValues[i]. -func (sig *Signature) Ver(Disclosure []byte, ipk *IssuerPublicKey, msg []byte, attributeValues []*FP256BN.BIG, rhIndex int, revPk *ecdsa.PublicKey, epoch int) error { - // Validate inputs - if ipk == nil || revPk == nil { - return errors.Errorf("cannot verify idemix signature: received nil input") - } - - if rhIndex < 0 || rhIndex >= len(ipk.AttributeNames) || len(Disclosure) != len(ipk.AttributeNames) { - return errors.Errorf("cannot verify idemix signature: received invalid input") - } - - if sig.NonRevocationProof.RevocationAlg != int32(ALG_NO_REVOCATION) && Disclosure[rhIndex] == 1 { - return errors.Errorf("Attribute %d is disclosed but is also used as revocation handle, which should remain hidden.", rhIndex) - } - - HiddenIndices := hiddenIndices(Disclosure) - - // Parse signature - APrime := EcpFromProto(sig.GetAPrime()) - ABar := EcpFromProto(sig.GetABar()) - BPrime := EcpFromProto(sig.GetBPrime()) - Nym := EcpFromProto(sig.GetNym()) - ProofC := FP256BN.FromBytes(sig.GetProofC()) - ProofSSk := FP256BN.FromBytes(sig.GetProofSSk()) - ProofSE := FP256BN.FromBytes(sig.GetProofSE()) - ProofSR2 := FP256BN.FromBytes(sig.GetProofSR2()) - ProofSR3 := FP256BN.FromBytes(sig.GetProofSR3()) - ProofSSPrime := FP256BN.FromBytes(sig.GetProofSSPrime()) - ProofSRNym := FP256BN.FromBytes(sig.GetProofSRNym()) - ProofSAttrs := make([]*FP256BN.BIG, len(sig.GetProofSAttrs())) - - if len(sig.ProofSAttrs) != len(HiddenIndices) { - return errors.Errorf("signature invalid: incorrect amount of s-values for AttributeProofSpec") - } - for i, b := range sig.ProofSAttrs { - ProofSAttrs[i] = FP256BN.FromBytes(b) - } - Nonce := FP256BN.FromBytes(sig.GetNonce()) - - // Parse issuer public key - W := Ecp2FromProto(ipk.W) - HRand := EcpFromProto(ipk.HRand) - HSk := EcpFromProto(ipk.HSk) - - // Verify signature - if APrime.Is_infinity() { - return errors.Errorf("signature invalid: APrime = 1") - } - temp1 := FP256BN.Ate(W, APrime) - temp2 := FP256BN.Ate(GenG2, ABar) - temp2.Inverse() - temp1.Mul(temp2) - if !FP256BN.Fexp(temp1).Isunity() { - return errors.Errorf("signature invalid: APrime and ABar don't have the expected structure") - } - - // Verify ZK proof - - // Recover t-values - - // Recompute t1 - t1 := APrime.Mul2(ProofSE, HRand, ProofSR2) - temp := FP256BN.NewECP() - temp.Copy(ABar) - temp.Sub(BPrime) - t1.Sub(FP256BN.G1mul(temp, ProofC)) - - // Recompute t2 - t2 := FP256BN.G1mul(HRand, ProofSSPrime) - t2.Add(BPrime.Mul2(ProofSR3, HSk, ProofSSk)) - for i := 0; i < len(HiddenIndices)/2; i++ { - t2.Add(EcpFromProto(ipk.HAttrs[HiddenIndices[2*i]]).Mul2(ProofSAttrs[2*i], EcpFromProto(ipk.HAttrs[HiddenIndices[2*i+1]]), ProofSAttrs[2*i+1])) - } - if len(HiddenIndices)%2 != 0 { - t2.Add(FP256BN.G1mul(EcpFromProto(ipk.HAttrs[HiddenIndices[len(HiddenIndices)-1]]), ProofSAttrs[len(HiddenIndices)-1])) - } - temp = FP256BN.NewECP() - temp.Copy(GenG1) - for index, disclose := range Disclosure { - if disclose != 0 { - temp.Add(FP256BN.G1mul(EcpFromProto(ipk.HAttrs[index]), attributeValues[index])) - } - } - t2.Add(FP256BN.G1mul(temp, ProofC)) - - // Recompute t3 - t3 := HSk.Mul2(ProofSSk, HRand, ProofSRNym) - t3.Sub(Nym.Mul(ProofC)) - - // add contribution from the non-revocation proof - nonRevokedVer, err := getNonRevocationVerifier(RevocationAlgorithm(sig.NonRevocationProof.RevocationAlg)) - if err != nil { - return err - } - - i := sort.SearchInts(HiddenIndices, rhIndex) - proofSRh := ProofSAttrs[i] - nonRevokedProofBytes, err := nonRevokedVer.recomputeFSContribution(sig.NonRevocationProof, ProofC, Ecp2FromProto(sig.RevocationEpochPk), proofSRh) - if err != nil { - return err - } - - // Recompute challenge - // proofData is the data being hashed, it consists of: - // the signature label - // 7 elements of G1 each taking 2*FieldBytes+1 bytes - // one bigint (hash of the issuer public key) of length FieldBytes - // disclosed attributes - // message that was signed - proofData := make([]byte, len(signLabel)+7*(2*FieldBytes+1)+FieldBytes+len(Disclosure)+len(msg)+ProofBytes[RevocationAlgorithm(sig.NonRevocationProof.RevocationAlg)]) - index := 0 - index = appendBytesString(proofData, index, signLabel) - index = appendBytesG1(proofData, index, t1) - index = appendBytesG1(proofData, index, t2) - index = appendBytesG1(proofData, index, t3) - index = appendBytesG1(proofData, index, APrime) - index = appendBytesG1(proofData, index, ABar) - index = appendBytesG1(proofData, index, BPrime) - index = appendBytesG1(proofData, index, Nym) - index = appendBytes(proofData, index, nonRevokedProofBytes) - copy(proofData[index:], ipk.Hash) - index = index + FieldBytes - copy(proofData[index:], Disclosure) - index = index + len(Disclosure) - copy(proofData[index:], msg) - - c := HashModOrder(proofData) - index = 0 - proofData = proofData[:2*FieldBytes] - index = appendBytesBig(proofData, index, c) - appendBytesBig(proofData, index, Nonce) - - if *ProofC != *HashModOrder(proofData) { - // This debug line helps identify where the mismatch happened - logger.Printf("Signature Verification : \n"+ - " [t1:%v]\n,"+ - " [t2:%v]\n,"+ - " [t3:%v]\n,"+ - " [APrime:%v]\n,"+ - " [ABar:%v]\n,"+ - " [BPrime:%v]\n,"+ - " [Nym:%v]\n,"+ - " [nonRevokedProofBytes:%v]\n,"+ - " [ipk.Hash:%v]\n,"+ - " [Disclosure:%v]\n,"+ - " [msg:%v]\n,", - EcpToBytes(t1), - EcpToBytes(t2), - EcpToBytes(t3), - EcpToBytes(APrime), - EcpToBytes(ABar), - EcpToBytes(BPrime), - EcpToBytes(Nym), - nonRevokedProofBytes, - ipk.Hash, - Disclosure, - msg, - ) - return errors.Errorf("signature invalid: zero-knowledge proof is invalid") - } - - // Signature is valid - return nil -} diff --git a/idemix/util.go b/idemix/util.go deleted file mode 100644 index 3a5f41b4b17..00000000000 --- a/idemix/util.go +++ /dev/null @@ -1,160 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package idemix - -import ( - "crypto/rand" - "crypto/sha256" - - "github.com/hyperledger/fabric-amcl/amcl" - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" - "github.com/pkg/errors" -) - -// GenG1 is a generator of Group G1 -var GenG1 = FP256BN.NewECPbigs( - FP256BN.NewBIGints(FP256BN.CURVE_Gx), - FP256BN.NewBIGints(FP256BN.CURVE_Gy)) - -// GenG2 is a generator of Group G2 -var GenG2 = FP256BN.NewECP2fp2s( - FP256BN.NewFP2bigs(FP256BN.NewBIGints(FP256BN.CURVE_Pxa), FP256BN.NewBIGints(FP256BN.CURVE_Pxb)), - FP256BN.NewFP2bigs(FP256BN.NewBIGints(FP256BN.CURVE_Pya), FP256BN.NewBIGints(FP256BN.CURVE_Pyb))) - -// GenGT is a generator of Group GT -var GenGT = FP256BN.Fexp(FP256BN.Ate(GenG2, GenG1)) - -// GroupOrder is the order of the groups -var GroupOrder = FP256BN.NewBIGints(FP256BN.CURVE_Order) - -// FieldBytes is the bytelength of the group order -var FieldBytes = int(FP256BN.MODBYTES) - -// RandModOrder returns a random element in 0, ..., GroupOrder-1 -func RandModOrder(rng *amcl.RAND) *FP256BN.BIG { - // curve order q - q := FP256BN.NewBIGints(FP256BN.CURVE_Order) - - // Take random element in Zq - return FP256BN.Randomnum(q, rng) -} - -// HashModOrder hashes data into 0, ..., GroupOrder-1 -func HashModOrder(data []byte) *FP256BN.BIG { - digest := sha256.Sum256(data) - digestBig := FP256BN.FromBytes(digest[:]) - digestBig.Mod(GroupOrder) - return digestBig -} - -func appendBytes(data []byte, index int, bytesToAdd []byte) int { - copy(data[index:], bytesToAdd) - return index + len(bytesToAdd) -} - -func appendBytesG1(data []byte, index int, E *FP256BN.ECP) int { - length := 2*FieldBytes + 1 - E.ToBytes(data[index:index+length], false) - return index + length -} - -func EcpToBytes(E *FP256BN.ECP) []byte { - length := 2*FieldBytes + 1 - res := make([]byte, length) - E.ToBytes(res, false) - return res -} - -func appendBytesG2(data []byte, index int, E *FP256BN.ECP2) int { - length := 4 * FieldBytes - E.ToBytes(data[index : index+length]) - return index + length -} - -func appendBytesBig(data []byte, index int, B *FP256BN.BIG) int { - length := FieldBytes - B.ToBytes(data[index : index+length]) - return index + length -} - -func appendBytesString(data []byte, index int, s string) int { - bytes := []byte(s) - copy(data[index:], bytes) - return index + len(bytes) -} - -// MakeNym creates a new unlinkable pseudonym -func MakeNym(sk *FP256BN.BIG, IPk *IssuerPublicKey, rng *amcl.RAND) (*FP256BN.ECP, *FP256BN.BIG) { - // Construct a commitment to the sk - // Nym = h_{sk}^sk \cdot h_r^r - RandNym := RandModOrder(rng) - Nym := EcpFromProto(IPk.HSk).Mul2(sk, EcpFromProto(IPk.HRand), RandNym) - return Nym, RandNym -} - -// BigToBytes takes an *amcl.BIG and returns a []byte representation -func BigToBytes(big *FP256BN.BIG) []byte { - ret := make([]byte, FieldBytes) - big.ToBytes(ret) - return ret -} - -// EcpToProto converts a *amcl.ECP into the proto struct *ECP -func EcpToProto(p *FP256BN.ECP) *ECP { - return &ECP{ - X: BigToBytes(p.GetX()), - Y: BigToBytes(p.GetY()), - } -} - -// EcpFromProto converts a proto struct *ECP into an *amcl.ECP -func EcpFromProto(p *ECP) *FP256BN.ECP { - return FP256BN.NewECPbigs(FP256BN.FromBytes(p.GetX()), FP256BN.FromBytes(p.GetY())) -} - -// Ecp2ToProto converts a *amcl.ECP2 into the proto struct *ECP2 -func Ecp2ToProto(p *FP256BN.ECP2) *ECP2 { - return &ECP2{ - Xa: BigToBytes(p.GetX().GetA()), - Xb: BigToBytes(p.GetX().GetB()), - Ya: BigToBytes(p.GetY().GetA()), - Yb: BigToBytes(p.GetY().GetB()), - } -} - -// Ecp2FromProto converts a proto struct *ECP2 into an *amcl.ECP2 -func Ecp2FromProto(p *ECP2) *FP256BN.ECP2 { - return FP256BN.NewECP2fp2s( - FP256BN.NewFP2bigs(FP256BN.FromBytes(p.GetXa()), FP256BN.FromBytes(p.GetXb())), - FP256BN.NewFP2bigs(FP256BN.FromBytes(p.GetYa()), FP256BN.FromBytes(p.GetYb()))) -} - -// GetRand returns a new *amcl.RAND with a fresh seed -func GetRand() (*amcl.RAND, error) { - seedLength := 32 - b := make([]byte, seedLength) - _, err := rand.Read(b) - if err != nil { - return nil, errors.Wrap(err, "error getting randomness for seed") - } - rng := amcl.NewRAND() - rng.Clean() - rng.Seed(seedLength, b) - return rng, nil -} - -// Modadd takes input BIGs a, b, m, and returns a+b modulo m -func Modadd(a, b, m *FP256BN.BIG) *FP256BN.BIG { - c := a.Plus(b) - c.Mod(m) - return c -} - -// Modsub takes input BIGs a, b, m and returns a-b modulo m -func Modsub(a, b, m *FP256BN.BIG) *FP256BN.BIG { - return Modadd(a, FP256BN.Modneg(b, m), m) -} diff --git a/idemix/weak-bb.go b/idemix/weak-bb.go deleted file mode 100644 index 1b696afcbe1..00000000000 --- a/idemix/weak-bb.go +++ /dev/null @@ -1,49 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package idemix - -import ( - "github.com/hyperledger/fabric-amcl/amcl" - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" - "github.com/pkg/errors" -) - -// WBBKeyGen creates a fresh weak-Boneh-Boyen signature key pair (http://ia.cr/2004/171) -func WBBKeyGen(rng *amcl.RAND) (*FP256BN.BIG, *FP256BN.ECP2) { - // sample sk uniform from Zq - sk := RandModOrder(rng) - // set pk = g2^sk - pk := GenG2.Mul(sk) - return sk, pk -} - -// WBBSign places a weak Boneh-Boyen signature on message m using secret key sk -func WBBSign(sk *FP256BN.BIG, m *FP256BN.BIG) *FP256BN.ECP { - // compute exp = 1/(m + sk) mod q - exp := Modadd(sk, m, GroupOrder) - exp.Invmodp(GroupOrder) - - // return signature sig = g1^(1/(m + sk)) - return GenG1.Mul(exp) -} - -// WBBVerify verifies a weak Boneh-Boyen signature sig on message m with public key pk -func WBBVerify(pk *FP256BN.ECP2, sig *FP256BN.ECP, m *FP256BN.BIG) error { - if pk == nil || sig == nil || m == nil { - return errors.Errorf("Weak-BB signature invalid: received nil input") - } - // Set P = pk * g2^m - P := FP256BN.NewECP2() - P.Copy(pk) - P.Add(GenG2.Mul(m)) - P.Affine() - // check that e(sig, pk * g2^m) = e(g1, g2) - if !FP256BN.Fexp(FP256BN.Ate(P, sig)).Equals(GenGT) { - return errors.Errorf("Weak-BB signature is invalid") - } - return nil -} diff --git a/integration/nwo/components.go b/integration/nwo/components.go index b3fca9eb4e0..4e903811281 100644 --- a/integration/nwo/components.go +++ b/integration/nwo/components.go @@ -13,6 +13,7 @@ import ( "github.com/hyperledger/fabric/integration/nwo/runner" . "github.com/onsi/gomega" + "github.com/onsi/gomega/gexec" ) type Components struct { @@ -32,7 +33,9 @@ func (c *Components) Discover() string { } func (c *Components) Idemixgen() string { - return c.Build("github.com/hyperledger/fabric/cmd/idemixgen") + idemixgen, err := gexec.Build("github.com/IBM/idemix/tools/idemixgen", "-mod=mod") + Expect(err).NotTo(HaveOccurred()) + return idemixgen } func (c *Components) Orderer() string { diff --git a/msp/configbuilder.go b/msp/configbuilder.go index 1424f66add0..6744b63332f 100644 --- a/msp/configbuilder.go +++ b/msp/configbuilder.go @@ -12,6 +12,7 @@ import ( "os" "path/filepath" + "github.com/IBM/idemix" "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-protos-go/msp" "github.com/hyperledger/fabric/bccsp" @@ -160,7 +161,7 @@ func GetLocalMspConfigWithType(dir string, bccspConfig *factory.FactoryOpts, ID, case ProviderTypeToString(FABRIC): return GetLocalMspConfig(dir, bccspConfig, ID) case ProviderTypeToString(IDEMIX): - return GetIdemixMspConfig(dir, ID) + return idemix.GetIdemixMspConfig(dir, ID) default: return nil, errors.Errorf("unknown MSP type '%s'", mspType) } @@ -198,7 +199,7 @@ func GetVerifyingMspConfig(dir, ID, mspType string) (*msp.MSPConfig, error) { case ProviderTypeToString(FABRIC): return getMspConfig(dir, ID, nil) case ProviderTypeToString(IDEMIX): - return GetIdemixMspConfig(dir, ID) + return idemix.GetIdemixMspConfig(dir, ID) default: return nil, errors.Errorf("unknown MSP type '%s'", mspType) } @@ -378,47 +379,3 @@ func loadCertificateAt(dir, certificatePath string, ouType string) []byte { return nil } - -const ( - IdemixConfigDirMsp = "msp" - IdemixConfigDirUser = "user" - IdemixConfigFileIssuerPublicKey = "IssuerPublicKey" - IdemixConfigFileRevocationPublicKey = "RevocationPublicKey" - IdemixConfigFileSigner = "SignerConfig" -) - -// GetIdemixMspConfig returns the configuration for the Idemix MSP -func GetIdemixMspConfig(dir string, ID string) (*msp.MSPConfig, error) { - ipkBytes, err := readFile(filepath.Join(dir, IdemixConfigDirMsp, IdemixConfigFileIssuerPublicKey)) - if err != nil { - return nil, errors.Wrapf(err, "failed to read issuer public key file") - } - - revocationPkBytes, err := readFile(filepath.Join(dir, IdemixConfigDirMsp, IdemixConfigFileRevocationPublicKey)) - if err != nil { - return nil, errors.Wrapf(err, "failed to read revocation public key file") - } - - idemixConfig := &msp.IdemixMSPConfig{ - Name: ID, - Ipk: ipkBytes, - RevocationPk: revocationPkBytes, - } - - signerBytes, err := readFile(filepath.Join(dir, IdemixConfigDirUser, IdemixConfigFileSigner)) - if err == nil { - signerConfig := &msp.IdemixMSPSignerConfig{} - err = proto.Unmarshal(signerBytes, signerConfig) - if err != nil { - return nil, err - } - idemixConfig.Signer = signerConfig - } - - confBytes, err := proto.Marshal(idemixConfig) - if err != nil { - return nil, err - } - - return &msp.MSPConfig{Config: confBytes, Type: int32(IDEMIX)}, nil -} diff --git a/msp/factory.go b/msp/factory.go index 109864898a4..e7510ad08a6 100644 --- a/msp/factory.go +++ b/msp/factory.go @@ -7,6 +7,7 @@ SPDX-License-Identifier: Apache-2.0 package msp import ( + "github.com/IBM/idemix" "github.com/hyperledger/fabric/bccsp" "github.com/pkg/errors" ) @@ -66,9 +67,19 @@ func New(opts NewOpts, cryptoProvider bccsp.BCCSP) (MSP, error) { case MSPv1_4_3: fallthrough case MSPv1_3: - return newIdemixMsp(MSPv1_3) + msp, err := idemix.NewIdemixMsp(MSPv1_3) + if err != nil { + return nil, err + } + + return &idemixMSPWrapper{msp.(*idemix.Idemixmsp)}, nil case MSPv1_1: - return newIdemixMsp(MSPv1_1) + msp, err := idemix.NewIdemixMsp(MSPv1_1) + if err != nil { + return nil, err + } + + return &idemixMSPWrapper{msp.(*idemix.Idemixmsp)}, nil default: return nil, errors.Errorf("Invalid *IdemixNewOpts. Version not recognized [%v]", opts.GetVersion()) } diff --git a/msp/idemix.go b/msp/idemix.go new file mode 100644 index 00000000000..78234d9874d --- /dev/null +++ b/msp/idemix.go @@ -0,0 +1,100 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +package msp + +import ( + "github.com/IBM/idemix" + "github.com/hyperledger/fabric-protos-go/msp" +) + +type idemixSigningIdentityWrapper struct { + *idemix.IdemixSigningIdentity +} + +func (i *idemixSigningIdentityWrapper) GetPublicVersion() Identity { + return &idemixIdentityWrapper{Idemixidentity: i.IdemixSigningIdentity.GetPublicVersion().(*idemix.Idemixidentity)} +} + +func (i *idemixSigningIdentityWrapper) GetIdentifier() *IdentityIdentifier { + return i.GetPublicVersion().GetIdentifier() +} + +func (i *idemixSigningIdentityWrapper) GetOrganizationalUnits() []*OUIdentifier { + return i.GetPublicVersion().GetOrganizationalUnits() +} + +type idemixIdentityWrapper struct { + *idemix.Idemixidentity +} + +func (i *idemixIdentityWrapper) GetIdentifier() *IdentityIdentifier { + id := i.Idemixidentity.GetIdentifier() + + return &IdentityIdentifier{ + Mspid: id.Mspid, + Id: id.Id, + } +} + +func (i *idemixIdentityWrapper) GetOrganizationalUnits() []*OUIdentifier { + ous := i.Idemixidentity.GetOrganizationalUnits() + wous := []*OUIdentifier{} + for _, ou := range ous { + wous = append(wous, &OUIdentifier{ + CertifiersIdentifier: ou.CertifiersIdentifier, + OrganizationalUnitIdentifier: ou.OrganizationalUnitIdentifier, + }) + } + + return wous +} + +type idemixMSPWrapper struct { + *idemix.Idemixmsp +} + +func (i *idemixMSPWrapper) deserializeIdentityInternal(serializedIdentity []byte) (Identity, error) { + id, err := i.Idemixmsp.DeserializeIdentityInternal(serializedIdentity) + if err != nil { + return nil, err + } + + return &idemixIdentityWrapper{id.(*idemix.Idemixidentity)}, nil +} + +func (i *idemixMSPWrapper) DeserializeIdentity(serializedIdentity []byte) (Identity, error) { + id, err := i.Idemixmsp.DeserializeIdentity(serializedIdentity) + if err != nil { + return nil, err + } + + return &idemixIdentityWrapper{id.(*idemix.Idemixidentity)}, nil +} + +func (i *idemixMSPWrapper) GetVersion() MSPVersion { + return MSPVersion(i.Idemixmsp.GetVersion()) +} + +func (i *idemixMSPWrapper) GetType() ProviderType { + return ProviderType(i.Idemixmsp.GetType()) +} + +func (i *idemixMSPWrapper) GetDefaultSigningIdentity() (SigningIdentity, error) { + id, err := i.Idemixmsp.GetDefaultSigningIdentity() + if err != nil { + return nil, err + } + + return &idemixSigningIdentityWrapper{id.(*idemix.IdemixSigningIdentity)}, nil +} + +func (i *idemixMSPWrapper) Validate(id Identity) error { + return i.Idemixmsp.Validate(id.(*idemixIdentityWrapper).Idemixidentity) +} + +func (i *idemixMSPWrapper) SatisfiesPrincipal(id Identity, principal *msp.MSPPrincipal) error { + return i.Idemixmsp.SatisfiesPrincipal(id.(*idemixIdentityWrapper).Idemixidentity, principal) +} diff --git a/msp/idemixmsp_test.go b/msp/idemixmsp_test.go deleted file mode 100644 index b1151612e4b..00000000000 --- a/msp/idemixmsp_test.go +++ /dev/null @@ -1,771 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package msp - -import ( - "testing" - - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-protos-go/msp" - "github.com/hyperledger/fabric/idemix" - "github.com/pkg/errors" - "github.com/stretchr/testify/require" -) - -func setup(configPath string, ID string) (MSP, error) { - return setupWithVersion(configPath, ID, MSPv1_3) -} - -func setupWithVersion(configPath string, ID string, version MSPVersion) (MSP, error) { - msp, err := newIdemixMsp(version) - if err != nil { - return nil, err - } - - conf, err := GetIdemixMspConfig(configPath, ID) - if err != nil { - return nil, errors.Wrap(err, "Getting MSP config failed") - } - - err = msp.Setup(conf) - if err != nil { - return nil, errors.Wrap(err, "Setting up MSP failed") - } - return msp, nil -} - -func getDefaultSigner(msp MSP) (SigningIdentity, error) { - id, err := msp.GetDefaultSigningIdentity() - if err != nil { - return nil, errors.Wrap(err, "Getting default signing identity failed") - } - - err = id.Validate() - if err != nil { - return nil, errors.Wrap(err, "Default signing identity invalid") - } - - err = msp.Validate(id) - if err != nil { - return nil, errors.Wrap(err, "Default signing identity invalid") - } - - return id, nil -} - -func TestSetup(t *testing.T) { - msp, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - require.Equal(t, IDEMIX, msp.GetType()) -} - -func TestSetupBad(t *testing.T) { - _, err := setup("testdata/idemix/badpath", "MSPID") - require.Error(t, err) - require.Contains(t, err.Error(), "Getting MSP config failed") - - msp1, err := newIdemixMsp(MSPv1_3) - require.NoError(t, err) - - // Setup with nil config - err = msp1.Setup(nil) - require.Error(t, err) - require.Contains(t, err.Error(), "setup error: nil conf reference") - - // Setup with incorrect MSP type - conf := &msp.MSPConfig{Type: 1234, Config: nil} - err = msp1.Setup(conf) - require.Error(t, err) - require.Contains(t, err.Error(), "setup error: config is not of type IDEMIX") - - // Setup with bad idemix config bytes - conf = &msp.MSPConfig{Type: int32(IDEMIX), Config: []byte("barf")} - err = msp1.Setup(conf) - require.Error(t, err) - require.Contains(t, err.Error(), "failed unmarshalling idemix msp config") - - conf, err = GetIdemixMspConfig("testdata/idemix/MSP1OU1", "IdemixMSP1") - require.NoError(t, err) - idemixconfig := &msp.IdemixMSPConfig{} - err = proto.Unmarshal(conf.Config, idemixconfig) - require.NoError(t, err) - - // Create MSP config with IPK with incorrect attribute names - rng, err := idemix.GetRand() - require.NoError(t, err) - key, err := idemix.NewIssuerKey([]string{}, rng) - require.NoError(t, err) - ipkBytes, err := proto.Marshal(key.Ipk) - require.NoError(t, err) - idemixconfig.Ipk = ipkBytes - - idemixConfigBytes, err := proto.Marshal(idemixconfig) - require.NoError(t, err) - conf.Config = idemixConfigBytes - - err = msp1.Setup(conf) - require.Error(t, err) - require.Contains(t, err.Error(), "issuer public key must have have attributes OU, Role, EnrollmentId, and RevocationHandle") - - // Create MSP config with bad IPK bytes - ipkBytes = []byte("barf") - idemixconfig.Ipk = ipkBytes - - idemixConfigBytes, err = proto.Marshal(idemixconfig) - require.NoError(t, err) - conf.Config = idemixConfigBytes - - err = msp1.Setup(conf) - require.Error(t, err) - require.Contains(t, err.Error(), "failed to unmarshal ipk from idemix msp config") -} - -func TestSigning(t *testing.T) { - msp, err := setup("testdata/idemix/MSP1OU1", "MSP1") - require.NoError(t, err) - - id, err := getDefaultSigner(msp) - require.NoError(t, err) - - msg := []byte("TestMessage") - sig, err := id.Sign(msg) - require.NoError(t, err) - - err = id.Verify(msg, sig) - require.NoError(t, err) - - err = id.Verify([]byte("OtherMessage"), sig) - require.Error(t, err) - require.Contains(t, err.Error(), "pseudonym signature invalid: zero-knowledge proof is invalid") - - verMsp, err := setup("testdata/idemix/MSP1Verifier", "MSP1") - require.NoError(t, err) - err = verMsp.Validate(id) - require.NoError(t, err) - _, err = verMsp.GetDefaultSigningIdentity() - require.Error(t, err) - require.Contains(t, err.Error(), "no default signer setup") -} - -func TestSigningBad(t *testing.T) { - msp, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id, err := getDefaultSigner(msp) - require.NoError(t, err) - - msg := []byte("TestMessage") - sig := []byte("barf") - - err = id.Verify(msg, sig) - require.Error(t, err) - require.Contains(t, err.Error(), "error unmarshalling signature") -} - -func TestIdentitySerialization(t *testing.T) { - msp, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id, err := getDefaultSigner(msp) - require.NoError(t, err) - - // Test serialization of identities - serializedID, err := id.Serialize() - require.NoError(t, err) - - verID, err := msp.DeserializeIdentity(serializedID) - require.NoError(t, err) - - err = verID.Validate() - require.NoError(t, err) - - err = msp.Validate(verID) - require.NoError(t, err) -} - -func TestIdentitySerializationBad(t *testing.T) { - msp, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - _, err = msp.DeserializeIdentity([]byte("barf")) - require.Error(t, err, "DeserializeIdentity should have failed for bad input") - require.Contains(t, err.Error(), "could not deserialize a SerializedIdentity") -} - -func TestIdentitySerializationWrongMSP(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - msp2, err := setup("testdata/idemix/MSP2OU1", "MSP2OU1") - require.NoError(t, err) - id2, err := getDefaultSigner(msp2) - require.NoError(t, err) - - idBytes, err := id2.Serialize() - require.NoError(t, err) - - _, err = msp1.DeserializeIdentity(idBytes) - require.Error(t, err, "DeserializeIdentity should have failed for ID of other MSP") - require.Contains(t, err.Error(), "expected MSP ID MSP1OU1, received MSP2OU1") -} - -func TestPrincipalIdentity(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - idBytes, err := id1.Serialize() - require.NoError(t, err) - - principal := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_IDENTITY, - Principal: idBytes, - } - - err = id1.SatisfiesPrincipal(principal) - require.NoError(t, err) -} - -func TestPrincipalIdentityWrongIdentity(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - msp2, err := setup("testdata/idemix/MSP1OU2", "MSP1OU2") - require.NoError(t, err) - - id2, err := getDefaultSigner(msp2) - require.NoError(t, err) - - idBytes, err := id1.Serialize() - require.NoError(t, err) - - principal := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_IDENTITY, - Principal: idBytes, - } - - err = id2.SatisfiesPrincipal(principal) - require.Error(t, err, "Identity MSP principal for different user should fail") - require.Contains(t, err.Error(), "the identities do not match") -} - -func TestPrincipalIdentityBadIdentity(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - idBytes := []byte("barf") - - principal := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_IDENTITY, - Principal: idBytes, - } - - err = id1.SatisfiesPrincipal(principal) - require.Error(t, err, "Identity MSP principal for a bad principal should fail") - require.Contains(t, err.Error(), "the identities do not match") -} - -func TestAnonymityPrincipal(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - principalBytes, err := proto.Marshal(&msp.MSPIdentityAnonymity{AnonymityType: msp.MSPIdentityAnonymity_ANONYMOUS}) - require.NoError(t, err) - - principal := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ANONYMITY, - Principal: principalBytes, - } - - err = id1.SatisfiesPrincipal(principal) - require.NoError(t, err) -} - -func TestAnonymityPrincipalBad(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - principalBytes, err := proto.Marshal(&msp.MSPIdentityAnonymity{AnonymityType: msp.MSPIdentityAnonymity_NOMINAL}) - require.NoError(t, err) - - principal := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ANONYMITY, - Principal: principalBytes, - } - - err = id1.SatisfiesPrincipal(principal) - require.Error(t, err, "Idemix identity is anonymous and should not pass NOMINAL anonymity principal") - require.Contains(t, err.Error(), "principal is nominal, but idemix MSP is anonymous") -} - -func TestAnonymityPrincipalV11(t *testing.T) { - msp1, err := setupWithVersion("testdata/idemix/MSP1OU1", "MSP1OU1", MSPv1_1) - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - principalBytes, err := proto.Marshal(&msp.MSPIdentityAnonymity{AnonymityType: msp.MSPIdentityAnonymity_NOMINAL}) - require.NoError(t, err) - - principal := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ANONYMITY, - Principal: principalBytes, - } - - err = id1.SatisfiesPrincipal(principal) - require.Error(t, err) - require.Contains(t, err.Error(), "Anonymity MSP Principals are unsupported in MSPv1_1") -} - -func TestIdemixIsWellFormed(t *testing.T) { - idemixMSP, err := setup("testdata/idemix/MSP1OU1", "TestName") - require.NoError(t, err) - - id, err := getDefaultSigner(idemixMSP) - require.NoError(t, err) - rawId, err := id.Serialize() - require.NoError(t, err) - sId := &msp.SerializedIdentity{} - err = proto.Unmarshal(rawId, sId) - require.NoError(t, err) - err = idemixMSP.IsWellFormed(sId) - require.NoError(t, err) - // Corrupt the identity bytes - sId.IdBytes = append(sId.IdBytes, 1) - err = idemixMSP.IsWellFormed(sId) - require.Error(t, err) - require.Contains(t, err.Error(), "not an idemix identity") -} - -func TestPrincipalOU(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - ou := &msp.OrganizationUnit{ - OrganizationalUnitIdentifier: id1.GetOrganizationalUnits()[0].OrganizationalUnitIdentifier, - MspIdentifier: id1.GetMSPIdentifier(), - CertifiersIdentifier: nil, - } - bytes, err := proto.Marshal(ou) - require.NoError(t, err) - - principal := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ORGANIZATION_UNIT, - Principal: bytes, - } - - err = id1.SatisfiesPrincipal(principal) - require.NoError(t, err) -} - -func TestPrincipalOUWrongOU(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - ou := &msp.OrganizationUnit{ - OrganizationalUnitIdentifier: "DifferentOU", - MspIdentifier: id1.GetMSPIdentifier(), - CertifiersIdentifier: nil, - } - bytes, err := proto.Marshal(ou) - require.NoError(t, err) - - principal := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ORGANIZATION_UNIT, - Principal: bytes, - } - - err = id1.SatisfiesPrincipal(principal) - require.Error(t, err, "OU MSP principal should have failed for user of different OU") - require.Contains(t, err.Error(), "user is not part of the desired organizational unit") -} - -func TestPrincipalOUWrongMSP(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - ou := &msp.OrganizationUnit{ - OrganizationalUnitIdentifier: "OU1", - MspIdentifier: "OtherMSP", - CertifiersIdentifier: nil, - } - bytes, err := proto.Marshal(ou) - require.NoError(t, err) - - principal := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ORGANIZATION_UNIT, - Principal: bytes, - } - - err = id1.SatisfiesPrincipal(principal) - require.Error(t, err, "OU MSP principal should have failed for user of different MSP") - require.Contains(t, err.Error(), "the identity is a member of a different MSP") -} - -func TestPrincipalOUBad(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - bytes := []byte("barf") - require.NoError(t, err) - - principal := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ORGANIZATION_UNIT, - Principal: bytes, - } - - err = id1.SatisfiesPrincipal(principal) - require.Error(t, err, "OU MSP principal should have failed for a bad OU principal") - require.Contains(t, err.Error(), "could not unmarshal OU from principal") -} - -func TestPrincipalRoleMember(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - principalBytes, err := proto.Marshal(&msp.MSPRole{Role: msp.MSPRole_MEMBER, MspIdentifier: id1.GetMSPIdentifier()}) - require.NoError(t, err) - - principal := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ROLE, - Principal: principalBytes, - } - - err = id1.SatisfiesPrincipal(principal) - require.NoError(t, err) - - // Member should also satisfy client - principalBytes, err = proto.Marshal(&msp.MSPRole{Role: msp.MSPRole_CLIENT, MspIdentifier: id1.GetMSPIdentifier()}) - require.NoError(t, err) - - principal = &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ROLE, - Principal: principalBytes, - } - - err = id1.SatisfiesPrincipal(principal) - require.NoError(t, err) -} - -func TestPrincipalRoleAdmin(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1Admin", "MSP1OU1Admin") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - principalBytes, err := proto.Marshal(&msp.MSPRole{Role: msp.MSPRole_MEMBER, MspIdentifier: id1.GetMSPIdentifier()}) - require.NoError(t, err) - - principal := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ROLE, - Principal: principalBytes, - } - - // Admin should also satisfy member - err = id1.SatisfiesPrincipal(principal) - require.NoError(t, err) - - principalBytes, err = proto.Marshal(&msp.MSPRole{Role: msp.MSPRole_ADMIN, MspIdentifier: id1.GetMSPIdentifier()}) - require.NoError(t, err) - - principal = &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ROLE, - Principal: principalBytes, - } - - err = id1.SatisfiesPrincipal(principal) - require.NoError(t, err) -} - -func TestPrincipalRoleNotPeer(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1Admin", "MSP1OU1") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - principalBytes, err := proto.Marshal(&msp.MSPRole{Role: msp.MSPRole_PEER, MspIdentifier: id1.GetMSPIdentifier()}) - require.NoError(t, err) - - principal := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ROLE, - Principal: principalBytes, - } - - err = id1.SatisfiesPrincipal(principal) - require.Error(t, err, "Admin should not satisfy PEER principal") - require.Contains(t, err.Error(), "idemixmsp only supports client use, so it cannot satisfy an MSPRole PEER principal") -} - -func TestPrincipalRoleNotAdmin(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - principalBytes, err := proto.Marshal(&msp.MSPRole{Role: msp.MSPRole_ADMIN, MspIdentifier: id1.GetMSPIdentifier()}) - require.NoError(t, err) - - principal := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ROLE, - Principal: principalBytes, - } - - err = id1.SatisfiesPrincipal(principal) - require.Error(t, err, "Member should not satisfy Admin principal") - require.Contains(t, err.Error(), "user is not an admin") -} - -func TestPrincipalRoleWrongMSP(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - principalBytes, err := proto.Marshal(&msp.MSPRole{Role: msp.MSPRole_MEMBER, MspIdentifier: "OtherMSP"}) - require.NoError(t, err) - - principal := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ROLE, - Principal: principalBytes, - } - - err = id1.SatisfiesPrincipal(principal) - require.Error(t, err, "Role MSP principal should have failed for user of different MSP") - require.Contains(t, err.Error(), "the identity is a member of a different MSP") -} - -func TestPrincipalRoleBadRole(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - // Make principal for nonexisting role 1234 - principalBytes, err := proto.Marshal(&msp.MSPRole{Role: 1234, MspIdentifier: id1.GetMSPIdentifier()}) - require.NoError(t, err) - - principal := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ROLE, - Principal: principalBytes, - } - - err = id1.SatisfiesPrincipal(principal) - require.Error(t, err, "Role MSP principal should have failed for a bad Role") - require.Contains(t, err.Error(), "invalid MSP role type") -} - -func TestPrincipalBad(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - principal := &msp.MSPPrincipal{ - PrincipalClassification: 1234, - Principal: nil, - } - - err = id1.SatisfiesPrincipal(principal) - require.Error(t, err, "Principal with bad Classification should fail") - require.Contains(t, err.Error(), "invalid principal type") -} - -func TestPrincipalCombined(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - ou := &msp.OrganizationUnit{ - OrganizationalUnitIdentifier: id1.GetOrganizationalUnits()[0].OrganizationalUnitIdentifier, - MspIdentifier: id1.GetMSPIdentifier(), - CertifiersIdentifier: nil, - } - principalBytes, err := proto.Marshal(ou) - require.NoError(t, err) - - principalOU := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ORGANIZATION_UNIT, - Principal: principalBytes, - } - - principalBytes, err = proto.Marshal(&msp.MSPRole{Role: msp.MSPRole_MEMBER, MspIdentifier: id1.GetMSPIdentifier()}) - require.NoError(t, err) - - principalRole := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ROLE, - Principal: principalBytes, - } - - principals := []*msp.MSPPrincipal{principalOU, principalRole} - - combinedPrincipal := &msp.CombinedPrincipal{Principals: principals} - combinedPrincipalBytes, err := proto.Marshal(combinedPrincipal) - - require.NoError(t, err) - - principalsCombined := &msp.MSPPrincipal{PrincipalClassification: msp.MSPPrincipal_COMBINED, Principal: combinedPrincipalBytes} - - err = id1.SatisfiesPrincipal(principalsCombined) - require.NoError(t, err) -} - -func TestPrincipalCombinedBad(t *testing.T) { - msp1, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1") - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - // create combined principal requiring membership of OU1 in MSP1 and requiring admin role - ou := &msp.OrganizationUnit{ - OrganizationalUnitIdentifier: id1.GetOrganizationalUnits()[0].OrganizationalUnitIdentifier, - MspIdentifier: id1.GetMSPIdentifier(), - CertifiersIdentifier: nil, - } - principalBytes, err := proto.Marshal(ou) - require.NoError(t, err) - - principalOU := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ORGANIZATION_UNIT, - Principal: principalBytes, - } - - principalBytes, err = proto.Marshal(&msp.MSPRole{Role: msp.MSPRole_ADMIN, MspIdentifier: id1.GetMSPIdentifier()}) - require.NoError(t, err) - - principalRole := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ROLE, - Principal: principalBytes, - } - - principals := []*msp.MSPPrincipal{principalOU, principalRole} - - combinedPrincipal := &msp.CombinedPrincipal{Principals: principals} - combinedPrincipalBytes, err := proto.Marshal(combinedPrincipal) - - require.NoError(t, err) - - principalsCombined := &msp.MSPPrincipal{PrincipalClassification: msp.MSPPrincipal_COMBINED, Principal: combinedPrincipalBytes} - - err = id1.SatisfiesPrincipal(principalsCombined) - require.Error(t, err, "non-admin member of OU1 in MSP1 should not satisfy principal admin and OU1 in MSP1") - require.Contains(t, err.Error(), "user is not an admin") -} - -func TestPrincipalCombinedV11(t *testing.T) { - msp1, err := setupWithVersion("testdata/idemix/MSP1OU1", "MSP1OU1", MSPv1_1) - require.NoError(t, err) - - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - ou := &msp.OrganizationUnit{ - OrganizationalUnitIdentifier: id1.GetOrganizationalUnits()[0].OrganizationalUnitIdentifier, - MspIdentifier: id1.GetMSPIdentifier(), - CertifiersIdentifier: nil, - } - principalBytes, err := proto.Marshal(ou) - require.NoError(t, err) - - principalOU := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ORGANIZATION_UNIT, - Principal: principalBytes, - } - - principalBytes, err = proto.Marshal(&msp.MSPRole{Role: msp.MSPRole_MEMBER, MspIdentifier: id1.GetMSPIdentifier()}) - require.NoError(t, err) - - principalRole := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ROLE, - Principal: principalBytes, - } - - principals := []*msp.MSPPrincipal{principalOU, principalRole} - - combinedPrincipal := &msp.CombinedPrincipal{Principals: principals} - combinedPrincipalBytes, err := proto.Marshal(combinedPrincipal) - - require.NoError(t, err) - - principalsCombined := &msp.MSPPrincipal{PrincipalClassification: msp.MSPPrincipal_COMBINED, Principal: combinedPrincipalBytes} - - err = id1.SatisfiesPrincipal(principalsCombined) - require.Error(t, err) - require.Contains(t, err.Error(), "Combined MSP Principals are unsupported in MSPv1_1") -} - -func TestRoleClientV11(t *testing.T) { - msp1, err := setupWithVersion("testdata/idemix/MSP1OU1", "MSP1OU1", MSPv1_1) - require.NoError(t, err) - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - principalBytes, err := proto.Marshal(&msp.MSPRole{Role: msp.MSPRole_CLIENT, MspIdentifier: id1.GetMSPIdentifier()}) - require.NoError(t, err) - principalRole := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ROLE, - Principal: principalBytes, - } - err = id1.SatisfiesPrincipal(principalRole) - require.Error(t, err) - require.Contains(t, err.Error(), "invalid MSP role type") -} - -func TestRolePeerV11(t *testing.T) { - msp1, err := setupWithVersion("testdata/idemix/MSP1OU1", "MSP1OU1", MSPv1_1) - require.NoError(t, err) - id1, err := getDefaultSigner(msp1) - require.NoError(t, err) - - principalBytes, err := proto.Marshal(&msp.MSPRole{Role: msp.MSPRole_PEER, MspIdentifier: id1.GetMSPIdentifier()}) - require.NoError(t, err) - principalRole := &msp.MSPPrincipal{ - PrincipalClassification: msp.MSPPrincipal_ROLE, - Principal: principalBytes, - } - err = id1.SatisfiesPrincipal(principalRole) - require.Error(t, err) - require.Contains(t, err.Error(), "invalid MSP role type") -} diff --git a/msp/mspmgrimpl.go b/msp/mspmgrimpl.go index f1f93029bd0..718e05075ee 100644 --- a/msp/mspmgrimpl.go +++ b/msp/mspmgrimpl.go @@ -92,7 +92,7 @@ func (mgr *mspManagerImpl) DeserializeIdentity(serializedID []byte) (Identity, e switch t := msp.(type) { case *bccspmsp: return t.deserializeIdentityInternal(sId.IdBytes) - case *idemixmsp: + case *idemixMSPWrapper: return t.deserializeIdentityInternal(sId.IdBytes) default: return t.DeserializeIdentity(serializedID) diff --git a/msp/testdata/idemix/MSP1OU1/ca/IssuerPublicKey b/msp/testdata/idemix/MSP1OU1/ca/IssuerPublicKey deleted file mode 100644 index 034daa5753f..00000000000 --- a/msp/testdata/idemix/MSP1OU1/ca/IssuerPublicKey +++ /dev/null @@ -1,16 +0,0 @@ - -OU -Role - EnrollmentID -RevocationHandleD - �^٪�����h�ĉ�l<�3�t���%(N�P� ���5����x|_�}|M�΂3�8u��UX�˷D - �'+{S9�! � x^k좃����9NXO�{?%� ��@��n GÚ£HD8�|��٘p���$6�!6�"D - �!s�dW�4�0b���ʸ��T�D-��+(�mX �ʺ��[���Ҋε���x� �����˛�[�T"D - ����O����(��1�qJ�)�Ji�,\�a ���e%�s����3�� ]���#���%����"D - ��\n�m��;s�=�a�sm�R�&��W��m#j �,�.l�T�wjWpH6�hg]��eA�T�~"D - �o�E��6�‘�Û”<$��^b��bE�%�� �HØ™g�Ö¼I���]�nT ��ǃ'܆�٘�*� - U~;��lk�E�0S�&Lj̗��#@��9P�VN �>Ó �����N��Hh6�����7���fJ 9��E���Z���ɳ��1z�*B�# N�" �!������9�uLN�H���������� -y2D - ���i� ���mLB�� �^��Y�~����D.D ����HRxIk%�>����or���V��7?YL:D - ]Fq�#A����3I�����TgGf�K�\x -� �i�Չ~�o�/���P�։� >ˆ�P�vB 3����}������x]�RJ��P@D��J �;l��D����Ny��x��E��b�t�چ���R ���Z�1̶�V�0o��{��܉������֫� \ No newline at end of file diff --git a/msp/testdata/idemix/MSP1OU1/ca/IssuerSecretKey b/msp/testdata/idemix/MSP1OU1/ca/IssuerSecretKey deleted file mode 100644 index 10b591dea0a..00000000000 --- a/msp/testdata/idemix/MSP1OU1/ca/IssuerSecretKey +++ /dev/null @@ -1 +0,0 @@ -d�{�ҟ�� �\�fR�Q�[�Ó �����N��Hh6�����7���fJ 9��E���Z���ɳ��1z�*B�# N�" �!������9�uLN�H���������� -y2D - ���i� ���mLB�� �^��Y�~����D.D ����HRxIk%�>����or���V��7?YL:D - ]Fq�#A����3I�����TgGf�K�\x -� �i�Չ~�o�/���P�։� >ˆ�P�vB 3����}������x]�RJ��P@D��J �;l��D����Ny��x��E��b�t�چ���R ���Z�1̶�V�0o��{��܉������֫� \ No newline at end of file diff --git a/msp/testdata/idemix/MSP1OU1/msp/RevocationPublicKey b/msp/testdata/idemix/MSP1OU1/msp/RevocationPublicKey deleted file mode 100644 index a0fc2af367d..00000000000 --- a/msp/testdata/idemix/MSP1OU1/msp/RevocationPublicKey +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN PUBLIC KEY----- -MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE76UE50n31TB34E3tEHi9vyaLXEJIpxF6 -Ur1eWKRIpZ7Pyi55fHg93nM2kKwglbX6LLRIl0nzMLhgvwJpIlVh+REM63cNj9D0 -80OaN8HetLRG7Hpj7ipR3Q4VjZ0x22ZC ------END PUBLIC KEY----- diff --git a/msp/testdata/idemix/MSP1OU1/user/SignerConfig b/msp/testdata/idemix/MSP1OU1/user/SignerConfig deleted file mode 100644 index f496457a543..00000000000 Binary files a/msp/testdata/idemix/MSP1OU1/user/SignerConfig and /dev/null differ diff --git a/msp/testdata/idemix/MSP1OU1Admin/ca/IssuerPublicKey b/msp/testdata/idemix/MSP1OU1Admin/ca/IssuerPublicKey deleted file mode 100644 index 034daa5753f..00000000000 --- a/msp/testdata/idemix/MSP1OU1Admin/ca/IssuerPublicKey +++ /dev/null @@ -1,16 +0,0 @@ - -OU -Role - EnrollmentID -RevocationHandleD - �^٪�����h�ĉ�l<�3�t���%(N�P� ���5����x|_�}|M�΂3�8u��UX�˷D - �'+{S9�! � x^k좃����9NXO�{?%� ��@��n GÚ£HD8�|��٘p���$6�!6�"D - �!s�dW�4�0b���ʸ��T�D-��+(�mX �ʺ��[���Ҋε���x� �����˛�[�T"D - ����O����(��1�qJ�)�Ji�,\�a ���e%�s����3�� ]���#���%����"D - ��\n�m��;s�=�a�sm�R�&��W��m#j �,�.l�T�wjWpH6�hg]��eA�T�~"D - �o�E��6�‘�Û”<$��^b��bE�%�� �HØ™g�Ö¼I���]�nT ��ǃ'܆�٘�*� - U~;��lk�E�0S�&Lj̗��#@��9P�VN �>Ó �����N��Hh6�����7���fJ 9��E���Z���ɳ��1z�*B�# N�" �!������9�uLN�H���������� -y2D - ���i� ���mLB�� �^��Y�~����D.D ����HRxIk%�>����or���V��7?YL:D - ]Fq�#A����3I�����TgGf�K�\x -� �i�Չ~�o�/���P�։� >ˆ�P�vB 3����}������x]�RJ��P@D��J �;l��D����Ny��x��E��b�t�چ���R ���Z�1̶�V�0o��{��܉������֫� \ No newline at end of file diff --git a/msp/testdata/idemix/MSP1OU1Admin/ca/IssuerSecretKey b/msp/testdata/idemix/MSP1OU1Admin/ca/IssuerSecretKey deleted file mode 100644 index 10b591dea0a..00000000000 --- a/msp/testdata/idemix/MSP1OU1Admin/ca/IssuerSecretKey +++ /dev/null @@ -1 +0,0 @@ -d�{�ҟ�� �\�fR�Q�[�Ó �����N��Hh6�����7���fJ 9��E���Z���ɳ��1z�*B�# N�" �!������9�uLN�H���������� -y2D - ���i� ���mLB�� �^��Y�~����D.D ����HRxIk%�>����or���V��7?YL:D - ]Fq�#A����3I�����TgGf�K�\x -� �i�Չ~�o�/���P�։� >ˆ�P�vB 3����}������x]�RJ��P@D��J �;l��D����Ny��x��E��b�t�چ���R ���Z�1̶�V�0o��{��܉������֫� \ No newline at end of file diff --git a/msp/testdata/idemix/MSP1OU1Admin/msp/RevocationPublicKey b/msp/testdata/idemix/MSP1OU1Admin/msp/RevocationPublicKey deleted file mode 100644 index a0fc2af367d..00000000000 --- a/msp/testdata/idemix/MSP1OU1Admin/msp/RevocationPublicKey +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN PUBLIC KEY----- -MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE76UE50n31TB34E3tEHi9vyaLXEJIpxF6 -Ur1eWKRIpZ7Pyi55fHg93nM2kKwglbX6LLRIl0nzMLhgvwJpIlVh+REM63cNj9D0 -80OaN8HetLRG7Hpj7ipR3Q4VjZ0x22ZC ------END PUBLIC KEY----- diff --git a/msp/testdata/idemix/MSP1OU1Admin/user/SignerConfig b/msp/testdata/idemix/MSP1OU1Admin/user/SignerConfig deleted file mode 100644 index 767b1131585..00000000000 Binary files a/msp/testdata/idemix/MSP1OU1Admin/user/SignerConfig and /dev/null differ diff --git a/msp/testdata/idemix/MSP1OU2/ca/IssuerPublicKey b/msp/testdata/idemix/MSP1OU2/ca/IssuerPublicKey deleted file mode 100644 index 034daa5753f..00000000000 --- a/msp/testdata/idemix/MSP1OU2/ca/IssuerPublicKey +++ /dev/null @@ -1,16 +0,0 @@ - -OU -Role - EnrollmentID -RevocationHandleD - �^٪�����h�ĉ�l<�3�t���%(N�P� ���5����x|_�}|M�΂3�8u��UX�˷D - �'+{S9�! � x^k좃����9NXO�{?%� ��@��n GÚ£HD8�|��٘p���$6�!6�"D - �!s�dW�4�0b���ʸ��T�D-��+(�mX �ʺ��[���Ҋε���x� �����˛�[�T"D - ����O����(��1�qJ�)�Ji�,\�a ���e%�s����3�� ]���#���%����"D - ��\n�m��;s�=�a�sm�R�&��W��m#j �,�.l�T�wjWpH6�hg]��eA�T�~"D - �o�E��6�‘�Û”<$��^b��bE�%�� �HØ™g�Ö¼I���]�nT ��ǃ'܆�٘�*� - U~;��lk�E�0S�&Lj̗��#@��9P�VN �>Ó �����N��Hh6�����7���fJ 9��E���Z���ɳ��1z�*B�# N�" �!������9�uLN�H���������� -y2D - ���i� ���mLB�� �^��Y�~����D.D ����HRxIk%�>����or���V��7?YL:D - ]Fq�#A����3I�����TgGf�K�\x -� �i�Չ~�o�/���P�։� >ˆ�P�vB 3����}������x]�RJ��P@D��J �;l��D����Ny��x��E��b�t�چ���R ���Z�1̶�V�0o��{��܉������֫� \ No newline at end of file diff --git a/msp/testdata/idemix/MSP1OU2/ca/IssuerSecretKey b/msp/testdata/idemix/MSP1OU2/ca/IssuerSecretKey deleted file mode 100644 index 10b591dea0a..00000000000 --- a/msp/testdata/idemix/MSP1OU2/ca/IssuerSecretKey +++ /dev/null @@ -1 +0,0 @@ -d�{�ҟ�� �\�fR�Q�[�Ó �����N��Hh6�����7���fJ 9��E���Z���ɳ��1z�*B�# N�" �!������9�uLN�H���������� -y2D - ���i� ���mLB�� �^��Y�~����D.D ����HRxIk%�>����or���V��7?YL:D - ]Fq�#A����3I�����TgGf�K�\x -� �i�Չ~�o�/���P�։� >ˆ�P�vB 3����}������x]�RJ��P@D��J �;l��D����Ny��x��E��b�t�چ���R ���Z�1̶�V�0o��{��܉������֫� \ No newline at end of file diff --git a/msp/testdata/idemix/MSP1OU2/msp/RevocationPublicKey b/msp/testdata/idemix/MSP1OU2/msp/RevocationPublicKey deleted file mode 100644 index a0fc2af367d..00000000000 --- a/msp/testdata/idemix/MSP1OU2/msp/RevocationPublicKey +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN PUBLIC KEY----- -MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE76UE50n31TB34E3tEHi9vyaLXEJIpxF6 -Ur1eWKRIpZ7Pyi55fHg93nM2kKwglbX6LLRIl0nzMLhgvwJpIlVh+REM63cNj9D0 -80OaN8HetLRG7Hpj7ipR3Q4VjZ0x22ZC ------END PUBLIC KEY----- diff --git a/msp/testdata/idemix/MSP1OU2/user/SignerConfig b/msp/testdata/idemix/MSP1OU2/user/SignerConfig deleted file mode 100644 index 7b2c560afac..00000000000 Binary files a/msp/testdata/idemix/MSP1OU2/user/SignerConfig and /dev/null differ diff --git a/msp/testdata/idemix/MSP1Verifier/ca/IssuerPublicKey b/msp/testdata/idemix/MSP1Verifier/ca/IssuerPublicKey deleted file mode 100644 index 034daa5753f..00000000000 --- a/msp/testdata/idemix/MSP1Verifier/ca/IssuerPublicKey +++ /dev/null @@ -1,16 +0,0 @@ - -OU -Role - EnrollmentID -RevocationHandleD - �^٪�����h�ĉ�l<�3�t���%(N�P� ���5����x|_�}|M�΂3�8u��UX�˷D - �'+{S9�! � x^k좃����9NXO�{?%� ��@��n GÚ£HD8�|��٘p���$6�!6�"D - �!s�dW�4�0b���ʸ��T�D-��+(�mX �ʺ��[���Ҋε���x� �����˛�[�T"D - ����O����(��1�qJ�)�Ji�,\�a ���e%�s����3�� ]���#���%����"D - ��\n�m��;s�=�a�sm�R�&��W��m#j �,�.l�T�wjWpH6�hg]��eA�T�~"D - �o�E��6�‘�Û”<$��^b��bE�%�� �HØ™g�Ö¼I���]�nT ��ǃ'܆�٘�*� - U~;��lk�E�0S�&Lj̗��#@��9P�VN �>Ó �����N��Hh6�����7���fJ 9��E���Z���ɳ��1z�*B�# N�" �!������9�uLN�H���������� -y2D - ���i� ���mLB�� �^��Y�~����D.D ����HRxIk%�>����or���V��7?YL:D - ]Fq�#A����3I�����TgGf�K�\x -� �i�Չ~�o�/���P�։� >ˆ�P�vB 3����}������x]�RJ��P@D��J �;l��D����Ny��x��E��b�t�چ���R ���Z�1̶�V�0o��{��܉������֫� \ No newline at end of file diff --git a/msp/testdata/idemix/MSP1Verifier/ca/IssuerSecretKey b/msp/testdata/idemix/MSP1Verifier/ca/IssuerSecretKey deleted file mode 100644 index 10b591dea0a..00000000000 --- a/msp/testdata/idemix/MSP1Verifier/ca/IssuerSecretKey +++ /dev/null @@ -1 +0,0 @@ -d�{�ҟ�� �\�fR�Q�[�Ó �����N��Hh6�����7���fJ 9��E���Z���ɳ��1z�*B�# N�" �!������9�uLN�H���������� -y2D - ���i� ���mLB�� �^��Y�~����D.D ����HRxIk%�>����or���V��7?YL:D - ]Fq�#A����3I�����TgGf�K�\x -� �i�Չ~�o�/���P�։� >ˆ�P�vB 3����}������x]�RJ��P@D��J �;l��D����Ny��x��E��b�t�چ���R ���Z�1̶�V�0o��{��܉������֫� \ No newline at end of file diff --git a/msp/testdata/idemix/MSP1Verifier/msp/RevocationPublicKey b/msp/testdata/idemix/MSP1Verifier/msp/RevocationPublicKey deleted file mode 100644 index a0fc2af367d..00000000000 --- a/msp/testdata/idemix/MSP1Verifier/msp/RevocationPublicKey +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN PUBLIC KEY----- -MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE76UE50n31TB34E3tEHi9vyaLXEJIpxF6 -Ur1eWKRIpZ7Pyi55fHg93nM2kKwglbX6LLRIl0nzMLhgvwJpIlVh+REM63cNj9D0 -80OaN8HetLRG7Hpj7ipR3Q4VjZ0x22ZC ------END PUBLIC KEY----- diff --git a/msp/testdata/idemix/MSP2OU1/ca/IssuerPublicKey b/msp/testdata/idemix/MSP2OU1/ca/IssuerPublicKey deleted file mode 100644 index cb904d7580f..00000000000 Binary files a/msp/testdata/idemix/MSP2OU1/ca/IssuerPublicKey and /dev/null differ diff --git a/msp/testdata/idemix/MSP2OU1/ca/IssuerSecretKey b/msp/testdata/idemix/MSP2OU1/ca/IssuerSecretKey deleted file mode 100644 index 7645123f8ef..00000000000 --- a/msp/testdata/idemix/MSP2OU1/ca/IssuerSecretKey +++ /dev/null @@ -1 +0,0 @@ -Z��݇-E_��} �����DEt�QIw��`� \ No newline at end of file diff --git a/msp/testdata/idemix/MSP2OU1/ca/RevocationKey b/msp/testdata/idemix/MSP2OU1/ca/RevocationKey deleted file mode 100644 index fc9280c554b..00000000000 --- a/msp/testdata/idemix/MSP2OU1/ca/RevocationKey +++ /dev/null @@ -1,6 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIGkAgEBBDACDZ/H28Lz9ZkRt9DPS0S2St6myYr0yOXUBh6jXnL6Xd6KtxG9Gvbx -izkRk9WPY0qgBwYFK4EEACKhZANiAAShz6e2n4kjEI/AmkIciyGlVXlrcupnNjSN -3wgtr7WvvtmhmrMSxNRNa+wAuaHKcLwUlRvf/S6xswzdFaWkSOv7b0XQrlpTPZkb -Y7l14ajp4H3Le6dw4D8Wj6PLgDA6EXc= ------END PRIVATE KEY----- diff --git a/msp/testdata/idemix/MSP2OU1/msp/IssuerPublicKey b/msp/testdata/idemix/MSP2OU1/msp/IssuerPublicKey deleted file mode 100644 index cb904d7580f..00000000000 Binary files a/msp/testdata/idemix/MSP2OU1/msp/IssuerPublicKey and /dev/null differ diff --git a/msp/testdata/idemix/MSP2OU1/msp/RevocationPublicKey b/msp/testdata/idemix/MSP2OU1/msp/RevocationPublicKey deleted file mode 100644 index ed47424a3c4..00000000000 --- a/msp/testdata/idemix/MSP2OU1/msp/RevocationPublicKey +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN PUBLIC KEY----- -MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEoc+ntp+JIxCPwJpCHIshpVV5a3LqZzY0 -jd8ILa+1r77ZoZqzEsTUTWvsALmhynC8FJUb3/0usbMM3RWlpEjr+29F0K5aUz2Z -G2O5deGo6eB9y3uncOA/Fo+jy4AwOhF3 ------END PUBLIC KEY----- diff --git a/msp/testdata/idemix/MSP2OU1/user/SignerConfig b/msp/testdata/idemix/MSP2OU1/user/SignerConfig deleted file mode 100644 index 90d9578675d..00000000000 Binary files a/msp/testdata/idemix/MSP2OU1/user/SignerConfig and /dev/null differ diff --git a/vendor/github.com/IBM/idemix/LICENSE b/vendor/github.com/IBM/idemix/LICENSE new file mode 100644 index 00000000000..261eeb9e9f8 --- /dev/null +++ b/vendor/github.com/IBM/idemix/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/vendor/github.com/IBM/idemix/Makefile b/vendor/github.com/IBM/idemix/Makefile new file mode 100644 index 00000000000..afc6b75203c --- /dev/null +++ b/vendor/github.com/IBM/idemix/Makefile @@ -0,0 +1,20 @@ +.PHONY: all +all: checks unit-tests unit-tests-race + +.PHONY: checks +checks: check-deps + @test -z $(shell gofmt -l -s $(shell go list -f '{{.Dir}}' ./... | grep -v mpc) | tee /dev/stderr) || (echo "Fix formatting issues"; exit 1) + @go vet -all $(shell go list -f '{{.Dir}}' ./... | grep -v mpc) + find . -name '*.go' | xargs addlicense -check || (echo "Missing license headers"; exit 1) + +.PHONY: unit-tests +unit-tests: + @go test -timeout 480s -cover $(shell go list ./...) + +.PHONY: unit-tests-race +unit-tests-race: + @export GORACE=history_size=7; go test -timeout 960s -race -cover $(shell go list ./...) + +.PHONY: check-deps +check-deps: + @go get -u github.com/google/addlicense diff --git a/vendor/github.com/IBM/idemix/README.md b/vendor/github.com/IBM/idemix/README.md new file mode 100644 index 00000000000..c8f888495d4 --- /dev/null +++ b/vendor/github.com/IBM/idemix/README.md @@ -0,0 +1,256 @@ +# Idemix +[![License](https://img.shields.io/badge/license-Apache%202-blue)](LICENSE) +[![Go Report Card](https://goreportcard.com/badge/github.com/IBM/idemix)](https://goreportcard.com/badge/github.com/IBM/idemix) +[![Go](https://github.com/IBM/idemix/actions/workflows/go.yml/badge.svg)](https://github.com/IBM/idemix/actions/workflows/go.yml/badge.svg) + +This project is a Go implementation of an anonymous identity stack for blockchain systems. + +- [Protocol](#protocol) + * [Preliminaries](#preliminaries) + * [Generation of issue certificate](#generation-of-issue-certificate) + * [Generation of client certificate](#generation-of-client-certificate) + * [Generation of signature](#generation-of-signature) + * [Verification of a signature](#verification-of-a-signature) + * [Generation of a pseudonymous signature](#generation-of-a-pseudonymous-signature) + * [Verification of a pseudonymous signature](#verification-of-a-pseudonymous-signature) + * [Extensions](#extensions) + + [Adding a pseudonym as a function of the Enrollment ID (eid)](#adding-a-pseudonym-as-a-function-of-the-enrollment-id--eid-) + - [Signature generation](#signature-generation) + - [Signature verification](#signature-verification) + - [Auditing NymEid](#auditing-nymeid) + +# Protocol + +Here we describe the cryptographic protocol that is implemented. + +## Preliminaries + +TBD (Group etc.) + +## Generation of issue certificate + +The input for this step are the 4 attributes that are certified, namely `OU`, `Role`, `EnrollmentID` and `RevocationHandle` (call them ). + +Given these attributes, the CA samples the issuer secret key at random + + + +And then computes + + + +For each attribute the CA picks a random element and generates a base for that attribute + + + +The CA randomly selects and computes bases + + + + + + +Then the CA randomly selects and computes + + + + +It also generates + + + + +The issuer public key is + + + +where is a hash of all fields of the public key. + +and the issuer private key is is + + + +## Generation of client certificate + +Given a client with attributes , the client samples the secret key + + + +and random elements + + + + +and then computes + + + + + + +The credential request sent to the CA is . + +The CA computes + + + +and checks whether + + + +If so, the CA picks random elements + + + + +and computes + + + + + +The CA returns the credential to the user. + +The user verifies the credential by computing + + + +If the user aborts. Otherwise it verifies the signature by checking whether the following equality + + + +holds. If so, the user accepts private key and the user public key is . + +## Generation of signature + + +To sign message and simultaneously disclose a subset of attributes (tracked by the bits such that if the bit is one the corresponding attribute is disclosed; notationally, ), the client chooses a new random element and generates a new pseudonym + + + +And then generates the new signature as follows + + + + + + + + + + +The client then generates random elements + + + + + + + + + + + + +and then generates + + + + + + + + + + + + +and for each attribute that requires disclosure, it generates + + + +The signature is . + +## Verification of a signature + +Upon receipt of a signature is over message the verifier checks whether the following equality holds + + + +If so, it recomputes + + + + + +and accepts the signature if + + + +This verification also verifies the disclosed subset of attributes. + +## Generation of a pseudonymous signature + +Differently from a standard signature, a pseudonymous signature does not prove that the pseudonym possesses a user certificate signed by a CA. It only proves that the pseudonym signed message . The signature is generated starting from the pseudonym (as generated in the section above) together with secret key and randomness as follows: at first it picks random elements + + + + + +Then it generates + + + + + + +The signature is . + +## Verification of a pseudonymous signature + +Upon receipt of a pseudonymous signature over message the verifier recomputes + + + +and accepts the signature if + + + +## Extensions + +### Adding a pseudonym as a function of the Enrollment ID (eid) + +The enrollment id is one of the cerified attributes ( with value ). This extension introduces a pseudonym which is a function of the enrollment ID, together with a proof that it was correclty generated. + +#### Signature generation + +The pseudonym is computed by sampling + + + + +and by generating the pseudonym + + + +Signature generation is similar to the scheme [above](#sign); in particular, the term is the same used by the original sign algorithm. The extensions include: + + * the client computes an additional value ; + + * the client includes in the challenge computation: (if is included, it should always be set to 0 otherwise the value of the enrollment ID would be revealed); + + * the client computes an additional proof ; + + * The signature includes the additional proof and pseudonym . + +#### Signature verification + +Signature verification is the same as above except that + + * verifier computes ; + + * verifier checks if . + +#### Auditing NymEid +To Audit NymEid the client reveals pair and the auditor checks if . + diff --git a/bccsp/idemix/bccsp.go b/vendor/github.com/IBM/idemix/bccsp/bccsp.go similarity index 62% rename from bccsp/idemix/bccsp.go rename to vendor/github.com/IBM/idemix/bccsp/bccsp.go index 478028faf5f..5a0ac4e277c 100644 --- a/bccsp/idemix/bccsp.go +++ b/vendor/github.com/IBM/idemix/bccsp/bccsp.go @@ -8,76 +8,93 @@ package idemix import ( "reflect" - "github.com/hyperledger/fabric/bccsp/idemix/bridge" - - "github.com/hyperledger/fabric/bccsp/idemix/handlers" - - "github.com/hyperledger/fabric/bccsp" - "github.com/hyperledger/fabric/bccsp/sw" + bccsp "github.com/IBM/idemix/bccsp/schemes" + "github.com/IBM/idemix/bccsp/schemes/dlog/bridge" + idemix "github.com/IBM/idemix/bccsp/schemes/dlog/crypto" + "github.com/IBM/idemix/bccsp/schemes/dlog/handlers" + math "github.com/IBM/mathlib" "github.com/pkg/errors" ) type csp struct { - *sw.CSP + *CSP } -func New(keyStore bccsp.KeyStore) (*csp, error) { - base, err := sw.New(keyStore) +func New(keyStore bccsp.KeyStore, curve *math.Curve, translator idemix.Translator, exportable bool) (*csp, error) { + base, err := NewImpl(keyStore) if err != nil { return nil, errors.Wrap(err, "failed instantiating base bccsp") } csp := &csp{CSP: base} + idmx := &idemix.Idemix{ + Curve: curve, + Translator: translator, + } + // key generators - base.AddWrapper(reflect.TypeOf(&bccsp.IdemixIssuerKeyGenOpts{}), &handlers.IssuerKeyGen{Issuer: &bridge.Issuer{NewRand: bridge.NewRandOrPanic}}) - base.AddWrapper(reflect.TypeOf(&bccsp.IdemixUserSecretKeyGenOpts{}), &handlers.UserKeyGen{User: &bridge.User{NewRand: bridge.NewRandOrPanic}}) - base.AddWrapper(reflect.TypeOf(&bccsp.IdemixRevocationKeyGenOpts{}), &handlers.RevocationKeyGen{Revocation: &bridge.Revocation{}}) + base.AddWrapper(reflect.TypeOf(&bccsp.IdemixIssuerKeyGenOpts{}), &handlers.IssuerKeyGen{Exportable: exportable, Issuer: &bridge.Issuer{Idemix: idmx, Translator: translator}}) + base.AddWrapper(reflect.TypeOf(&bccsp.IdemixUserSecretKeyGenOpts{}), &handlers.UserKeyGen{Exportable: exportable, User: &bridge.User{Idemix: idmx, Translator: translator}}) + base.AddWrapper(reflect.TypeOf(&bccsp.IdemixRevocationKeyGenOpts{}), &handlers.RevocationKeyGen{Exportable: exportable, Revocation: &bridge.Revocation{Idemix: idmx, Translator: translator}}) // key derivers - base.AddWrapper(reflect.TypeOf(handlers.NewUserSecretKey(nil, false)), &handlers.NymKeyDerivation{ - User: &bridge.User{NewRand: bridge.NewRandOrPanic}, + base.AddWrapper(reflect.TypeOf(handlers.NewUserSecretKey(nil, true)), &handlers.NymKeyDerivation{ + Exportable: exportable, + User: &bridge.User{Idemix: idmx, Translator: translator}, + Translator: translator, }) // signers - base.AddWrapper(reflect.TypeOf(handlers.NewUserSecretKey(nil, false)), &userSecreKeySignerMultiplexer{ - signer: &handlers.Signer{SignatureScheme: &bridge.SignatureScheme{NewRand: bridge.NewRandOrPanic}}, - nymSigner: &handlers.NymSigner{NymSignatureScheme: &bridge.NymSignatureScheme{NewRand: bridge.NewRandOrPanic}}, - credentialRequestSigner: &handlers.CredentialRequestSigner{CredRequest: &bridge.CredRequest{NewRand: bridge.NewRandOrPanic}}, + base.AddWrapper(reflect.TypeOf(handlers.NewUserSecretKey(nil, true)), &userSecreKeySignerMultiplexer{ + signer: &handlers.Signer{SignatureScheme: &bridge.SignatureScheme{Idemix: idmx, Translator: translator}}, + nymSigner: &handlers.NymSigner{NymSignatureScheme: &bridge.NymSignatureScheme{Idemix: idmx, Translator: translator}}, + credentialRequestSigner: &handlers.CredentialRequestSigner{CredRequest: &bridge.CredRequest{Idemix: idmx, Translator: translator}}, }) - base.AddWrapper(reflect.TypeOf(handlers.NewIssuerSecretKey(nil, false)), &handlers.CredentialSigner{ - Credential: &bridge.Credential{NewRand: bridge.NewRandOrPanic}, + base.AddWrapper(reflect.TypeOf(handlers.NewIssuerSecretKey(nil, true)), &handlers.CredentialSigner{ + Credential: &bridge.Credential{Idemix: idmx, Translator: translator}, }) - base.AddWrapper(reflect.TypeOf(handlers.NewRevocationSecretKey(nil, false)), &handlers.CriSigner{ - Revocation: &bridge.Revocation{}, + base.AddWrapper(reflect.TypeOf(handlers.NewRevocationSecretKey(nil, true)), &handlers.CriSigner{ + Revocation: &bridge.Revocation{Idemix: idmx, Translator: translator}, }) // verifiers base.AddWrapper(reflect.TypeOf(handlers.NewIssuerPublicKey(nil)), &issuerPublicKeyVerifierMultiplexer{ - verifier: &handlers.Verifier{SignatureScheme: &bridge.SignatureScheme{NewRand: bridge.NewRandOrPanic}}, - credentialRequestVerifier: &handlers.CredentialRequestVerifier{CredRequest: &bridge.CredRequest{NewRand: bridge.NewRandOrPanic}}, + verifier: &handlers.Verifier{SignatureScheme: &bridge.SignatureScheme{Idemix: idmx, Translator: translator}}, + credentialRequestVerifier: &handlers.CredentialRequestVerifier{CredRequest: &bridge.CredRequest{Idemix: idmx, Translator: translator}}, }) - base.AddWrapper(reflect.TypeOf(handlers.NewNymPublicKey(nil)), &handlers.NymVerifier{ - NymSignatureScheme: &bridge.NymSignatureScheme{NewRand: bridge.NewRandOrPanic}, + base.AddWrapper(reflect.TypeOf(handlers.NewNymPublicKey(nil, translator)), &handlers.NymVerifier{ + NymSignatureScheme: &bridge.NymSignatureScheme{Idemix: idmx, Translator: translator}, }) - base.AddWrapper(reflect.TypeOf(handlers.NewUserSecretKey(nil, false)), &handlers.CredentialVerifier{ - Credential: &bridge.Credential{NewRand: bridge.NewRandOrPanic}, + base.AddWrapper(reflect.TypeOf(handlers.NewUserSecretKey(nil, true)), &handlers.CredentialVerifier{ + Credential: &bridge.Credential{Idemix: idmx, Translator: translator}, }) base.AddWrapper(reflect.TypeOf(handlers.NewRevocationPublicKey(nil)), &handlers.CriVerifier{ - Revocation: &bridge.Revocation{}, + Revocation: &bridge.Revocation{Idemix: idmx, Translator: translator}, }) // importers base.AddWrapper(reflect.TypeOf(&bccsp.IdemixUserSecretKeyImportOpts{}), &handlers.UserKeyImporter{ - User: &bridge.User{}, + User: &bridge.User{Idemix: idmx, Translator: translator}, }) base.AddWrapper(reflect.TypeOf(&bccsp.IdemixIssuerPublicKeyImportOpts{}), &handlers.IssuerPublicKeyImporter{ - Issuer: &bridge.Issuer{}, + Issuer: &bridge.Issuer{Idemix: idmx, Translator: translator}, + }) + base.AddWrapper(reflect.TypeOf(&bccsp.IdemixIssuerKeyImportOpts{}), &handlers.IssuerKeyImporter{ + Issuer: &bridge.Issuer{Idemix: idmx, Translator: translator}, }) base.AddWrapper(reflect.TypeOf(&bccsp.IdemixNymPublicKeyImportOpts{}), &handlers.NymPublicKeyImporter{ - User: &bridge.User{}, + User: &bridge.User{Idemix: idmx, Translator: translator}, + Translator: translator, + }) + base.AddWrapper(reflect.TypeOf(&bccsp.IdemixNymKeyImportOpts{}), &handlers.NymKeyImporter{ + User: &bridge.User{Idemix: idmx, Translator: translator}, + Translator: translator, }) base.AddWrapper(reflect.TypeOf(&bccsp.IdemixRevocationPublicKeyImportOpts{}), &handlers.RevocationPublicKeyImporter{}) + base.AddWrapper(reflect.TypeOf(&bccsp.IdemixRevocationKeyImportOpts{}), &handlers.RevocationKeyImporter{ + Revocation: &bridge.Revocation{Idemix: idmx, Translator: translator}, + }) return csp, nil } @@ -161,6 +178,8 @@ type issuerPublicKeyVerifierMultiplexer struct { func (v *issuerPublicKeyVerifierMultiplexer) Verify(k bccsp.Key, signature, digest []byte, opts bccsp.SignerOpts) (valid bool, err error) { switch opts.(type) { + case *bccsp.EidNymAuditOpts: + return v.verifier.AuditNymEid(k, signature, digest, opts) case *bccsp.IdemixSignerOpts: return v.verifier.Verify(k, signature, digest, opts) case *bccsp.IdemixCredentialRequestSignerOpts: diff --git a/vendor/github.com/IBM/idemix/bccsp/impl.go b/vendor/github.com/IBM/idemix/bccsp/impl.go new file mode 100644 index 00000000000..65cd225e2dd --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/impl.go @@ -0,0 +1,411 @@ +/* +Copyright IBM Corp. 2016 All Rights Reserved. + +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. +*/ +package idemix + +import ( + "hash" + "reflect" + + bccsp "github.com/IBM/idemix/bccsp/schemes" + "github.com/IBM/idemix/common/flogging" + "github.com/pkg/errors" +) + +var ( + logger = flogging.MustGetLogger("bccsp_idemix") +) + +// KeyGenerator is a BCCSP-like interface that provides key generation algorithms +type KeyGenerator interface { + + // KeyGen generates a key using opts. + KeyGen(opts bccsp.KeyGenOpts) (k bccsp.Key, err error) +} + +// KeyDeriver is a BCCSP-like interface that provides key derivation algorithms +type KeyDeriver interface { + + // KeyDeriv derives a key from k using opts. + // The opts argument should be appropriate for the primitive used. + KeyDeriv(k bccsp.Key, opts bccsp.KeyDerivOpts) (dk bccsp.Key, err error) +} + +// KeyImporter is a BCCSP-like interface that provides key import algorithms +type KeyImporter interface { + + // KeyImport imports a key from its raw representation using opts. + // The opts argument should be appropriate for the primitive used. + KeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.Key, err error) +} + +// Encryptor is a BCCSP-like interface that provides encryption algorithms +type Encryptor interface { + + // Encrypt encrypts plaintext using key k. + // The opts argument should be appropriate for the algorithm used. + Encrypt(k bccsp.Key, plaintext []byte, opts bccsp.EncrypterOpts) (ciphertext []byte, err error) +} + +// Decryptor is a BCCSP-like interface that provides decryption algorithms +type Decryptor interface { + + // Decrypt decrypts ciphertext using key k. + // The opts argument should be appropriate for the algorithm used. + Decrypt(k bccsp.Key, ciphertext []byte, opts bccsp.DecrypterOpts) (plaintext []byte, err error) +} + +// Signer is a BCCSP-like interface that provides signing algorithms +type Signer interface { + + // Sign signs digest using key k. + // The opts argument should be appropriate for the algorithm used. + // + // Note that when a signature of a hash of a larger message is needed, + // the caller is responsible for hashing the larger message and passing + // the hash (as digest). + Sign(k bccsp.Key, digest []byte, opts bccsp.SignerOpts) (signature []byte, err error) +} + +// Verifier is a BCCSP-like interface that provides verifying algorithms +type Verifier interface { + + // Verify verifies signature against key k and digest + // The opts argument should be appropriate for the algorithm used. + Verify(k bccsp.Key, signature, digest []byte, opts bccsp.SignerOpts) (valid bool, err error) +} + +// Hasher is a BCCSP-like interface that provides hash algorithms +type Hasher interface { + + // Hash hashes messages msg using options opts. + // If opts is nil, the default hash function will be used. + Hash(msg []byte, opts bccsp.HashOpts) (hash []byte, err error) + + // GetHash returns and instance of hash.Hash using options opts. + // If opts is nil, the default hash function will be returned. + GetHash(opts bccsp.HashOpts) (h hash.Hash, err error) +} + +// CSP provides a generic implementation of the BCCSP interface based +// on wrappers. It can be customized by providing implementations for the +// following algorithm-based wrappers: KeyGenerator, KeyDeriver, KeyImporter, +// Encryptor, Decryptor, Signer, Verifier, Hasher. Each wrapper is bound to a +// goland type representing either an option or a key. +type CSP struct { + ks bccsp.KeyStore + + KeyGenerators map[reflect.Type]KeyGenerator + KeyDerivers map[reflect.Type]KeyDeriver + KeyImporters map[reflect.Type]KeyImporter + Encryptors map[reflect.Type]Encryptor + Decryptors map[reflect.Type]Decryptor + Signers map[reflect.Type]Signer + Verifiers map[reflect.Type]Verifier + Hashers map[reflect.Type]Hasher +} + +func NewImpl(keyStore bccsp.KeyStore) (*CSP, error) { + if keyStore == nil { + return nil, errors.Errorf("Invalid bccsp.KeyStore instance. It must be different from nil.") + } + + encryptors := make(map[reflect.Type]Encryptor) + decryptors := make(map[reflect.Type]Decryptor) + signers := make(map[reflect.Type]Signer) + verifiers := make(map[reflect.Type]Verifier) + hashers := make(map[reflect.Type]Hasher) + keyGenerators := make(map[reflect.Type]KeyGenerator) + keyDerivers := make(map[reflect.Type]KeyDeriver) + keyImporters := make(map[reflect.Type]KeyImporter) + + csp := &CSP{keyStore, + keyGenerators, keyDerivers, keyImporters, encryptors, + decryptors, signers, verifiers, hashers} + + return csp, nil +} + +// KeyGen generates a key using opts. +func (csp *CSP) KeyGen(opts bccsp.KeyGenOpts) (k bccsp.Key, err error) { + // Validate arguments + if opts == nil { + return nil, errors.New("Invalid Opts parameter. It must not be nil.") + } + + keyGenerator, found := csp.KeyGenerators[reflect.TypeOf(opts)] + if !found { + return nil, errors.Errorf("Unsupported 'KeyGenOpts' provided [%v]", opts) + } + + k, err = keyGenerator.KeyGen(opts) + if err != nil { + return nil, errors.Wrapf(err, "Failed generating key with opts [%v]", opts) + } + + // If the key is not Ephemeral, store it. + if !opts.Ephemeral() { + // Store the key + err = csp.ks.StoreKey(k) + if err != nil { + return nil, errors.Wrapf(err, "Failed storing key [%s]", opts.Algorithm()) + } + } + + return k, nil +} + +// KeyDeriv derives a key from k using opts. +// The opts argument should be appropriate for the primitive used. +func (csp *CSP) KeyDeriv(k bccsp.Key, opts bccsp.KeyDerivOpts) (dk bccsp.Key, err error) { + // Validate arguments + if k == nil { + return nil, errors.New("Invalid Key. It must not be nil.") + } + if opts == nil { + return nil, errors.New("Invalid opts. It must not be nil.") + } + + keyDeriver, found := csp.KeyDerivers[reflect.TypeOf(k)] + if !found { + return nil, errors.Errorf("Unsupported 'Key' provided [%v]", k) + } + + k, err = keyDeriver.KeyDeriv(k, opts) + if err != nil { + return nil, errors.Wrapf(err, "Failed deriving key with opts [%v]", opts) + } + + // If the key is not Ephemeral, store it. + if !opts.Ephemeral() { + // Store the key + err = csp.ks.StoreKey(k) + if err != nil { + return nil, errors.Wrapf(err, "Failed storing key [%s]", opts.Algorithm()) + } + } + + return k, nil +} + +// KeyImport imports a key from its raw representation using opts. +// The opts argument should be appropriate for the primitive used. +func (csp *CSP) KeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.Key, err error) { + // Validate arguments + if raw == nil { + return nil, errors.New("Invalid raw. It must not be nil.") + } + if opts == nil { + return nil, errors.New("Invalid opts. It must not be nil.") + } + + keyImporter, found := csp.KeyImporters[reflect.TypeOf(opts)] + if !found { + return nil, errors.Errorf("Unsupported 'KeyImportOpts' provided [%v]", opts) + } + + k, err = keyImporter.KeyImport(raw, opts) + if err != nil { + return nil, errors.Wrapf(err, "Failed importing key with opts [%v]", opts) + } + + // If the key is not Ephemeral, store it. + if !opts.Ephemeral() { + // Store the key + err = csp.ks.StoreKey(k) + if err != nil { + return nil, errors.Wrapf(err, "Failed storing imported key with opts [%v]", opts) + } + } + + return +} + +// GetKey returns the key this CSP associates to +// the Subject Key Identifier ski. +func (csp *CSP) GetKey(ski []byte) (k bccsp.Key, err error) { + k, err = csp.ks.GetKey(ski) + if err != nil { + return nil, errors.Wrapf(err, "Failed getting key for SKI [%v]", ski) + } + + return +} + +// Hash hashes messages msg using options opts. +func (csp *CSP) Hash(msg []byte, opts bccsp.HashOpts) (digest []byte, err error) { + // Validate arguments + if opts == nil { + return nil, errors.New("Invalid opts. It must not be nil.") + } + + hasher, found := csp.Hashers[reflect.TypeOf(opts)] + if !found { + return nil, errors.Errorf("Unsupported 'HashOpt' provided [%v]", opts) + } + + digest, err = hasher.Hash(msg, opts) + if err != nil { + return nil, errors.Wrapf(err, "Failed hashing with opts [%v]", opts) + } + + return +} + +// GetHash returns and instance of hash.Hash using options opts. +// If opts is nil then the default hash function is returned. +func (csp *CSP) GetHash(opts bccsp.HashOpts) (h hash.Hash, err error) { + // Validate arguments + if opts == nil { + return nil, errors.New("Invalid opts. It must not be nil.") + } + + hasher, found := csp.Hashers[reflect.TypeOf(opts)] + if !found { + return nil, errors.Errorf("Unsupported 'HashOpt' provided [%v]", opts) + } + + h, err = hasher.GetHash(opts) + if err != nil { + return nil, errors.Wrapf(err, "Failed getting hash function with opts [%v]", opts) + } + + return +} + +// Sign signs digest using key k. +// The opts argument should be appropriate for the primitive used. +// +// Note that when a signature of a hash of a larger message is needed, +// the caller is responsible for hashing the larger message and passing +// the hash (as digest). +func (csp *CSP) Sign(k bccsp.Key, digest []byte, opts bccsp.SignerOpts) (signature []byte, err error) { + // Validate arguments + if k == nil { + return nil, errors.New("Invalid Key. It must not be nil.") + } + if len(digest) == 0 { + return nil, errors.New("Invalid digest. Cannot be empty.") + } + + keyType := reflect.TypeOf(k) + signer, found := csp.Signers[keyType] + if !found { + return nil, errors.Errorf("Unsupported 'SignKey' provided [%s]", keyType) + } + + signature, err = signer.Sign(k, digest, opts) + if err != nil { + return nil, errors.Wrapf(err, "Failed signing with opts [%v]", opts) + } + + return +} + +// Verify verifies signature against key k and digest +func (csp *CSP) Verify(k bccsp.Key, signature, digest []byte, opts bccsp.SignerOpts) (valid bool, err error) { + // Validate arguments + if k == nil { + return false, errors.New("Invalid Key. It must not be nil.") + } + if len(signature) == 0 { + return false, errors.New("Invalid signature. Cannot be empty.") + } + if len(digest) == 0 { + return false, errors.New("Invalid digest. Cannot be empty.") + } + + verifier, found := csp.Verifiers[reflect.TypeOf(k)] + if !found { + return false, errors.Errorf("Unsupported 'VerifyKey' provided [%v]", k) + } + + valid, err = verifier.Verify(k, signature, digest, opts) + if err != nil { + return false, errors.Wrapf(err, "Failed verifing with opts [%v]", opts) + } + + return +} + +// Encrypt encrypts plaintext using key k. +// The opts argument should be appropriate for the primitive used. +func (csp *CSP) Encrypt(k bccsp.Key, plaintext []byte, opts bccsp.EncrypterOpts) ([]byte, error) { + // Validate arguments + if k == nil { + return nil, errors.New("Invalid Key. It must not be nil.") + } + + encryptor, found := csp.Encryptors[reflect.TypeOf(k)] + if !found { + return nil, errors.Errorf("Unsupported 'EncryptKey' provided [%v]", k) + } + + return encryptor.Encrypt(k, plaintext, opts) +} + +// Decrypt decrypts ciphertext using key k. +// The opts argument should be appropriate for the primitive used. +func (csp *CSP) Decrypt(k bccsp.Key, ciphertext []byte, opts bccsp.DecrypterOpts) (plaintext []byte, err error) { + // Validate arguments + if k == nil { + return nil, errors.New("Invalid Key. It must not be nil.") + } + + decryptor, found := csp.Decryptors[reflect.TypeOf(k)] + if !found { + return nil, errors.Errorf("Unsupported 'DecryptKey' provided [%v]", k) + } + + plaintext, err = decryptor.Decrypt(k, ciphertext, opts) + if err != nil { + return nil, errors.Wrapf(err, "Failed decrypting with opts [%v]", opts) + } + + return +} + +// AddWrapper binds the passed type to the passed wrapper. +// Notice that that wrapper must be an instance of one of the following interfaces: +// KeyGenerator, KeyDeriver, KeyImporter, Encryptor, Decryptor, Signer, Verifier, Hasher. +func (csp *CSP) AddWrapper(t reflect.Type, w interface{}) error { + if t == nil { + return errors.Errorf("type cannot be nil") + } + if w == nil { + return errors.Errorf("wrapper cannot be nil") + } + switch dt := w.(type) { + case KeyGenerator: + csp.KeyGenerators[t] = dt + case KeyImporter: + csp.KeyImporters[t] = dt + case KeyDeriver: + csp.KeyDerivers[t] = dt + case Encryptor: + csp.Encryptors[t] = dt + case Decryptor: + csp.Decryptors[t] = dt + case Signer: + csp.Signers[t] = dt + case Verifier: + csp.Verifiers[t] = dt + case Hasher: + csp.Hashers[t] = dt + default: + return errors.Errorf("wrapper type not valid, must be on of: KeyGenerator, KeyDeriver, KeyImporter, Encryptor, Decryptor, Signer, Verifier, Hasher") + } + return nil +} diff --git a/vendor/github.com/IBM/idemix/bccsp/keystore/dummy.go b/vendor/github.com/IBM/idemix/bccsp/keystore/dummy.go new file mode 100644 index 00000000000..ec7d944de8a --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/keystore/dummy.go @@ -0,0 +1,34 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package keystore + +import ( + "errors" + + bccsp "github.com/IBM/idemix/bccsp/schemes" +) + +// Dummy is a read-only KeyStore that neither loads nor stores keys. +type Dummy struct { +} + +// ReadOnly returns true if this KeyStore is read only, false otherwise. +// If ReadOnly is true then StoreKey will fail. +func (ks *Dummy) ReadOnly() bool { + return true +} + +// GetKey returns a key object whose SKI is the one passed. +func (ks *Dummy) GetKey(ski []byte) (bccsp.Key, error) { + return nil, errors.New("key not found. This is a dummy KeyStore") +} + +// StoreKey stores the key k in this KeyStore. +// If this KeyStore is read only then the method will fail. +func (ks *Dummy) StoreKey(k bccsp.Key) error { + return errors.New("cannot store key. This is a dummy read-only KeyStore") +} diff --git a/vendor/github.com/IBM/idemix/bccsp/keystore/kvsbased.go b/vendor/github.com/IBM/idemix/bccsp/keystore/kvsbased.go new file mode 100644 index 00000000000..20e7593290c --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/keystore/kvsbased.go @@ -0,0 +1,121 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package keystore + +import ( + "encoding/hex" + + bccsp "github.com/IBM/idemix/bccsp/schemes" + idemix "github.com/IBM/idemix/bccsp/schemes/dlog/crypto" + "github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl" + "github.com/IBM/idemix/bccsp/schemes/dlog/handlers" + math "github.com/IBM/mathlib" + "github.com/pkg/errors" +) + +type KVS interface { + Put(id string, state interface{}) error + Get(id string, state interface{}) error +} + +type NymSecretKey struct { + Ski []byte + Sk []byte + Pk *amcl.ECP + Exportable bool +} + +type UserSecretKey struct { + Sk []byte + Exportable bool +} + +type entry struct { + NymSecretKey *NymSecretKey `json:",omitempty"` + UserSecretKey *UserSecretKey `json:",omitempty"` +} + +// KVSStore is a read-only KeyStore that neither loads nor stores keys. +type KVSStore struct { + KVS + Translator idemix.Translator + Curve *math.Curve +} + +// ReadOnly returns true if this KeyStore is read only, false otherwise. +// If ReadOnly is true then StoreKey will fail. +func (ks *KVSStore) ReadOnly() bool { + return false +} + +// GetKey returns a key object whose SKI is the one passed. +func (ks *KVSStore) GetKey(ski []byte) (bccsp.Key, error) { + id := hex.EncodeToString(ski) + + entry := &entry{} + err := ks.KVS.Get(id, entry) + if err != nil { + return nil, errors.Wrapf(err, "could not get key [%s] from kvs", id) + } + + switch { + case entry.NymSecretKey != nil: + pk, err := ks.Translator.G1FromProto(entry.NymSecretKey.Pk) + if err != nil { + return nil, err + } + + return &handlers.NymSecretKey{ + Exportable: entry.NymSecretKey.Exportable, + Sk: ks.Curve.NewZrFromBytes(entry.NymSecretKey.Sk), + Ski: entry.NymSecretKey.Ski, + Pk: pk, + Translator: ks.Translator, + }, nil + case entry.UserSecretKey != nil: + return &handlers.UserSecretKey{ + Exportable: entry.UserSecretKey.Exportable, + Sk: ks.Curve.NewZrFromBytes(entry.UserSecretKey.Sk), + }, nil + default: + return nil, errors.Errorf("key not found for [%s]", id) + } +} + +// StoreKey stores the key k in this KeyStore. +// If this KeyStore is read only then the method will fail. +func (ks *KVSStore) StoreKey(k bccsp.Key) error { + entry := &entry{} + var id string + + switch key := k.(type) { + case *handlers.NymSecretKey: + entry.NymSecretKey = &NymSecretKey{ + Ski: key.Ski, + Sk: key.Sk.Bytes(), + Pk: ks.Translator.G1ToProto(key.Pk), + Exportable: key.Exportable, + } + + pk, err := k.PublicKey() + if err != nil { + return errors.Errorf("could not get public version for key [%s]", k.SKI()) + } + + id = hex.EncodeToString(pk.SKI()) + case *handlers.UserSecretKey: + entry.UserSecretKey = &UserSecretKey{ + Sk: key.Sk.Bytes(), + Exportable: key.Exportable, + } + id = hex.EncodeToString(k.SKI()) + default: + return errors.Errorf("unknown type [%T] for the supplied key", key) + } + + return ks.KVS.Put(id, entry) +} diff --git a/vendor/github.com/IBM/idemix/bccsp/schemes/crypto.go b/vendor/github.com/IBM/idemix/bccsp/schemes/crypto.go new file mode 100644 index 00000000000..e4cfa52a31a --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/crypto.go @@ -0,0 +1,151 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +package idemix + +import ( + "crypto" + "hash" +) + +// KeyStore represents a storage system for cryptographic keys. +// It allows to store and retrieve bccsp.Key objects. +// The KeyStore can be read only, in that case StoreKey will return +// an error. +type KeyStore interface { + + // ReadOnly returns true if this KeyStore is read only, false otherwise. + // If ReadOnly is true then StoreKey will fail. + ReadOnly() bool + + // GetKey returns a key object whose SKI is the one passed. + GetKey(ski []byte) (k Key, err error) + + // StoreKey stores the key k in this KeyStore. + // If this KeyStore is read only then the method will fail. + StoreKey(k Key) (err error) +} + +// Key represents a cryptographic key +type Key interface { + + // Bytes converts this key to its byte representation, + // if this operation is allowed. + Bytes() ([]byte, error) + + // SKI returns the subject key identifier of this key. + SKI() []byte + + // Symmetric returns true if this key is a symmetric key, + // false is this key is asymmetric + Symmetric() bool + + // Private returns true if this key is a private key, + // false otherwise. + Private() bool + + // PublicKey returns the corresponding public key part of an asymmetric public/private key pair. + // This method returns an error in symmetric key schemes. + PublicKey() (Key, error) +} + +// KeyGenOpts contains options for key-generation with a CSP. +type KeyGenOpts interface { + + // Algorithm returns the key generation algorithm identifier (to be used). + Algorithm() string + + // Ephemeral returns true if the key to generate has to be ephemeral, + // false otherwise. + Ephemeral() bool +} + +// KeyDerivOpts contains options for key-derivation with a CSP. +type KeyDerivOpts interface { + + // Algorithm returns the key derivation algorithm identifier (to be used). + Algorithm() string + + // Ephemeral returns true if the key to derived has to be ephemeral, + // false otherwise. + Ephemeral() bool +} + +// KeyImportOpts contains options for importing the raw material of a key with a CSP. +type KeyImportOpts interface { + + // Algorithm returns the key importation algorithm identifier (to be used). + Algorithm() string + + // Ephemeral returns true if the key generated has to be ephemeral, + // false otherwise. + Ephemeral() bool +} + +// HashOpts contains options for hashing with a CSP. +type HashOpts interface { + + // Algorithm returns the hash algorithm identifier (to be used). + Algorithm() string +} + +// SignerOpts contains options for signing with a CSP. +type SignerOpts interface { + crypto.SignerOpts +} + +// EncrypterOpts contains options for encrypting with a CSP. +type EncrypterOpts interface{} + +// DecrypterOpts contains options for decrypting with a CSP. +type DecrypterOpts interface{} + +// BCCSP is the blockchain cryptographic service provider that offers +// the implementation of cryptographic standards and algorithms. +type BCCSP interface { + + // KeyGen generates a key using opts. + KeyGen(opts KeyGenOpts) (k Key, err error) + + // KeyDeriv derives a key from k using opts. + // The opts argument should be appropriate for the primitive used. + KeyDeriv(k Key, opts KeyDerivOpts) (dk Key, err error) + + // KeyImport imports a key from its raw representation using opts. + // The opts argument should be appropriate for the primitive used. + KeyImport(raw interface{}, opts KeyImportOpts) (k Key, err error) + + // GetKey returns the key this CSP associates to + // the Subject Key Identifier ski. + GetKey(ski []byte) (k Key, err error) + + // Hash hashes messages msg using options opts. + // If opts is nil, the default hash function will be used. + Hash(msg []byte, opts HashOpts) (hash []byte, err error) + + // GetHash returns and instance of hash.Hash using options opts. + // If opts is nil, the default hash function will be returned. + GetHash(opts HashOpts) (h hash.Hash, err error) + + // Sign signs digest using key k. + // The opts argument should be appropriate for the algorithm used. + // + // Note that when a signature of a hash of a larger message is needed, + // the caller is responsible for hashing the larger message and passing + // the hash (as digest). + Sign(k Key, digest []byte, opts SignerOpts) (signature []byte, err error) + + // Verify verifies signature against key k and digest + // The opts argument should be appropriate for the algorithm used. + Verify(k Key, signature, digest []byte, opts SignerOpts) (valid bool, err error) + + // Encrypt encrypts plaintext using key k. + // The opts argument should be appropriate for the algorithm used. + Encrypt(k Key, plaintext []byte, opts EncrypterOpts) (ciphertext []byte, err error) + + // Decrypt decrypts ciphertext using key k. + // The opts argument should be appropriate for the algorithm used. + Decrypt(k Key, ciphertext []byte, opts DecrypterOpts) (plaintext []byte, err error) +} diff --git a/bccsp/idemix/bridge/credential.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/credential.go similarity index 67% rename from bccsp/idemix/bridge/credential.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/credential.go index ae5859b4418..38f97eaa6e2 100644 --- a/bccsp/idemix/bridge/credential.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/credential.go @@ -8,12 +8,11 @@ package bridge import ( "bytes" + bccsp "github.com/IBM/idemix/bccsp/schemes" + idemix "github.com/IBM/idemix/bccsp/schemes/dlog/crypto" + "github.com/IBM/idemix/bccsp/schemes/dlog/handlers" + math "github.com/IBM/mathlib" "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-amcl/amcl" - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" - "github.com/hyperledger/fabric/bccsp" - "github.com/hyperledger/fabric/bccsp/idemix/handlers" - cryptolib "github.com/hyperledger/fabric/idemix" "github.com/pkg/errors" ) @@ -21,7 +20,8 @@ import ( // and verify it. Recall that a credential is produced by the Issuer upon a credential request, // and it is verified by the requester. type Credential struct { - NewRand func() *amcl.RAND + Translator idemix.Translator + Idemix *idemix.Idemix } // Sign produces an idemix credential. It takes in input the issuer secret key, @@ -41,25 +41,33 @@ func (c *Credential) Sign(key handlers.IssuerSecretKey, credentialRequest []byte return nil, errors.Errorf("invalid issuer secret key, expected *Big, got [%T]", key) } - cr := &cryptolib.CredRequest{} + cr := &idemix.CredRequest{} err = proto.Unmarshal(credentialRequest, cr) if err != nil { return nil, errors.Wrap(err, "failed unmarshalling credential request") } - attrValues := make([]*FP256BN.BIG, len(attributes)) + attrValues := make([]*math.Zr, len(attributes)) for i := 0; i < len(attributes); i++ { switch attributes[i].Type { case bccsp.IdemixBytesAttribute: - attrValues[i] = cryptolib.HashModOrder(attributes[i].Value.([]byte)) + attrValues[i] = c.Idemix.Curve.HashToZr(attributes[i].Value.([]byte)) case bccsp.IdemixIntAttribute: - attrValues[i] = FP256BN.NewBIGint(attributes[i].Value.(int)) + var value int64 + if v, ok := attributes[i].Value.(int); ok { + value = int64(v) + } else if v, ok := attributes[i].Value.(int64); ok { + value = v + } else { + return nil, errors.Errorf("invalid int type for IdemixIntAttribute attribute") + } + attrValues[i] = c.Idemix.Curve.NewZrFromInt(value) default: return nil, errors.Errorf("attribute type not allowed or supported [%v] at position [%d]", attributes[i].Type, i) } } - cred, err := cryptolib.NewCredential(iisk.SK, cr, attrValues, c.NewRand()) + cred, err := c.Idemix.NewCredential(iisk.SK, cr, attrValues, newRandOrPanic(c.Idemix.Curve), c.Translator) if err != nil { return nil, errors.WithMessage(err, "failed creating new credential") } @@ -71,23 +79,19 @@ func (c *Credential) Sign(key handlers.IssuerSecretKey, credentialRequest []byte // in input the user secret key (sk), the issuer public key (ipk), the serialised credential (credential), // and a list of attributes. The list of attributes is optional, in case it is specified, Verify // checks that the credential carries the specified attributes. -func (*Credential) Verify(sk handlers.Big, ipk handlers.IssuerPublicKey, credential []byte, attributes []bccsp.IdemixAttribute) (err error) { +func (c *Credential) Verify(sk *math.Zr, ipk handlers.IssuerPublicKey, credential []byte, attributes []bccsp.IdemixAttribute) (err error) { defer func() { if r := recover(); r != nil { err = errors.Errorf("failure [%s]", r) } }() - isk, ok := sk.(*Big) - if !ok { - return errors.Errorf("invalid user secret key, expected *Big, got [%T]", sk) - } iipk, ok := ipk.(*IssuerPublicKey) if !ok { return errors.Errorf("invalid issuer public key, expected *IssuerPublicKey, got [%T]", sk) } - cred := &cryptolib.Credential{} + cred := &idemix.Credential{} err = proto.Unmarshal(credential, cred) if err != nil { return err @@ -97,13 +101,22 @@ func (*Credential) Verify(sk handlers.Big, ipk handlers.IssuerPublicKey, credent switch attributes[i].Type { case bccsp.IdemixBytesAttribute: if !bytes.Equal( - cryptolib.BigToBytes(cryptolib.HashModOrder(attributes[i].Value.([]byte))), + c.Idemix.Curve.HashToZr(attributes[i].Value.([]byte)).Bytes(), cred.Attrs[i]) { return errors.Errorf("credential does not contain the correct attribute value at position [%d]", i) } case bccsp.IdemixIntAttribute: + var value int64 + if v, ok := attributes[i].Value.(int); ok { + value = int64(v) + } else if v, ok := attributes[i].Value.(int64); ok { + value = v + } else { + return errors.Errorf("invalid int type for IdemixIntAttribute attribute") + } + if !bytes.Equal( - cryptolib.BigToBytes(FP256BN.NewBIGint(attributes[i].Value.(int))), + c.Idemix.Curve.NewZrFromInt(value).Bytes(), cred.Attrs[i]) { return errors.Errorf("credential does not contain the correct attribute value at position [%d]", i) } @@ -114,5 +127,5 @@ func (*Credential) Verify(sk handlers.Big, ipk handlers.IssuerPublicKey, credent } } - return cred.Ver(isk.E, iipk.PK) + return cred.Ver(sk, iipk.PK, c.Idemix.Curve, c.Translator) } diff --git a/bccsp/idemix/bridge/credrequest.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/credrequest.go similarity index 65% rename from bccsp/idemix/bridge/credrequest.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/credrequest.go index a7e1c638924..a7d8d07804f 100644 --- a/bccsp/idemix/bridge/credrequest.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/credrequest.go @@ -8,10 +8,10 @@ package bridge import ( "bytes" + idemix "github.com/IBM/idemix/bccsp/schemes/dlog/crypto" + "github.com/IBM/idemix/bccsp/schemes/dlog/handlers" + math "github.com/IBM/mathlib" "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-amcl/amcl" - "github.com/hyperledger/fabric/bccsp/idemix/handlers" - cryptolib "github.com/hyperledger/fabric/idemix" "github.com/pkg/errors" ) @@ -19,12 +19,13 @@ import ( // and verify it. Recall that a credential request is produced by a user, // and it is verified by the issuer at credential creation time. type CredRequest struct { - NewRand func() *amcl.RAND + Translator idemix.Translator + Idemix *idemix.Idemix } // Sign produces an idemix credential request. It takes in input a user secret key and // an issuer public key. -func (cr *CredRequest) Sign(sk handlers.Big, ipk handlers.IssuerPublicKey, nonce []byte) (res []byte, err error) { +func (cr *CredRequest) Sign(sk *math.Zr, ipk handlers.IssuerPublicKey, nonce []byte) (res []byte, err error) { defer func() { if r := recover(); r != nil { res = nil @@ -32,39 +33,38 @@ func (cr *CredRequest) Sign(sk handlers.Big, ipk handlers.IssuerPublicKey, nonce } }() - isk, ok := sk.(*Big) - if !ok { - return nil, errors.Errorf("invalid user secret key, expected *Big, got [%T]", sk) - } iipk, ok := ipk.(*IssuerPublicKey) if !ok { return nil, errors.Errorf("invalid issuer public key, expected *IssuerPublicKey, got [%T]", ipk) } - if len(nonce) != cryptolib.FieldBytes { - return nil, errors.Errorf("invalid issuer nonce, expected length %d, got %d", cryptolib.FieldBytes, len(nonce)) + if len(nonce) != cr.Idemix.Curve.FieldBytes { + return nil, errors.Errorf("invalid issuer nonce, expected length %d, got %d", cr.Idemix.Curve.FieldBytes, len(nonce)) } - rng := cr.NewRand() - - credRequest := cryptolib.NewCredRequest( - isk.E, + credRequest, err := cr.Idemix.NewCredRequest( + sk, nonce, iipk.PK, - rng) + newRandOrPanic(cr.Idemix.Curve), + cr.Translator, + ) + if err != nil { + return nil, err + } return proto.Marshal(credRequest) } // Verify checks that the passed credential request is valid with the respect to the passed // issuer public key. -func (*CredRequest) Verify(credentialRequest []byte, ipk handlers.IssuerPublicKey, nonce []byte) (err error) { +func (cr *CredRequest) Verify(credentialRequest []byte, ipk handlers.IssuerPublicKey, nonce []byte) (err error) { defer func() { if r := recover(); r != nil { err = errors.Errorf("failure [%s]", r) } }() - credRequest := &cryptolib.CredRequest{} + credRequest := &idemix.CredRequest{} err = proto.Unmarshal(credentialRequest, credRequest) if err != nil { return err @@ -75,14 +75,14 @@ func (*CredRequest) Verify(credentialRequest []byte, ipk handlers.IssuerPublicKe return errors.Errorf("invalid issuer public key, expected *IssuerPublicKey, got [%T]", ipk) } - err = credRequest.Check(iipk.PK) + err = credRequest.Check(iipk.PK, cr.Idemix.Curve, cr.Translator) if err != nil { return err } // Nonce checks - if len(nonce) != cryptolib.FieldBytes { - return errors.Errorf("invalid issuer nonce, expected length %d, got %d", cryptolib.FieldBytes, len(nonce)) + if len(nonce) != cr.Idemix.Curve.FieldBytes { + return errors.Errorf("invalid issuer nonce, expected length %d, got %d", cr.Idemix.Curve.FieldBytes, len(nonce)) } if !bytes.Equal(nonce, credRequest.IssuerNonce) { return errors.Errorf("invalid nonce, expected [%v], got [%v]", nonce, credRequest.IssuerNonce) diff --git a/bccsp/idemix/bridge/issuer.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/issuer.go similarity index 72% rename from bccsp/idemix/bridge/issuer.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/issuer.go index 3d34b94ca51..1c98a955792 100644 --- a/bccsp/idemix/bridge/issuer.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/issuer.go @@ -8,17 +8,16 @@ package bridge import ( "fmt" + bccsp "github.com/IBM/idemix/bccsp/schemes" + idemix "github.com/IBM/idemix/bccsp/schemes/dlog/crypto" + "github.com/IBM/idemix/bccsp/schemes/dlog/handlers" "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-amcl/amcl" - "github.com/hyperledger/fabric/bccsp" - "github.com/hyperledger/fabric/bccsp/idemix/handlers" - cryptolib "github.com/hyperledger/fabric/idemix" "github.com/pkg/errors" ) // IssuerPublicKey encapsulate an idemix issuer public key. type IssuerPublicKey struct { - PK *cryptolib.IssuerPublicKey + PK *idemix.IssuerPublicKey } func (o *IssuerPublicKey) Bytes() ([]byte, error) { @@ -31,7 +30,7 @@ func (o *IssuerPublicKey) Hash() []byte { // IssuerPublicKey encapsulate an idemix issuer secret key. type IssuerSecretKey struct { - SK *cryptolib.IssuerKey + SK *idemix.IssuerKey } func (o *IssuerSecretKey) Bytes() ([]byte, error) { @@ -44,7 +43,8 @@ func (o *IssuerSecretKey) Public() handlers.IssuerPublicKey { // Issuer encapsulates the idemix algorithms to generate issuer key-pairs type Issuer struct { - NewRand func() *amcl.RAND + Translator idemix.Translator + Idemix *idemix.Idemix } // NewKey generates a new issuer key-pair @@ -56,7 +56,7 @@ func (i *Issuer) NewKey(attributeNames []string) (res handlers.IssuerSecretKey, } }() - sk, err := cryptolib.NewIssuerKey(attributeNames, i.NewRand()) + sk, err := i.Idemix.NewIssuerKey(attributeNames, newRandOrPanic(i.Idemix.Curve), i.Translator) if err != nil { return } @@ -66,7 +66,7 @@ func (i *Issuer) NewKey(attributeNames []string) (res handlers.IssuerSecretKey, return } -func (*Issuer) NewPublicKeyFromBytes(raw []byte, attributes []string) (res handlers.IssuerPublicKey, err error) { +func (i *Issuer) NewKeyFromBytes(raw []byte, attributes []string) (res handlers.IssuerSecretKey, err error) { defer func() { if r := recover(); r != nil { res = nil @@ -74,32 +74,47 @@ func (*Issuer) NewPublicKeyFromBytes(raw []byte, attributes []string) (res handl } }() - ipk := new(cryptolib.IssuerPublicKey) + sk, err := i.Idemix.NewIssuerKeyFromBytes(raw) + if err != nil { + return + } + + res = &IssuerSecretKey{SK: sk} + + return +} + +func (i *Issuer) NewPublicKeyFromBytes(raw []byte, attributes []string) (res handlers.IssuerPublicKey, err error) { + defer func() { + if r := recover(); r != nil { + res = nil + err = errors.Errorf("failure [%s]", r) + } + }() + + ipk := new(idemix.IssuerPublicKey) err = proto.Unmarshal(raw, ipk) if err != nil { return nil, errors.WithStack(&bccsp.IdemixIssuerPublicKeyImporterError{ Type: bccsp.IdemixIssuerPublicKeyImporterUnmarshallingError, ErrorMsg: "failed to unmarshal issuer public key", - Cause: err, - }) + Cause: err}) } - err = ipk.SetHash() + err = ipk.SetHash(i.Idemix.Curve) if err != nil { return nil, errors.WithStack(&bccsp.IdemixIssuerPublicKeyImporterError{ Type: bccsp.IdemixIssuerPublicKeyImporterHashError, ErrorMsg: "setting the hash of the issuer public key failed", - Cause: err, - }) + Cause: err}) } - err = ipk.Check() + err = ipk.Check(i.Idemix.Curve, i.Translator) if err != nil { return nil, errors.WithStack(&bccsp.IdemixIssuerPublicKeyImporterError{ Type: bccsp.IdemixIssuerPublicKeyImporterValidationError, ErrorMsg: "invalid issuer public key", - Cause: err, - }) + Cause: err}) } if len(attributes) != 0 { diff --git a/bccsp/idemix/bridge/nymsignaturescheme.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/nymsignaturescheme.go similarity index 56% rename from bccsp/idemix/bridge/nymsignaturescheme.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/nymsignaturescheme.go index 1cdd6da7fde..442668dbdca 100644 --- a/bccsp/idemix/bridge/nymsignaturescheme.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/nymsignaturescheme.go @@ -6,23 +6,24 @@ SPDX-License-Identifier: Apache-2.0 package bridge import ( - "github.com/hyperledger/fabric-amcl/amcl" - "github.com/hyperledger/fabric/bccsp/idemix/handlers" + idemix "github.com/IBM/idemix/bccsp/schemes/dlog/crypto" + "github.com/IBM/idemix/bccsp/schemes/dlog/handlers" + math "github.com/IBM/mathlib" "github.com/golang/protobuf/proto" - cryptolib "github.com/hyperledger/fabric/idemix" "github.com/pkg/errors" ) // NymSignatureScheme encapsulates the idemix algorithms to sign and verify using an idemix // pseudonym. type NymSignatureScheme struct { - NewRand func() *amcl.RAND + Translator idemix.Translator + Idemix *idemix.Idemix } // Sign produces a signature over the passed digest. It takes in input, the user secret key (sk), // the pseudonym public key (Nym) and secret key (RNym), and the issuer public key (ipk). -func (n *NymSignatureScheme) Sign(sk handlers.Big, Nym handlers.Ecp, RNym handlers.Big, ipk handlers.IssuerPublicKey, digest []byte) (res []byte, err error) { +func (n *NymSignatureScheme) Sign(sk *math.Zr, Nym *math.G1, RNym *math.Zr, ipk handlers.IssuerPublicKey, digest []byte) (res []byte, err error) { defer func() { if r := recover(); r != nil { res = nil @@ -30,30 +31,19 @@ func (n *NymSignatureScheme) Sign(sk handlers.Big, Nym handlers.Ecp, RNym handle } }() - isk, ok := sk.(*Big) - if !ok { - return nil, errors.Errorf("invalid user secret key, expected *Big, got [%T]", sk) - } - inym, ok := Nym.(*Ecp) - if !ok { - return nil, errors.Errorf("invalid nym public key, expected *Ecp, got [%T]", Nym) - } - irnym, ok := RNym.(*Big) - if !ok { - return nil, errors.Errorf("invalid nym secret key, expected *Big, got [%T]", RNym) - } iipk, ok := ipk.(*IssuerPublicKey) if !ok { return nil, errors.Errorf("invalid issuer public key, expected *IssuerPublicKey, got [%T]", ipk) } - sig, err := cryptolib.NewNymSignature( - isk.E, - inym.E, - irnym.E, + sig, err := n.Idemix.NewNymSignature( + sk, + Nym, + RNym, iipk.PK, digest, - n.NewRand()) + newRandOrPanic(n.Idemix.Curve), + n.Translator) if err != nil { return nil, errors.WithMessage(err, "failed creating new nym signature") } @@ -63,7 +53,7 @@ func (n *NymSignatureScheme) Sign(sk handlers.Big, Nym handlers.Ecp, RNym handle // Verify checks that the passed signatures is valid with the respect to the passed digest, issuer public key, // and pseudonym public key. -func (*NymSignatureScheme) Verify(ipk handlers.IssuerPublicKey, Nym handlers.Ecp, signature, digest []byte) (err error) { +func (n *NymSignatureScheme) Verify(ipk handlers.IssuerPublicKey, Nym *math.G1, signature, digest []byte) (err error) { defer func() { if r := recover(); r != nil { err = errors.Errorf("failure [%s]", r) @@ -74,16 +64,12 @@ func (*NymSignatureScheme) Verify(ipk handlers.IssuerPublicKey, Nym handlers.Ecp if !ok { return errors.Errorf("invalid issuer public key, expected *IssuerPublicKey, got [%T]", ipk) } - inym, ok := Nym.(*Ecp) - if !ok { - return errors.Errorf("invalid nym public key, expected *Ecp, got [%T]", Nym) - } - sig := &cryptolib.NymSignature{} + sig := &idemix.NymSignature{} err = proto.Unmarshal(signature, sig) if err != nil { return errors.Wrap(err, "error unmarshalling signature") } - return sig.Ver(inym.E, iipk.PK, digest) + return sig.Ver(Nym, iipk.PK, digest, n.Idemix.Curve, n.Translator) } diff --git a/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/rand.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/rand.go new file mode 100644 index 00000000000..efdd3d2239a --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/rand.go @@ -0,0 +1,20 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +package bridge + +import ( + "io" + + math "github.com/IBM/mathlib" +) + +func newRandOrPanic(curve *math.Curve) io.Reader { + rng, err := curve.Rand() + if err != nil { + panic(err) + } + return rng +} diff --git a/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/revocation.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/revocation.go new file mode 100644 index 00000000000..b82d25d4f98 --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/revocation.go @@ -0,0 +1,76 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +package bridge + +import ( + "crypto/ecdsa" + + bccsp "github.com/IBM/idemix/bccsp/schemes" + idemix "github.com/IBM/idemix/bccsp/schemes/dlog/crypto" + math "github.com/IBM/mathlib" + "github.com/golang/protobuf/proto" + "github.com/pkg/errors" +) + +// Revocation encapsulates the idemix algorithms for revocation +type Revocation struct { + Translator idemix.Translator + Idemix *idemix.Idemix +} + +// NewKey generate a new revocation key-pair. +func (r *Revocation) NewKey() (*ecdsa.PrivateKey, error) { + return r.Idemix.GenerateLongTermRevocationKey() +} + +func (r *Revocation) NewKeyFromBytes(raw []byte) (*ecdsa.PrivateKey, error) { + return r.Idemix.LongTermRevocationKeyFromBytes(raw) +} + +// Sign generates a new CRI with the respect to the passed unrevoked handles, epoch, and revocation algorithm. +func (r *Revocation) Sign(key *ecdsa.PrivateKey, unrevokedHandles [][]byte, epoch int, alg bccsp.RevocationAlgorithm) (res []byte, err error) { + defer func() { + if r := recover(); r != nil { + res = nil + err = errors.Errorf("failure [%s]", r) + } + }() + + handles := make([]*math.Zr, len(unrevokedHandles)) + for i := 0; i < len(unrevokedHandles); i++ { + handles[i] = r.Idemix.Curve.NewZrFromBytes(unrevokedHandles[i]) + } + cri, err := r.Idemix.CreateCRI(key, handles, epoch, idemix.RevocationAlgorithm(alg), newRandOrPanic(r.Idemix.Curve), r.Translator) + if err != nil { + return nil, errors.WithMessage(err, "failed creating CRI") + } + + return proto.Marshal(cri) +} + +// Verify checks that the passed serialised CRI (criRaw) is valid with the respect to the passed revocation public key, +// epoch, and revocation algorithm. +func (r *Revocation) Verify(pk *ecdsa.PublicKey, criRaw []byte, epoch int, alg bccsp.RevocationAlgorithm) (err error) { + defer func() { + if r := recover(); r != nil { + err = errors.Errorf("failure [%s]", r) + } + }() + + cri := &idemix.CredentialRevocationInformation{} + err = proto.Unmarshal(criRaw, cri) + if err != nil { + return err + } + + return r.Idemix.VerifyEpochPK( + pk, + cri.EpochPk, + cri.EpochPkSig, + int(cri.Epoch), + idemix.RevocationAlgorithm(cri.RevocationAlg), + ) +} diff --git a/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/signaturescheme.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/signaturescheme.go new file mode 100644 index 00000000000..35a148e166e --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/signaturescheme.go @@ -0,0 +1,197 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +package bridge + +import ( + "crypto/ecdsa" + + bccsp "github.com/IBM/idemix/bccsp/schemes" + idemix "github.com/IBM/idemix/bccsp/schemes/dlog/crypto" + "github.com/IBM/idemix/bccsp/schemes/dlog/handlers" + math "github.com/IBM/mathlib" + "github.com/golang/protobuf/proto" + "github.com/pkg/errors" +) + +// SignatureScheme encapsulates the idemix algorithms to sign and verify using an idemix credential. +type SignatureScheme struct { + Translator idemix.Translator + Idemix *idemix.Idemix +} + +// Sign produces an idemix-signature with the respect to the passed serialised credential (cred), +// user secret key (sk), pseudonym public key (Nym) and secret key (RNym), issuer public key (ipk), +// and attributes to be disclosed. +func (s *SignatureScheme) Sign(cred []byte, sk *math.Zr, Nym *math.G1, RNym *math.Zr, ipk handlers.IssuerPublicKey, attributes []bccsp.IdemixAttribute, + msg []byte, rhIndex, eidIndex int, criRaw []byte, sigType bccsp.SignatureType) (res []byte, meta *bccsp.IdemixSignerMetadata, err error) { + defer func() { + if r := recover(); r != nil { + res = nil + err = errors.Errorf("failure [%s]", r) + } + }() + + iipk, ok := ipk.(*IssuerPublicKey) + if !ok { + return nil, nil, errors.Errorf("invalid issuer public key, expected *IssuerPublicKey, got [%T]", ipk) + } + + credential := &idemix.Credential{} + err = proto.Unmarshal(cred, credential) + if err != nil { + return nil, nil, errors.Wrap(err, "failed unmarshalling credential") + } + + cri := &idemix.CredentialRevocationInformation{} + err = proto.Unmarshal(criRaw, cri) + if err != nil { + return nil, nil, errors.Wrap(err, "failed unmarshalling credential revocation information") + } + + disclosure := make([]byte, len(attributes)) + for i := 0; i < len(attributes); i++ { + if attributes[i].Type == bccsp.IdemixHiddenAttribute { + disclosure[i] = 0 + } else { + disclosure[i] = 1 + } + } + + sig, meta, err := s.Idemix.NewSignature( + credential, + sk, + Nym, + RNym, + iipk.PK, + disclosure, + msg, + rhIndex, eidIndex, + cri, + newRandOrPanic(s.Idemix.Curve), + s.Translator, + sigType) + if err != nil { + return nil, nil, errors.WithMessage(err, "failed creating new signature") + } + + sigBytes, err := proto.Marshal(sig) + if err != nil { + return nil, nil, errors.WithMessage(err, "marshalling error") + } + + return sigBytes, meta, nil +} + +func (s *SignatureScheme) AuditNymEid( + ipk handlers.IssuerPublicKey, + eidIndex int, + signature []byte, + enrollmentID string, + RNymEid *math.Zr, +) (err error) { + defer func() { + if r := recover(); r != nil { + err = errors.Errorf("failure [%s]", r) + } + }() + + iipk, ok := ipk.(*IssuerPublicKey) + if !ok { + return errors.Errorf("invalid issuer public key, expected *IssuerPublicKey, got [%T]", ipk) + } + + sig := &idemix.Signature{} + err = proto.Unmarshal(signature, sig) + if err != nil { + return err + } + + eidAttr := s.Idemix.Curve.HashToZr([]byte(enrollmentID)) + + return sig.AuditNymEid( + iipk.PK, + eidAttr, + eidIndex, + RNymEid, + s.Idemix.Curve, + s.Translator, + ) +} + +// Verify checks that an idemix signature is valid with the respect to the passed issuer public key, digest, attributes, +// revocation index (rhIndex), revocation public key, and epoch. +func (s *SignatureScheme) Verify( + ipk handlers.IssuerPublicKey, + signature, digest []byte, + attributes []bccsp.IdemixAttribute, + rhIndex, eidIndex int, + revocationPublicKey *ecdsa.PublicKey, + epoch int, + verType bccsp.VerificationType, + meta *bccsp.IdemixSignerMetadata, +) (err error) { + defer func() { + if r := recover(); r != nil { + err = errors.Errorf("failure [%s]", r) + } + }() + + iipk, ok := ipk.(*IssuerPublicKey) + if !ok { + return errors.Errorf("invalid issuer public key, expected *IssuerPublicKey, got [%T]", ipk) + } + + sig := &idemix.Signature{} + err = proto.Unmarshal(signature, sig) + if err != nil { + return err + } + + disclosure := make([]byte, len(attributes)) + attrValues := make([]*math.Zr, len(attributes)) + for i := 0; i < len(attributes); i++ { + switch attributes[i].Type { + case bccsp.IdemixHiddenAttribute: + disclosure[i] = 0 + attrValues[i] = nil + case bccsp.IdemixBytesAttribute: + disclosure[i] = 1 + attrValues[i] = s.Idemix.Curve.HashToZr(attributes[i].Value.([]byte)) + case bccsp.IdemixIntAttribute: + var value int64 + if v, ok := attributes[i].Value.(int); ok { + value = int64(v) + } else if v, ok := attributes[i].Value.(int64); ok { + value = v + } else { + return errors.Errorf("invalid int type for IdemixIntAttribute attribute") + } + + disclosure[i] = 1 + attrValues[i] = s.Idemix.Curve.NewZrFromInt(value) + default: + err = errors.Errorf("attribute type not allowed or supported [%v] at position [%d]", attributes[i].Type, i) + } + } + if err != nil { + return + } + + return sig.Ver( + disclosure, + iipk.PK, + digest, + attrValues, + rhIndex, + eidIndex, + revocationPublicKey, + epoch, + s.Idemix.Curve, + s.Translator, + verType, + meta, + ) +} diff --git a/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/user.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/user.go new file mode 100644 index 00000000000..be3f2a38d37 --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/bridge/user.go @@ -0,0 +1,96 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +package bridge + +import ( + idemix "github.com/IBM/idemix/bccsp/schemes/dlog/crypto" + "github.com/IBM/idemix/bccsp/schemes/dlog/handlers" + math "github.com/IBM/mathlib" + "github.com/pkg/errors" +) + +// User encapsulates the idemix algorithms to generate user secret keys and pseudonym. +type User struct { + Translator idemix.Translator + Idemix *idemix.Idemix +} + +// NewKey generates an idemix user secret key +func (u *User) NewKey() (res *math.Zr, err error) { + defer func() { + if r := recover(); r != nil { + res = nil + err = errors.Errorf("failure [%s]", r) + } + }() + + res = u.Idemix.Curve.NewRandomZr(newRandOrPanic(u.Idemix.Curve)) + + return +} + +func (u *User) NewKeyFromBytes(raw []byte) (res *math.Zr, err error) { + if len(raw) != u.Idemix.Curve.FieldBytes { + return nil, errors.Errorf("invalid length, expected [%d], got [%d]", u.Idemix.Curve.FieldBytes, len(raw)) + } + + res = u.Idemix.Curve.NewZrFromBytes(raw) + + return +} + +// MakeNym generates a new pseudonym key-pair derived from the passed user secret key (sk) and issuer public key (ipk) +func (u *User) MakeNym(sk *math.Zr, ipk handlers.IssuerPublicKey) (r1 *math.G1, r2 *math.Zr, err error) { + defer func() { + if r := recover(); r != nil { + r1 = nil + r2 = nil + err = errors.Errorf("failure [%s]", r) + } + }() + + iipk, ok := ipk.(*IssuerPublicKey) + if !ok { + return nil, nil, errors.Errorf("invalid issuer public key, expected *IssuerPublicKey, got [%T]", ipk) + } + + ecp, big, err := u.Idemix.MakeNym(sk, iipk.PK, newRandOrPanic(u.Idemix.Curve), u.Translator) + + r1 = ecp + r2 = big + + return +} + +// MakeNym generates a new pseudonym key-pair derived from the passed user secret key (sk) and issuer public key (ipk) +func (u *User) NewNymFromBytes(raw []byte) (r1 *math.G1, r2 *math.Zr, err error) { + defer func() { + if r := recover(); r != nil { + r1 = nil + r2 = nil + err = errors.Errorf("failure [%s]", r) + } + }() + + ecp, big, err := u.Idemix.MakeNymFromBytes(raw) + r1 = ecp + r2 = big + + return +} + +func (u *User) NewPublicNymFromBytes(raw []byte) (res *math.G1, err error) { + defer func() { + if r := recover(); r != nil { + res = nil + err = errors.Errorf("failure [%s]", r) + } + }() + + res, err = u.Translator.G1FromRawBytes(raw) + + return +} diff --git a/idemix/credential.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/credential.go similarity index 60% rename from idemix/credential.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/credential.go index cb1d460c00b..307a6a75fc7 100644 --- a/idemix/credential.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/credential.go @@ -7,11 +7,21 @@ SPDX-License-Identifier: Apache-2.0 package idemix import ( - "github.com/hyperledger/fabric-amcl/amcl" - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" + "io" + + amcl "github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl" + math "github.com/IBM/mathlib" "github.com/pkg/errors" ) +type Translator interface { + G1ToProto(*math.G1) *amcl.ECP + G1FromProto(*amcl.ECP) (*math.G1, error) + G1FromRawBytes([]byte) (*math.G1, error) + G2ToProto(*math.G2) *amcl.ECP2 + G2FromProto(*amcl.ECP2) (*math.G2, error) +} + // Identity Mixer Credential is a list of attributes certified (signed) by the issuer // A credential also contains a user secret key blindly signed by the issuer // Without the secret key the credential cannot be used @@ -34,9 +44,13 @@ import ( // NewCredential issues a new credential, which is the last step of the interactive issuance protocol // All attribute values are added by the issuer at this step and then signed together with a commitment to // the user's secret key from a credential request -func NewCredential(key *IssuerKey, m *CredRequest, attrs []*FP256BN.BIG, rng *amcl.RAND) (*Credential, error) { +func (i *Idemix) NewCredential(key *IssuerKey, m *CredRequest, attrs []*math.Zr, rng io.Reader, t Translator) (*Credential, error) { + return newCredential(key, m, attrs, rng, t, i.Curve) +} + +func newCredential(key *IssuerKey, m *CredRequest, attrs []*math.Zr, rng io.Reader, t Translator, curve *math.Curve) (*Credential, error) { // check the credential request that contains - err := m.Check(key.Ipk) + err := m.Check(key.Ipk, curve, t) if err != nil { return nil, err } @@ -57,36 +71,52 @@ func NewCredential(key *IssuerKey, m *CredRequest, attrs []*FP256BN.BIG, rng *am // h_r is h_0 in http://eprint.iacr.org/2016/663.pdf, Sec. 4.3. // Pick randomness E and S - E := RandModOrder(rng) - S := RandModOrder(rng) + E := curve.NewRandomZr(rng) + S := curve.NewRandomZr(rng) // Set B as g_1 \cdot h_r^s \cdot h_sk^sk \cdot \prod_{i=1}^L h_i^{m_i} and Exp = \frac{1}{e+x} - B := FP256BN.NewECP() - B.Copy(GenG1) // g_1 - Nym := EcpFromProto(m.Nym) - B.Add(Nym) // in this case, recall Nym=h_sk^sk - B.Add(EcpFromProto(key.Ipk.HRand).Mul(S)) // h_r^s + B := curve.NewG1() + B.Clone(curve.GenG1) // g_1 + Nym, err := t.G1FromProto(m.Nym) + if err != nil { + return nil, err + } + B.Add(Nym) // in this case, recall Nym=h_sk^sk + HRand, err := t.G1FromProto(key.Ipk.HRand) + if err != nil { + return nil, err + } + B.Add(HRand.Mul(S)) // h_r^s + + HAttrs := make([]*math.G1, len(key.Ipk.HAttrs)) + for i := range key.Ipk.HAttrs { + var err error + HAttrs[i], err = t.G1FromProto(key.Ipk.HAttrs[i]) + if err != nil { + return nil, err + } + } // Append attributes // Use Mul2 instead of Mul as much as possible for efficiency reasones for i := 0; i < len(attrs)/2; i++ { B.Add( // Add two attributes in one shot - EcpFromProto(key.Ipk.HAttrs[2*i]).Mul2( + HAttrs[2*i].Mul2( attrs[2*i], - EcpFromProto(key.Ipk.HAttrs[2*i+1]), + HAttrs[2*i+1], attrs[2*i+1], ), ) } // Check for residue in case len(attrs)%2 is odd if len(attrs)%2 != 0 { - B.Add(EcpFromProto(key.Ipk.HAttrs[len(attrs)-1]).Mul(attrs[len(attrs)-1])) + B.Add(HAttrs[len(attrs)-1].Mul(attrs[len(attrs)-1])) } // Set Exp as \frac{1}{e+x} - Exp := Modadd(FP256BN.FromBytes(key.GetIsk()), E, GroupOrder) - Exp.Invmodp(GroupOrder) + Exp := curve.ModAdd(curve.NewZrFromBytes(key.GetIsk()), E, curve.GroupOrder) + Exp.InvModP(curve.GroupOrder) // Finalise A as B^Exp A := B.Mul(Exp) // The signature is now generated. @@ -95,28 +125,33 @@ func NewCredential(key *IssuerKey, m *CredRequest, attrs []*FP256BN.BIG, rng *am // it can be compute publicly from the BBS+ signature itself. CredAttrs := make([][]byte, len(attrs)) for index, attribute := range attrs { - CredAttrs[index] = BigToBytes(attribute) + CredAttrs[index] = attribute.Bytes() } return &Credential{ - A: EcpToProto(A), - B: EcpToProto(B), - E: BigToBytes(E), - S: BigToBytes(S), - Attrs: CredAttrs, - }, nil + A: t.G1ToProto(A), + B: t.G1ToProto(B), + E: E.Bytes(), + S: S.Bytes(), + Attrs: CredAttrs}, nil } // Ver cryptographically verifies the credential by verifying the signature // on the attribute values and user's secret key -func (cred *Credential) Ver(sk *FP256BN.BIG, ipk *IssuerPublicKey) error { +func (cred *Credential) Ver(sk *math.Zr, ipk *IssuerPublicKey, curve *math.Curve, t Translator) error { // Validate Input // - parse the credential - A := EcpFromProto(cred.GetA()) - B := EcpFromProto(cred.GetB()) - E := FP256BN.FromBytes(cred.GetE()) - S := FP256BN.FromBytes(cred.GetS()) + A, err := t.G1FromProto(cred.GetA()) + if err != nil { + return err + } + B, err := t.G1FromProto(cred.GetB()) + if err != nil { + return err + } + E := curve.NewZrFromBytes(cred.GetE()) + S := curve.NewZrFromBytes(cred.GetS()) // - verify that all attribute values are present for i := 0; i < len(cred.GetAttrs()); i++ { @@ -125,33 +160,57 @@ func (cred *Credential) Ver(sk *FP256BN.BIG, ipk *IssuerPublicKey) error { } } + HSk, err := t.G1FromProto(ipk.HSk) + if err != nil { + return err + } + + HRand, err := t.G1FromProto(ipk.HRand) + if err != nil { + return err + } + + HAttrs := make([]*math.G1, len(ipk.HAttrs)) + for i := range ipk.HAttrs { + var err error + HAttrs[i], err = t.G1FromProto(ipk.HAttrs[i]) + if err != nil { + return err + } + } + // - verify cryptographic signature on the attributes and the user secret key - BPrime := FP256BN.NewECP() - BPrime.Copy(GenG1) - BPrime.Add(EcpFromProto(ipk.HSk).Mul2(sk, EcpFromProto(ipk.HRand), S)) + BPrime := curve.NewG1() + BPrime.Clone(curve.GenG1) + BPrime.Add(HSk.Mul2(sk, HRand, S)) for i := 0; i < len(cred.Attrs)/2; i++ { BPrime.Add( - EcpFromProto(ipk.HAttrs[2*i]).Mul2( - FP256BN.FromBytes(cred.Attrs[2*i]), - EcpFromProto(ipk.HAttrs[2*i+1]), - FP256BN.FromBytes(cred.Attrs[2*i+1]), + HAttrs[2*i].Mul2( + curve.NewZrFromBytes(cred.Attrs[2*i]), + HAttrs[2*i+1], + curve.NewZrFromBytes(cred.Attrs[2*i+1]), ), ) } if len(cred.Attrs)%2 != 0 { - BPrime.Add(EcpFromProto(ipk.HAttrs[len(cred.Attrs)-1]).Mul(FP256BN.FromBytes(cred.Attrs[len(cred.Attrs)-1]))) + BPrime.Add(HAttrs[len(cred.Attrs)-1].Mul(curve.NewZrFromBytes(cred.Attrs[len(cred.Attrs)-1]))) } if !B.Equals(BPrime) { return errors.Errorf("b-value from credential does not match the attribute values") } + W, err := t.G2FromProto(ipk.W) + if err != nil { + return err + } + // Verify BBS+ signature. Namely: e(w \cdot g_2^e, A) =? e(g_2, B) - a := GenG2.Mul(E) - a.Add(Ecp2FromProto(ipk.W)) + a := curve.GenG2.Mul(E) + a.Add(W) a.Affine() - left := FP256BN.Fexp(FP256BN.Ate(a, A)) - right := FP256BN.Fexp(FP256BN.Ate(GenG2, B)) + left := curve.FExp(curve.Pairing(a, A)) + right := curve.FExp(curve.Pairing(curve.GenG2, B)) if !left.Equals(right) { return errors.Errorf("credential is not cryptographically valid") diff --git a/idemix/credrequest.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/credrequest.go similarity index 68% rename from idemix/credrequest.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/credrequest.go index dfd36b91ee5..28592a4408a 100644 --- a/idemix/credrequest.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/credrequest.go @@ -7,8 +7,9 @@ SPDX-License-Identifier: Apache-2.0 package idemix import ( - "github.com/hyperledger/fabric-amcl/amcl" - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" + "io" + + math "github.com/IBM/mathlib" "github.com/pkg/errors" ) @@ -32,15 +33,22 @@ const credRequestLabel = "credRequest" // NewCredRequest creates a new Credential Request, the first message of the interactive credential issuance protocol // (from user to issuer) -func NewCredRequest(sk *FP256BN.BIG, IssuerNonce []byte, ipk *IssuerPublicKey, rng *amcl.RAND) *CredRequest { +func (i *Idemix) NewCredRequest(sk *math.Zr, IssuerNonce []byte, ipk *IssuerPublicKey, rng io.Reader, tr Translator) (*CredRequest, error) { + return newCredRequest(sk, IssuerNonce, ipk, rng, i.Curve, tr) +} + +func newCredRequest(sk *math.Zr, IssuerNonce []byte, ipk *IssuerPublicKey, rng io.Reader, curve *math.Curve, tr Translator) (*CredRequest, error) { // Set Nym as h_{sk}^{sk} - HSk := EcpFromProto(ipk.HSk) + HSk, err := tr.G1FromProto(ipk.HSk) + if err != nil { + return nil, err + } Nym := HSk.Mul(sk) // generate a zero-knowledge proof of knowledge (ZK PoK) of the secret key // Sample the randomness needed for the proof - rSk := RandModOrder(rng) + rSk := curve.NewRandomZr(rng) // Step 1: First message (t-values) t := HSk.Mul(rSk) // t = h_{sk}^{r_{sk}}, cover Nym @@ -48,10 +56,10 @@ func NewCredRequest(sk *FP256BN.BIG, IssuerNonce []byte, ipk *IssuerPublicKey, r // Step 2: Compute the Fiat-Shamir hash, forming the challenge of the ZKP. // proofData is the data being hashed, it consists of: // the credential request label - // 3 elements of G1 each taking 2*FieldBytes+1 bytes - // hash of the issuer public key of length FieldBytes - // issuer nonce of length FieldBytes - proofData := make([]byte, len(credRequestLabel)+3*(2*FieldBytes+1)+2*FieldBytes) + // 3 elements of G1 each taking 2*math.FieldBytes+1 bytes + // hash of the issuer public key of length math.FieldBytes + // issuer nonce of length math.FieldBytes + proofData := make([]byte, len([]byte(credRequestLabel))+3*(2*curve.FieldBytes+1)+2*curve.FieldBytes) index := 0 index = appendBytesString(proofData, index, credRequestLabel) index = appendBytesG1(proofData, index, t) @@ -59,28 +67,35 @@ func NewCredRequest(sk *FP256BN.BIG, IssuerNonce []byte, ipk *IssuerPublicKey, r index = appendBytesG1(proofData, index, Nym) index = appendBytes(proofData, index, IssuerNonce) copy(proofData[index:], ipk.Hash) - proofC := HashModOrder(proofData) + proofC := curve.HashToZr(proofData) // Step 3: reply to the challenge message (s-values) - proofS := Modadd(FP256BN.Modmul(proofC, sk, GroupOrder), rSk, GroupOrder) // s = r_{sk} + C \cdot sk + proofS := curve.ModAdd(curve.ModMul(proofC, sk, curve.GroupOrder), rSk, curve.GroupOrder) // s = r_{sk} + C \cdot sk // Done return &CredRequest{ - Nym: EcpToProto(Nym), + Nym: tr.G1ToProto(Nym), IssuerNonce: IssuerNonce, - ProofC: BigToBytes(proofC), - ProofS: BigToBytes(proofS), - } + ProofC: proofC.Bytes(), + ProofS: proofS.Bytes(), + }, nil } // Check cryptographically verifies the credential request -func (m *CredRequest) Check(ipk *IssuerPublicKey) error { - Nym := EcpFromProto(m.GetNym()) +func (m *CredRequest) Check(ipk *IssuerPublicKey, curve *math.Curve, tr Translator) error { + Nym, err := tr.G1FromProto(m.GetNym()) + if err != nil { + return err + } + IssuerNonce := m.GetIssuerNonce() - ProofC := FP256BN.FromBytes(m.GetProofC()) - ProofS := FP256BN.FromBytes(m.GetProofS()) + ProofC := curve.NewZrFromBytes(m.GetProofC()) + ProofS := curve.NewZrFromBytes(m.GetProofS()) - HSk := EcpFromProto(ipk.HSk) + HSk, err := tr.G1FromProto(ipk.HSk) + if err != nil { + return err + } if Nym == nil || IssuerNonce == nil || ProofC == nil || ProofS == nil { return errors.Errorf("one of the proof values is undefined") @@ -93,7 +108,7 @@ func (m *CredRequest) Check(ipk *IssuerPublicKey) error { t.Sub(Nym.Mul(ProofC)) // t = h_{sk}^s / Nym^C // Recompute challenge - proofData := make([]byte, len(credRequestLabel)+3*(2*FieldBytes+1)+2*FieldBytes) + proofData := make([]byte, len([]byte(credRequestLabel))+3*(2*curve.FieldBytes+1)+2*curve.FieldBytes) index := 0 index = appendBytesString(proofData, index, credRequestLabel) index = appendBytesG1(proofData, index, t) @@ -102,7 +117,7 @@ func (m *CredRequest) Check(ipk *IssuerPublicKey) error { index = appendBytes(proofData, index, IssuerNonce) copy(proofData[index:], ipk.Hash) - if *ProofC != *HashModOrder(proofData) { + if !ProofC.Equals(curve.HashToZr(proofData)) { return errors.Errorf("zero knowledge proof is invalid") } diff --git a/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/idemix.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/idemix.go new file mode 100644 index 00000000000..72ece27a6c7 --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/idemix.go @@ -0,0 +1,16 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package idemix + +import ( + math "github.com/IBM/mathlib" +) + +type Idemix struct { + Curve *math.Curve + Translator Translator +} diff --git a/idemix/idemix.pb.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/idemix.pb.go similarity index 60% rename from idemix/idemix.pb.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/idemix.pb.go index 661c91bc809..bb801ce9d84 100644 --- a/idemix/idemix.pb.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/idemix.pb.go @@ -1,10 +1,11 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// source: idemix.proto +// source: bccsp/schemes/dlog/crypto/idemix.proto package idemix import ( fmt "fmt" + amcl "github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl" proto "github.com/golang/protobuf/proto" math "math" ) @@ -20,146 +21,32 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package -// ECP is an elliptic curve point specified by its coordinates -// ECP corresponds to an element of the first group (G1) -type ECP struct { - X []byte `protobuf:"bytes,1,opt,name=x,proto3" json:"x,omitempty"` - Y []byte `protobuf:"bytes,2,opt,name=y,proto3" json:"y,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ECP) Reset() { *m = ECP{} } -func (m *ECP) String() string { return proto.CompactTextString(m) } -func (*ECP) ProtoMessage() {} -func (*ECP) Descriptor() ([]byte, []int) { - return fileDescriptor_28d23908e9a304c6, []int{0} -} - -func (m *ECP) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ECP.Unmarshal(m, b) -} -func (m *ECP) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ECP.Marshal(b, m, deterministic) -} -func (m *ECP) XXX_Merge(src proto.Message) { - xxx_messageInfo_ECP.Merge(m, src) -} -func (m *ECP) XXX_Size() int { - return xxx_messageInfo_ECP.Size(m) -} -func (m *ECP) XXX_DiscardUnknown() { - xxx_messageInfo_ECP.DiscardUnknown(m) -} - -var xxx_messageInfo_ECP proto.InternalMessageInfo - -func (m *ECP) GetX() []byte { - if m != nil { - return m.X - } - return nil -} - -func (m *ECP) GetY() []byte { - if m != nil { - return m.Y - } - return nil -} - -// ECP2 is an elliptic curve point specified by its coordinates -// ECP2 corresponds to an element of the second group (G2) -type ECP2 struct { - Xa []byte `protobuf:"bytes,1,opt,name=xa,proto3" json:"xa,omitempty"` - Xb []byte `protobuf:"bytes,2,opt,name=xb,proto3" json:"xb,omitempty"` - Ya []byte `protobuf:"bytes,3,opt,name=ya,proto3" json:"ya,omitempty"` - Yb []byte `protobuf:"bytes,4,opt,name=yb,proto3" json:"yb,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ECP2) Reset() { *m = ECP2{} } -func (m *ECP2) String() string { return proto.CompactTextString(m) } -func (*ECP2) ProtoMessage() {} -func (*ECP2) Descriptor() ([]byte, []int) { - return fileDescriptor_28d23908e9a304c6, []int{1} -} - -func (m *ECP2) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ECP2.Unmarshal(m, b) -} -func (m *ECP2) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ECP2.Marshal(b, m, deterministic) -} -func (m *ECP2) XXX_Merge(src proto.Message) { - xxx_messageInfo_ECP2.Merge(m, src) -} -func (m *ECP2) XXX_Size() int { - return xxx_messageInfo_ECP2.Size(m) -} -func (m *ECP2) XXX_DiscardUnknown() { - xxx_messageInfo_ECP2.DiscardUnknown(m) -} - -var xxx_messageInfo_ECP2 proto.InternalMessageInfo - -func (m *ECP2) GetXa() []byte { - if m != nil { - return m.Xa - } - return nil -} - -func (m *ECP2) GetXb() []byte { - if m != nil { - return m.Xb - } - return nil -} - -func (m *ECP2) GetYa() []byte { - if m != nil { - return m.Ya - } - return nil -} - -func (m *ECP2) GetYb() []byte { - if m != nil { - return m.Yb - } - return nil -} - // IssuerPublicKey specifies an issuer public key that consists of // attribute_names - a list of the attribute names of a credential issued by the issuer // h_sk, h_rand, h_attrs, w, bar_g1, bar_g2 - group elements corresponding to the signing key, randomness, and attributes // proof_c, proof_s compose a zero-knowledge proof of knowledge of the secret key // hash is a hash of the public key appended to it type IssuerPublicKey struct { - AttributeNames []string `protobuf:"bytes,1,rep,name=attribute_names,json=attributeNames,proto3" json:"attribute_names,omitempty"` - HSk *ECP `protobuf:"bytes,2,opt,name=h_sk,json=hSk,proto3" json:"h_sk,omitempty"` - HRand *ECP `protobuf:"bytes,3,opt,name=h_rand,json=hRand,proto3" json:"h_rand,omitempty"` - HAttrs []*ECP `protobuf:"bytes,4,rep,name=h_attrs,json=hAttrs,proto3" json:"h_attrs,omitempty"` - W *ECP2 `protobuf:"bytes,5,opt,name=w,proto3" json:"w,omitempty"` - BarG1 *ECP `protobuf:"bytes,6,opt,name=bar_g1,json=barG1,proto3" json:"bar_g1,omitempty"` - BarG2 *ECP `protobuf:"bytes,7,opt,name=bar_g2,json=barG2,proto3" json:"bar_g2,omitempty"` - ProofC []byte `protobuf:"bytes,8,opt,name=proof_c,json=proofC,proto3" json:"proof_c,omitempty"` - ProofS []byte `protobuf:"bytes,9,opt,name=proof_s,json=proofS,proto3" json:"proof_s,omitempty"` - Hash []byte `protobuf:"bytes,10,opt,name=hash,proto3" json:"hash,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + AttributeNames []string `protobuf:"bytes,1,rep,name=attribute_names,json=attributeNames,proto3" json:"attribute_names,omitempty"` + HSk *amcl.ECP `protobuf:"bytes,2,opt,name=h_sk,json=hSk,proto3" json:"h_sk,omitempty"` + HRand *amcl.ECP `protobuf:"bytes,3,opt,name=h_rand,json=hRand,proto3" json:"h_rand,omitempty"` + HAttrs []*amcl.ECP `protobuf:"bytes,4,rep,name=h_attrs,json=hAttrs,proto3" json:"h_attrs,omitempty"` + W *amcl.ECP2 `protobuf:"bytes,5,opt,name=w,proto3" json:"w,omitempty"` + BarG1 *amcl.ECP `protobuf:"bytes,6,opt,name=bar_g1,json=barG1,proto3" json:"bar_g1,omitempty"` + BarG2 *amcl.ECP `protobuf:"bytes,7,opt,name=bar_g2,json=barG2,proto3" json:"bar_g2,omitempty"` + ProofC []byte `protobuf:"bytes,8,opt,name=proof_c,json=proofC,proto3" json:"proof_c,omitempty"` + ProofS []byte `protobuf:"bytes,9,opt,name=proof_s,json=proofS,proto3" json:"proof_s,omitempty"` + Hash []byte `protobuf:"bytes,10,opt,name=hash,proto3" json:"hash,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *IssuerPublicKey) Reset() { *m = IssuerPublicKey{} } func (m *IssuerPublicKey) String() string { return proto.CompactTextString(m) } func (*IssuerPublicKey) ProtoMessage() {} func (*IssuerPublicKey) Descriptor() ([]byte, []int) { - return fileDescriptor_28d23908e9a304c6, []int{2} + return fileDescriptor_7f94c3d451691341, []int{0} } func (m *IssuerPublicKey) XXX_Unmarshal(b []byte) error { @@ -187,42 +74,42 @@ func (m *IssuerPublicKey) GetAttributeNames() []string { return nil } -func (m *IssuerPublicKey) GetHSk() *ECP { +func (m *IssuerPublicKey) GetHSk() *amcl.ECP { if m != nil { return m.HSk } return nil } -func (m *IssuerPublicKey) GetHRand() *ECP { +func (m *IssuerPublicKey) GetHRand() *amcl.ECP { if m != nil { return m.HRand } return nil } -func (m *IssuerPublicKey) GetHAttrs() []*ECP { +func (m *IssuerPublicKey) GetHAttrs() []*amcl.ECP { if m != nil { return m.HAttrs } return nil } -func (m *IssuerPublicKey) GetW() *ECP2 { +func (m *IssuerPublicKey) GetW() *amcl.ECP2 { if m != nil { return m.W } return nil } -func (m *IssuerPublicKey) GetBarG1() *ECP { +func (m *IssuerPublicKey) GetBarG1() *amcl.ECP { if m != nil { return m.BarG1 } return nil } -func (m *IssuerPublicKey) GetBarG2() *ECP { +func (m *IssuerPublicKey) GetBarG2() *amcl.ECP { if m != nil { return m.BarG2 } @@ -265,7 +152,7 @@ func (m *IssuerKey) Reset() { *m = IssuerKey{} } func (m *IssuerKey) String() string { return proto.CompactTextString(m) } func (*IssuerKey) ProtoMessage() {} func (*IssuerKey) Descriptor() ([]byte, []int) { - return fileDescriptor_28d23908e9a304c6, []int{3} + return fileDescriptor_7f94c3d451691341, []int{1} } func (m *IssuerKey) XXX_Unmarshal(b []byte) error { @@ -304,21 +191,21 @@ func (m *IssuerKey) GetIpk() *IssuerPublicKey { // a, b, e, s - signature value // attrs - attribute values type Credential struct { - A *ECP `protobuf:"bytes,1,opt,name=a,proto3" json:"a,omitempty"` - B *ECP `protobuf:"bytes,2,opt,name=b,proto3" json:"b,omitempty"` - E []byte `protobuf:"bytes,3,opt,name=e,proto3" json:"e,omitempty"` - S []byte `protobuf:"bytes,4,opt,name=s,proto3" json:"s,omitempty"` - Attrs [][]byte `protobuf:"bytes,5,rep,name=attrs,proto3" json:"attrs,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + A *amcl.ECP `protobuf:"bytes,1,opt,name=a,proto3" json:"a,omitempty"` + B *amcl.ECP `protobuf:"bytes,2,opt,name=b,proto3" json:"b,omitempty"` + E []byte `protobuf:"bytes,3,opt,name=e,proto3" json:"e,omitempty"` + S []byte `protobuf:"bytes,4,opt,name=s,proto3" json:"s,omitempty"` + Attrs [][]byte `protobuf:"bytes,5,rep,name=attrs,proto3" json:"attrs,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *Credential) Reset() { *m = Credential{} } func (m *Credential) String() string { return proto.CompactTextString(m) } func (*Credential) ProtoMessage() {} func (*Credential) Descriptor() ([]byte, []int) { - return fileDescriptor_28d23908e9a304c6, []int{4} + return fileDescriptor_7f94c3d451691341, []int{2} } func (m *Credential) XXX_Unmarshal(b []byte) error { @@ -339,14 +226,14 @@ func (m *Credential) XXX_DiscardUnknown() { var xxx_messageInfo_Credential proto.InternalMessageInfo -func (m *Credential) GetA() *ECP { +func (m *Credential) GetA() *amcl.ECP { if m != nil { return m.A } return nil } -func (m *Credential) GetB() *ECP { +func (m *Credential) GetB() *amcl.ECP { if m != nil { return m.B } @@ -380,20 +267,20 @@ func (m *Credential) GetAttrs() [][]byte { // proof_c, proof_s - a zero-knowledge proof of knowledge of the // user secret inside Nym type CredRequest struct { - Nym *ECP `protobuf:"bytes,1,opt,name=nym,proto3" json:"nym,omitempty"` - IssuerNonce []byte `protobuf:"bytes,2,opt,name=issuer_nonce,json=issuerNonce,proto3" json:"issuer_nonce,omitempty"` - ProofC []byte `protobuf:"bytes,3,opt,name=proof_c,json=proofC,proto3" json:"proof_c,omitempty"` - ProofS []byte `protobuf:"bytes,4,opt,name=proof_s,json=proofS,proto3" json:"proof_s,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Nym *amcl.ECP `protobuf:"bytes,1,opt,name=nym,proto3" json:"nym,omitempty"` + IssuerNonce []byte `protobuf:"bytes,2,opt,name=issuer_nonce,json=issuerNonce,proto3" json:"issuer_nonce,omitempty"` + ProofC []byte `protobuf:"bytes,3,opt,name=proof_c,json=proofC,proto3" json:"proof_c,omitempty"` + ProofS []byte `protobuf:"bytes,4,opt,name=proof_s,json=proofS,proto3" json:"proof_s,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *CredRequest) Reset() { *m = CredRequest{} } func (m *CredRequest) String() string { return proto.CompactTextString(m) } func (*CredRequest) ProtoMessage() {} func (*CredRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_28d23908e9a304c6, []int{5} + return fileDescriptor_7f94c3d451691341, []int{3} } func (m *CredRequest) XXX_Unmarshal(b []byte) error { @@ -414,7 +301,7 @@ func (m *CredRequest) XXX_DiscardUnknown() { var xxx_messageInfo_CredRequest proto.InternalMessageInfo -func (m *CredRequest) GetNym() *ECP { +func (m *CredRequest) GetNym() *amcl.ECP { if m != nil { return m.Nym } @@ -442,6 +329,53 @@ func (m *CredRequest) GetProofS() []byte { return nil } +type EIDNym struct { + Nym *amcl.ECP `protobuf:"bytes,1,opt,name=nym,proto3" json:"nym,omitempty"` + ProofSEid []byte `protobuf:"bytes,2,opt,name=proof_s_eid,json=proofSEid,proto3" json:"proof_s_eid,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *EIDNym) Reset() { *m = EIDNym{} } +func (m *EIDNym) String() string { return proto.CompactTextString(m) } +func (*EIDNym) ProtoMessage() {} +func (*EIDNym) Descriptor() ([]byte, []int) { + return fileDescriptor_7f94c3d451691341, []int{4} +} + +func (m *EIDNym) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_EIDNym.Unmarshal(m, b) +} +func (m *EIDNym) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_EIDNym.Marshal(b, m, deterministic) +} +func (m *EIDNym) XXX_Merge(src proto.Message) { + xxx_messageInfo_EIDNym.Merge(m, src) +} +func (m *EIDNym) XXX_Size() int { + return xxx_messageInfo_EIDNym.Size(m) +} +func (m *EIDNym) XXX_DiscardUnknown() { + xxx_messageInfo_EIDNym.DiscardUnknown(m) +} + +var xxx_messageInfo_EIDNym proto.InternalMessageInfo + +func (m *EIDNym) GetNym() *amcl.ECP { + if m != nil { + return m.Nym + } + return nil +} + +func (m *EIDNym) GetProofSEid() []byte { + if m != nil { + return m.ProofSEid + } + return nil +} + // Signature specifies a signature object that consists of // a_prime, a_bar, b_prime, proof_* - randomized credential signature values // and a zero-knowledge proof of knowledge of a credential @@ -449,9 +383,9 @@ func (m *CredRequest) GetProofS() []byte { // nonce - a fresh nonce used for the signature // nym - a fresh pseudonym (a commitment to to the user secret) type Signature struct { - APrime *ECP `protobuf:"bytes,1,opt,name=a_prime,json=aPrime,proto3" json:"a_prime,omitempty"` - ABar *ECP `protobuf:"bytes,2,opt,name=a_bar,json=aBar,proto3" json:"a_bar,omitempty"` - BPrime *ECP `protobuf:"bytes,3,opt,name=b_prime,json=bPrime,proto3" json:"b_prime,omitempty"` + APrime *amcl.ECP `protobuf:"bytes,1,opt,name=a_prime,json=aPrime,proto3" json:"a_prime,omitempty"` + ABar *amcl.ECP `protobuf:"bytes,2,opt,name=a_bar,json=aBar,proto3" json:"a_bar,omitempty"` + BPrime *amcl.ECP `protobuf:"bytes,3,opt,name=b_prime,json=bPrime,proto3" json:"b_prime,omitempty"` ProofC []byte `protobuf:"bytes,4,opt,name=proof_c,json=proofC,proto3" json:"proof_c,omitempty"` ProofSSk []byte `protobuf:"bytes,5,opt,name=proof_s_sk,json=proofSSk,proto3" json:"proof_s_sk,omitempty"` ProofSE []byte `protobuf:"bytes,6,opt,name=proof_s_e,json=proofSE,proto3" json:"proof_s_e,omitempty"` @@ -460,12 +394,13 @@ type Signature struct { ProofSSPrime []byte `protobuf:"bytes,9,opt,name=proof_s_s_prime,json=proofSSPrime,proto3" json:"proof_s_s_prime,omitempty"` ProofSAttrs [][]byte `protobuf:"bytes,10,rep,name=proof_s_attrs,json=proofSAttrs,proto3" json:"proof_s_attrs,omitempty"` Nonce []byte `protobuf:"bytes,11,opt,name=nonce,proto3" json:"nonce,omitempty"` - Nym *ECP `protobuf:"bytes,12,opt,name=nym,proto3" json:"nym,omitempty"` + Nym *amcl.ECP `protobuf:"bytes,12,opt,name=nym,proto3" json:"nym,omitempty"` ProofSRNym []byte `protobuf:"bytes,13,opt,name=proof_s_r_nym,json=proofSRNym,proto3" json:"proof_s_r_nym,omitempty"` - RevocationEpochPk *ECP2 `protobuf:"bytes,14,opt,name=revocation_epoch_pk,json=revocationEpochPk,proto3" json:"revocation_epoch_pk,omitempty"` + RevocationEpochPk *amcl.ECP2 `protobuf:"bytes,14,opt,name=revocation_epoch_pk,json=revocationEpochPk,proto3" json:"revocation_epoch_pk,omitempty"` RevocationPkSig []byte `protobuf:"bytes,15,opt,name=revocation_pk_sig,json=revocationPkSig,proto3" json:"revocation_pk_sig,omitempty"` Epoch int64 `protobuf:"varint,16,opt,name=epoch,proto3" json:"epoch,omitempty"` NonRevocationProof *NonRevocationProof `protobuf:"bytes,17,opt,name=non_revocation_proof,json=nonRevocationProof,proto3" json:"non_revocation_proof,omitempty"` + EidNym *EIDNym `protobuf:"bytes,18,opt,name=eid_nym,json=eidNym,proto3" json:"eid_nym,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -475,7 +410,7 @@ func (m *Signature) Reset() { *m = Signature{} } func (m *Signature) String() string { return proto.CompactTextString(m) } func (*Signature) ProtoMessage() {} func (*Signature) Descriptor() ([]byte, []int) { - return fileDescriptor_28d23908e9a304c6, []int{6} + return fileDescriptor_7f94c3d451691341, []int{5} } func (m *Signature) XXX_Unmarshal(b []byte) error { @@ -496,21 +431,21 @@ func (m *Signature) XXX_DiscardUnknown() { var xxx_messageInfo_Signature proto.InternalMessageInfo -func (m *Signature) GetAPrime() *ECP { +func (m *Signature) GetAPrime() *amcl.ECP { if m != nil { return m.APrime } return nil } -func (m *Signature) GetABar() *ECP { +func (m *Signature) GetABar() *amcl.ECP { if m != nil { return m.ABar } return nil } -func (m *Signature) GetBPrime() *ECP { +func (m *Signature) GetBPrime() *amcl.ECP { if m != nil { return m.BPrime } @@ -573,7 +508,7 @@ func (m *Signature) GetNonce() []byte { return nil } -func (m *Signature) GetNym() *ECP { +func (m *Signature) GetNym() *amcl.ECP { if m != nil { return m.Nym } @@ -587,7 +522,7 @@ func (m *Signature) GetProofSRNym() []byte { return nil } -func (m *Signature) GetRevocationEpochPk() *ECP2 { +func (m *Signature) GetRevocationEpochPk() *amcl.ECP2 { if m != nil { return m.RevocationEpochPk } @@ -615,6 +550,13 @@ func (m *Signature) GetNonRevocationProof() *NonRevocationProof { return nil } +func (m *Signature) GetEidNym() *EIDNym { + if m != nil { + return m.EidNym + } + return nil +} + // NonRevocationProof contains proof that the credential is not revoked type NonRevocationProof struct { RevocationAlg int32 `protobuf:"varint,1,opt,name=revocation_alg,json=revocationAlg,proto3" json:"revocation_alg,omitempty"` @@ -628,7 +570,7 @@ func (m *NonRevocationProof) Reset() { *m = NonRevocationProof{} } func (m *NonRevocationProof) String() string { return proto.CompactTextString(m) } func (*NonRevocationProof) ProtoMessage() {} func (*NonRevocationProof) Descriptor() ([]byte, []int) { - return fileDescriptor_28d23908e9a304c6, []int{7} + return fileDescriptor_7f94c3d451691341, []int{6} } func (m *NonRevocationProof) XXX_Unmarshal(b []byte) error { @@ -686,7 +628,7 @@ func (m *NymSignature) Reset() { *m = NymSignature{} } func (m *NymSignature) String() string { return proto.CompactTextString(m) } func (*NymSignature) ProtoMessage() {} func (*NymSignature) Descriptor() ([]byte, []int) { - return fileDescriptor_28d23908e9a304c6, []int{8} + return fileDescriptor_7f94c3d451691341, []int{7} } func (m *NymSignature) XXX_Unmarshal(b []byte) error { @@ -739,7 +681,7 @@ type CredentialRevocationInformation struct { // epoch contains the epoch (time window) in which this CRI is valid Epoch int64 `protobuf:"varint,1,opt,name=epoch,proto3" json:"epoch,omitempty"` // epoch_pk is the public key that is used by the revocation authority in this epoch - EpochPk *ECP2 `protobuf:"bytes,2,opt,name=epoch_pk,json=epochPk,proto3" json:"epoch_pk,omitempty"` + EpochPk *amcl.ECP2 `protobuf:"bytes,2,opt,name=epoch_pk,json=epochPk,proto3" json:"epoch_pk,omitempty"` // epoch_pk_sig is a signature on the EpochPK valid under the revocation authority's long term key EpochPkSig []byte `protobuf:"bytes,3,opt,name=epoch_pk_sig,json=epochPkSig,proto3" json:"epoch_pk_sig,omitempty"` // revocation_alg denotes which revocation algorithm is used @@ -755,7 +697,7 @@ func (m *CredentialRevocationInformation) Reset() { *m = CredentialRevoc func (m *CredentialRevocationInformation) String() string { return proto.CompactTextString(m) } func (*CredentialRevocationInformation) ProtoMessage() {} func (*CredentialRevocationInformation) Descriptor() ([]byte, []int) { - return fileDescriptor_28d23908e9a304c6, []int{9} + return fileDescriptor_7f94c3d451691341, []int{8} } func (m *CredentialRevocationInformation) XXX_Unmarshal(b []byte) error { @@ -783,7 +725,7 @@ func (m *CredentialRevocationInformation) GetEpoch() int64 { return 0 } -func (m *CredentialRevocationInformation) GetEpochPk() *ECP2 { +func (m *CredentialRevocationInformation) GetEpochPk() *amcl.ECP2 { if m != nil { return m.EpochPk } @@ -812,71 +754,75 @@ func (m *CredentialRevocationInformation) GetRevocationData() []byte { } func init() { - proto.RegisterType((*ECP)(nil), "ECP") - proto.RegisterType((*ECP2)(nil), "ECP2") - proto.RegisterType((*IssuerPublicKey)(nil), "IssuerPublicKey") - proto.RegisterType((*IssuerKey)(nil), "IssuerKey") - proto.RegisterType((*Credential)(nil), "Credential") - proto.RegisterType((*CredRequest)(nil), "CredRequest") - proto.RegisterType((*Signature)(nil), "Signature") - proto.RegisterType((*NonRevocationProof)(nil), "NonRevocationProof") - proto.RegisterType((*NymSignature)(nil), "NymSignature") - proto.RegisterType((*CredentialRevocationInformation)(nil), "CredentialRevocationInformation") -} - -func init() { proto.RegisterFile("idemix.proto", fileDescriptor_28d23908e9a304c6) } - -var fileDescriptor_28d23908e9a304c6 = []byte{ - // 814 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x55, 0xcb, 0x8e, 0xe2, 0x46, - 0x14, 0x55, 0x61, 0x9b, 0x6e, 0x2e, 0xee, 0xa6, 0xa7, 0xba, 0x95, 0xa9, 0xbc, 0x14, 0xc6, 0xca, - 0x64, 0x5a, 0x59, 0xd0, 0x19, 0x5a, 0xf9, 0x80, 0x1e, 0x42, 0xa2, 0x51, 0x24, 0x84, 0xcc, 0x2e, - 0x9b, 0x52, 0x15, 0x14, 0xd8, 0x02, 0xdb, 0xa4, 0x6c, 0x32, 0x38, 0x8b, 0x7c, 0x4d, 0xfe, 0x26, - 0x8b, 0xfc, 0x52, 0x54, 0x0f, 0x70, 0xd1, 0xcc, 0x64, 0xe7, 0x7b, 0xcf, 0x7d, 0x71, 0xce, 0x31, - 0x86, 0x30, 0x5d, 0x88, 0x2c, 0xdd, 0x0f, 0xb6, 0xb2, 0xa8, 0x8a, 0xe8, 0x15, 0x78, 0xe3, 0xd1, - 0x14, 0x87, 0x80, 0xf6, 0x04, 0xf5, 0xd1, 0x7d, 0x18, 0xa3, 0xbd, 0x8a, 0x6a, 0xd2, 0x32, 0x51, - 0x1d, 0xfd, 0x0c, 0xfe, 0x78, 0x34, 0x1d, 0xe2, 0x6b, 0x68, 0xed, 0x99, 0x2d, 0x6a, 0xed, 0x99, - 0x8e, 0xb9, 0x2d, 0x6b, 0xed, 0xb9, 0x8a, 0x6b, 0x46, 0x3c, 0x13, 0xd7, 0x1a, 0xaf, 0x39, 0xf1, - 0x6d, 0xcc, 0xa3, 0xbf, 0x5b, 0xd0, 0x7b, 0x5f, 0x96, 0x3b, 0x21, 0xa7, 0x3b, 0xbe, 0x49, 0xe7, - 0xbf, 0x8a, 0x1a, 0xbf, 0x81, 0x1e, 0xab, 0x2a, 0x99, 0xf2, 0x5d, 0x25, 0x68, 0xce, 0x32, 0x51, - 0x12, 0xd4, 0xf7, 0xee, 0x3b, 0xf1, 0xf5, 0x31, 0x3d, 0x51, 0x59, 0xfc, 0x12, 0xfc, 0x84, 0x96, - 0x6b, 0xbd, 0xae, 0x3b, 0xf4, 0x07, 0xe3, 0xd1, 0x34, 0xf6, 0x92, 0xd9, 0x1a, 0x7f, 0x09, 0xed, - 0x84, 0x4a, 0x96, 0x2f, 0xf4, 0xe6, 0x03, 0x14, 0x24, 0x31, 0xcb, 0x17, 0xf8, 0x6b, 0xb8, 0x48, - 0xa8, 0x9a, 0x54, 0x12, 0xbf, 0xef, 0x1d, 0xd1, 0x76, 0xf2, 0xa4, 0x72, 0xf8, 0x16, 0xd0, 0x07, - 0x12, 0xe8, 0xb6, 0x40, 0x01, 0xc3, 0x18, 0x7d, 0x50, 0x03, 0x39, 0x93, 0x74, 0xf5, 0x96, 0xb4, - 0xdd, 0x81, 0x9c, 0xc9, 0x5f, 0xde, 0x1e, 0xc1, 0x21, 0xb9, 0x78, 0x0e, 0x0e, 0xf1, 0x4b, 0xb8, - 0xd8, 0xca, 0xa2, 0x58, 0xd2, 0x39, 0xb9, 0xd4, 0xbf, 0xba, 0xad, 0xc3, 0x51, 0x03, 0x94, 0xa4, - 0xe3, 0x00, 0x33, 0x8c, 0xc1, 0x4f, 0x58, 0x99, 0x10, 0xd0, 0x59, 0xfd, 0x1c, 0x3d, 0x41, 0xc7, - 0xb0, 0xa4, 0xf8, 0xb9, 0x01, 0x2f, 0x2d, 0xd7, 0x96, 0x74, 0xf5, 0x88, 0x23, 0xf0, 0xd2, 0xed, - 0x81, 0x87, 0x9b, 0xc1, 0x33, 0x42, 0x63, 0x05, 0x46, 0x4b, 0x80, 0x91, 0x14, 0x0b, 0x91, 0x57, - 0x29, 0xdb, 0x60, 0x0c, 0xc8, 0xc8, 0x76, 0x38, 0x17, 0x31, 0x95, 0xe3, 0x27, 0x5c, 0x22, 0xae, - 0x54, 0x17, 0x56, 0x3e, 0x24, 0x54, 0x54, 0x5a, 0xf1, 0x50, 0x89, 0xef, 0x20, 0x30, 0x34, 0x06, - 0x7d, 0xef, 0x3e, 0x8c, 0x4d, 0x10, 0xfd, 0x09, 0x5d, 0xb5, 0x27, 0x16, 0xbf, 0xef, 0x44, 0x59, - 0xe1, 0xcf, 0xc0, 0xcb, 0xeb, 0xec, 0x64, 0x95, 0x4a, 0xe0, 0x57, 0x10, 0xa6, 0xfa, 0x4c, 0x9a, - 0x17, 0xf9, 0x5c, 0x58, 0xcb, 0x74, 0x4d, 0x6e, 0xa2, 0x52, 0x2e, 0x75, 0xde, 0xa7, 0xa8, 0xf3, - 0x5d, 0xea, 0xa2, 0x7f, 0x7d, 0xe8, 0xcc, 0xd2, 0x55, 0xce, 0xaa, 0x9d, 0x14, 0x4a, 0x68, 0x46, - 0xb7, 0x32, 0xcd, 0xc4, 0xc9, 0xfa, 0x36, 0x9b, 0xaa, 0x1c, 0xfe, 0x1c, 0x02, 0x46, 0x39, 0x93, - 0x27, 0x3f, 0xd9, 0x67, 0xef, 0x98, 0x54, 0x9d, 0xdc, 0x76, 0xba, 0x06, 0x6a, 0x73, 0xd3, 0xe9, - 0x1c, 0xe6, 0x9f, 0x1c, 0xf6, 0x15, 0x80, 0x3d, 0x4c, 0xd9, 0x32, 0xd0, 0xd8, 0xa5, 0xb9, 0x6d, - 0xb6, 0xc6, 0x5f, 0x40, 0xe7, 0x80, 0x0a, 0xed, 0xa3, 0x30, 0x36, 0x73, 0x66, 0x63, 0xb7, 0x53, - 0x1a, 0x1f, 0x1d, 0x3b, 0xe3, 0xe1, 0x09, 0xfa, 0x68, 0x7d, 0x74, 0x40, 0x1f, 0xf1, 0x6b, 0xe8, - 0x1d, 0xb7, 0xda, 0xab, 0x8d, 0xa3, 0x42, 0xbb, 0xda, 0x5c, 0x1d, 0xc1, 0xd5, 0xa1, 0xcc, 0xc8, - 0x06, 0x5a, 0xb6, 0xae, 0x29, 0x32, 0xe6, 0xbf, 0x83, 0xc0, 0xc8, 0xd1, 0xd5, 0x03, 0x4c, 0x70, - 0xd0, 0x30, 0x3c, 0xd7, 0xf0, 0x38, 0x51, 0x52, 0x55, 0x71, 0xa5, 0xbb, 0xc0, 0x5e, 0x36, 0xa9, - 0x33, 0xfc, 0x23, 0xdc, 0x4a, 0xf1, 0x47, 0x31, 0x67, 0x55, 0x5a, 0xe4, 0x54, 0x6c, 0x8b, 0x79, - 0x42, 0xb7, 0x6b, 0x72, 0xed, 0xbe, 0x5f, 0x2f, 0x9a, 0x8a, 0xb1, 0x2a, 0x98, 0xae, 0xf1, 0xf7, - 0xe0, 0x24, 0xe9, 0x76, 0x4d, 0xcb, 0x74, 0x45, 0x7a, 0x7a, 0x7a, 0xaf, 0x01, 0xa6, 0xeb, 0x59, - 0xba, 0x52, 0x37, 0xeb, 0xb9, 0xe4, 0xa6, 0x8f, 0xee, 0xbd, 0xd8, 0x04, 0x78, 0x0c, 0x77, 0x79, - 0x91, 0x53, 0x77, 0x8a, 0xba, 0x8a, 0xbc, 0xd0, 0x9b, 0x6f, 0x07, 0x93, 0x22, 0x8f, 0x9b, 0x41, - 0x0a, 0x8a, 0x71, 0x7e, 0x96, 0x8b, 0x32, 0xc0, 0xe7, 0x95, 0xf8, 0x35, 0x5c, 0x3b, 0x83, 0xd9, - 0x66, 0xa5, 0x0d, 0x16, 0xc4, 0x57, 0x4d, 0xf6, 0x69, 0xb3, 0xc2, 0x3f, 0x7c, 0xe2, 0x06, 0xe3, - 0xf5, 0x8f, 0xad, 0xfb, 0x0b, 0xc2, 0x49, 0x9d, 0x35, 0x16, 0x76, 0x9c, 0x86, 0xfe, 0xc7, 0x69, - 0xad, 0x67, 0x4e, 0x3b, 0x13, 0xc6, 0x3b, 0x13, 0xe6, 0xa8, 0xb4, 0xef, 0x28, 0x1d, 0xfd, 0x83, - 0xe0, 0x9b, 0xe6, 0x5f, 0xa2, 0xb9, 0xee, 0x7d, 0xbe, 0x2c, 0x64, 0xa6, 0x1f, 0x1b, 0xbe, 0x91, - 0xcb, 0x77, 0x1f, 0x2e, 0x8f, 0xea, 0xb6, 0x5c, 0x75, 0x2f, 0x84, 0xd5, 0xb4, 0x0f, 0xe1, 0xa1, - 0x42, 0xcb, 0x69, 0x6f, 0xb2, 0xb0, 0x52, 0xf2, 0x9c, 0x56, 0xff, 0x63, 0xb4, 0xbe, 0x01, 0xc7, - 0x03, 0x74, 0xc1, 0x2a, 0x66, 0x5f, 0x35, 0xa7, 0xfb, 0x27, 0x56, 0xb1, 0x77, 0xdf, 0xfd, 0xf6, - 0xed, 0x2a, 0xad, 0x92, 0x1d, 0x1f, 0xcc, 0x8b, 0xec, 0x21, 0xa9, 0xb7, 0x42, 0x6e, 0xc4, 0x62, - 0x25, 0xe4, 0xc3, 0x92, 0x71, 0x99, 0xce, 0x1f, 0xcc, 0x57, 0x8f, 0xb7, 0xf5, 0x67, 0xef, 0xf1, - 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1c, 0xca, 0x29, 0x38, 0x06, 0x07, 0x00, 0x00, + proto.RegisterType((*IssuerPublicKey)(nil), "idemix.IssuerPublicKey") + proto.RegisterType((*IssuerKey)(nil), "idemix.IssuerKey") + proto.RegisterType((*Credential)(nil), "idemix.Credential") + proto.RegisterType((*CredRequest)(nil), "idemix.CredRequest") + proto.RegisterType((*EIDNym)(nil), "idemix.EIDNym") + proto.RegisterType((*Signature)(nil), "idemix.Signature") + proto.RegisterType((*NonRevocationProof)(nil), "idemix.NonRevocationProof") + proto.RegisterType((*NymSignature)(nil), "idemix.NymSignature") + proto.RegisterType((*CredentialRevocationInformation)(nil), "idemix.CredentialRevocationInformation") +} + +func init() { + proto.RegisterFile("bccsp/schemes/dlog/crypto/idemix.proto", fileDescriptor_7f94c3d451691341) +} + +var fileDescriptor_7f94c3d451691341 = []byte{ + // 860 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x55, 0xcd, 0x6e, 0xe3, 0x36, + 0x10, 0x86, 0x22, 0x5b, 0x8e, 0xc7, 0x4a, 0xbc, 0xcb, 0x06, 0x88, 0x90, 0x2e, 0xb6, 0xae, 0x80, + 0x34, 0x6e, 0x0f, 0x71, 0xe3, 0xf4, 0xd4, 0xdb, 0x26, 0x6b, 0xb4, 0x41, 0x5b, 0xc3, 0xa0, 0x6f, + 0xbd, 0x10, 0x94, 0xc4, 0xb5, 0x08, 0x59, 0x3f, 0x25, 0xe5, 0x6e, 0x7d, 0x69, 0x5f, 0xa3, 0xcf, + 0xd3, 0x27, 0xe8, 0x23, 0x2d, 0x48, 0xca, 0x92, 0x12, 0x25, 0x7b, 0x31, 0xc4, 0x99, 0xe1, 0x37, + 0x1f, 0xbf, 0xf9, 0x68, 0xc2, 0x37, 0x41, 0x18, 0xca, 0x62, 0x26, 0xc3, 0x98, 0xa5, 0x4c, 0xce, + 0xa2, 0x6d, 0xbe, 0x99, 0x85, 0x62, 0x5f, 0x94, 0xf9, 0x8c, 0x47, 0x2c, 0xe5, 0x7f, 0x5d, 0x17, + 0x22, 0x2f, 0x73, 0xe4, 0x98, 0xd5, 0xc5, 0x0f, 0x2f, 0xd7, 0x97, 0x82, 0x66, 0x72, 0x4b, 0xcb, + 0x5c, 0xcc, 0x68, 0x1a, 0x6e, 0xf5, 0x8f, 0xd9, 0xed, 0xff, 0x77, 0x04, 0xe3, 0x07, 0x29, 0x77, + 0x4c, 0xac, 0x76, 0xc1, 0x96, 0x87, 0xbf, 0xb0, 0x3d, 0xba, 0x82, 0x31, 0x2d, 0x4b, 0xc1, 0x83, + 0x5d, 0xc9, 0x48, 0x46, 0x53, 0x26, 0x3d, 0x6b, 0x62, 0x4f, 0x87, 0xf8, 0xb4, 0x0e, 0x2f, 0x55, + 0x14, 0xbd, 0x81, 0x5e, 0x4c, 0x64, 0xe2, 0x1d, 0x4d, 0xac, 0xe9, 0x68, 0x3e, 0xbc, 0xd6, 0xb8, + 0x8b, 0xfb, 0x15, 0xb6, 0xe3, 0x75, 0x82, 0x26, 0xe0, 0xc4, 0x44, 0xd0, 0x2c, 0xf2, 0xec, 0xa7, + 0xf9, 0x7e, 0x8c, 0x69, 0x16, 0x21, 0x1f, 0x06, 0x31, 0x51, 0x98, 0xd2, 0xeb, 0x4d, 0xec, 0xc7, + 0x25, 0x4e, 0xfc, 0x4e, 0x25, 0x90, 0x07, 0xd6, 0x47, 0xaf, 0xaf, 0x01, 0xa0, 0xce, 0xce, 0xb1, + 0xf5, 0x51, 0xe1, 0x07, 0x54, 0x90, 0xcd, 0x8d, 0xe7, 0x74, 0xf0, 0x03, 0x2a, 0x7e, 0xba, 0xa9, + 0x2b, 0xe6, 0xde, 0xe0, 0xd9, 0x8a, 0x39, 0x3a, 0x87, 0x41, 0x21, 0xf2, 0xfc, 0x03, 0x09, 0xbd, + 0xe3, 0x89, 0x35, 0x75, 0xb1, 0xa3, 0x97, 0xf7, 0x4d, 0x42, 0x7a, 0xc3, 0x56, 0x62, 0x8d, 0x10, + 0xf4, 0x62, 0x2a, 0x63, 0x0f, 0x74, 0x54, 0x7f, 0xfb, 0x3f, 0xc3, 0xd0, 0x68, 0xa8, 0xd4, 0x7b, + 0x05, 0x36, 0x97, 0x89, 0x67, 0xe9, 0xbc, 0xfa, 0x44, 0xdf, 0x82, 0xcd, 0x8b, 0x83, 0x4a, 0xe7, + 0xd7, 0xd5, 0xf4, 0x9e, 0xa8, 0x8e, 0x55, 0x8d, 0x5f, 0x00, 0xdc, 0x0b, 0x16, 0xb1, 0xac, 0xe4, + 0x74, 0x8b, 0xce, 0xc1, 0xa2, 0x1a, 0xe8, 0x11, 0x75, 0x8b, 0xaa, 0x44, 0xd0, 0x55, 0xdd, 0x0a, + 0x90, 0x0b, 0x16, 0xd3, 0x72, 0xbb, 0xd8, 0x62, 0x6a, 0xa5, 0x94, 0xd5, 0x2b, 0x89, 0xce, 0xa0, + 0x6f, 0xb4, 0xee, 0x4f, 0xec, 0xa9, 0x8b, 0xcd, 0xc2, 0xff, 0x07, 0x46, 0xaa, 0x23, 0x66, 0x7f, + 0xec, 0x98, 0x2c, 0xd1, 0x97, 0x60, 0x67, 0xfb, 0xb4, 0xdb, 0x54, 0x45, 0xd1, 0xd7, 0xe0, 0x72, + 0xcd, 0x9a, 0x64, 0x79, 0x16, 0x32, 0xcd, 0xc0, 0xc5, 0x23, 0x13, 0x5b, 0xaa, 0x50, 0x5b, 0x50, + 0xfb, 0x25, 0x41, 0x7b, 0x6d, 0x41, 0xfd, 0x05, 0x38, 0x8b, 0x87, 0xf7, 0xcb, 0x7d, 0xfa, 0xf9, + 0xde, 0x6f, 0x61, 0x54, 0xed, 0x27, 0x8c, 0x47, 0x55, 0xeb, 0xa1, 0xc1, 0x58, 0xf0, 0xc8, 0xff, + 0xb7, 0x0f, 0xc3, 0x35, 0xdf, 0x64, 0xb4, 0xdc, 0x09, 0xa6, 0x9c, 0x45, 0x49, 0x21, 0x78, 0xca, + 0xba, 0x70, 0x0e, 0x5d, 0xa9, 0x04, 0x7a, 0x0b, 0x7d, 0x4a, 0x02, 0x2a, 0xba, 0x42, 0xf6, 0xe8, + 0x1d, 0x15, 0x0a, 0x23, 0xa8, 0x30, 0x3a, 0x06, 0x76, 0x02, 0x83, 0xd1, 0x3a, 0x6e, 0xef, 0xd1, + 0x71, 0xdf, 0x00, 0x1c, 0xe8, 0xca, 0x44, 0xfb, 0xd7, 0xc5, 0xc7, 0x86, 0xed, 0x3a, 0x41, 0x17, + 0x30, 0xac, 0x0f, 0xa3, 0xdd, 0xeb, 0xe2, 0x41, 0x75, 0x94, 0xf6, 0x4e, 0x61, 0x8c, 0x5b, 0xef, + 0xc4, 0xf3, 0x47, 0xd9, 0xdb, 0xca, 0xb3, 0x87, 0xec, 0x2d, 0xba, 0x84, 0x71, 0xdd, 0xb5, 0xa2, + 0x6e, 0xdc, 0xeb, 0x56, 0xad, 0x0d, 0x6b, 0x1f, 0x4e, 0x0e, 0x65, 0xc6, 0x11, 0xa0, 0x1d, 0x61, + 0x04, 0x5e, 0x9b, 0x7b, 0x77, 0x06, 0x7d, 0x33, 0xe4, 0x91, 0x06, 0x30, 0x8b, 0xc3, 0x88, 0xdc, + 0x17, 0xec, 0x51, 0xc3, 0x0a, 0xa2, 0xca, 0x4e, 0xf4, 0x56, 0xa8, 0xe8, 0xa9, 0x11, 0xff, 0x08, + 0x5f, 0x08, 0xf6, 0x67, 0x1e, 0xd2, 0x92, 0xe7, 0x19, 0x61, 0x45, 0x1e, 0xc6, 0xa4, 0x48, 0xbc, + 0xd3, 0xce, 0xfd, 0x7e, 0xdd, 0x94, 0x2d, 0x54, 0xd5, 0x2a, 0x41, 0xdf, 0x41, 0x2b, 0x48, 0x8a, + 0x84, 0x48, 0xbe, 0xf1, 0xc6, 0xba, 0xc5, 0xb8, 0x49, 0xac, 0x92, 0x35, 0xdf, 0x28, 0xf6, 0x1a, + 0xdc, 0x7b, 0x35, 0xb1, 0xa6, 0x36, 0x36, 0x0b, 0xf4, 0x2b, 0x9c, 0x65, 0x79, 0x46, 0xda, 0x28, + 0x8a, 0x9a, 0xf7, 0x5a, 0xb7, 0xbf, 0x38, 0xdc, 0xcc, 0x65, 0x9e, 0xe1, 0x06, 0x4f, 0x55, 0x60, + 0x94, 0x75, 0x62, 0xe8, 0x0a, 0x06, 0x8c, 0x47, 0xfa, 0xa0, 0x48, 0x03, 0x9c, 0x1e, 0x00, 0x8c, + 0x9f, 0xb1, 0xc3, 0x78, 0xb4, 0xdc, 0xa7, 0x7e, 0x0a, 0xa8, 0x0b, 0x89, 0x2e, 0xe1, 0xb4, 0x45, + 0x84, 0x6e, 0x37, 0xda, 0xa9, 0x7d, 0x7c, 0xd2, 0x44, 0xdf, 0x6d, 0x37, 0xe8, 0xfb, 0x17, 0x38, + 0x9b, 0x0b, 0xf0, 0x0c, 0x2f, 0xff, 0x6f, 0x70, 0x97, 0xfb, 0xb4, 0xb9, 0x0b, 0x2d, 0x8f, 0x5a, + 0x9f, 0xf1, 0xe8, 0xd1, 0x13, 0x8f, 0x76, 0xa6, 0x69, 0x77, 0xa6, 0x59, 0x7b, 0xa4, 0xd7, 0xf2, + 0x88, 0xff, 0xbf, 0x05, 0x5f, 0x35, 0x7f, 0x62, 0x0d, 0xbb, 0x87, 0xec, 0x43, 0x2e, 0x52, 0xfd, + 0xd9, 0xcc, 0xc7, 0x6a, 0xcf, 0xe7, 0x12, 0x8e, 0x6b, 0x4b, 0x1c, 0x75, 0x2c, 0x31, 0x60, 0x95, + 0x11, 0x26, 0xe0, 0x1e, 0xca, 0xb4, 0x07, 0x2a, 0x62, 0x55, 0x5a, 0x8d, 0xbf, 0xab, 0x6d, 0xef, + 0x39, 0x6d, 0xaf, 0xa0, 0x65, 0x1c, 0x12, 0xd1, 0x92, 0x56, 0x37, 0xb5, 0xb5, 0xfb, 0x3d, 0x2d, + 0xe9, 0xdd, 0xcd, 0xef, 0xb3, 0x0d, 0x2f, 0xe3, 0x5d, 0x70, 0x1d, 0xe6, 0xe9, 0xec, 0xe1, 0xee, + 0xb7, 0xea, 0x09, 0x9e, 0x3d, 0xf3, 0xe6, 0x9a, 0x4c, 0xe0, 0xe8, 0xf7, 0xf5, 0xf6, 0x53, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x8f, 0xe8, 0x8e, 0x65, 0xc7, 0x07, 0x00, 0x00, } diff --git a/idemix/idemix.proto b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/idemix.proto similarity index 84% rename from idemix/idemix.proto rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/idemix.proto index 56b546d651b..b42fbb215b1 100644 --- a/idemix/idemix.proto +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/idemix.proto @@ -6,28 +6,16 @@ SPDX-License-Identifier: Apache-2.0 syntax = "proto3"; -option go_package = "github.com/hyperledger/fabric/idemix"; +option go_package = "github.com/IBM/idemix/bccsp/schemes/dlog/idemix"; // The Identity Mixer protocols make use of pairings (bilinear maps) - // functions that can be described as e: G1 x G2 -> GT that // map group elements from the source groups (G1 and G2) to the target group // Such groups can be represented by the points on an elliptic curve -// ECP is an elliptic curve point specified by its coordinates -// ECP corresponds to an element of the first group (G1) -message ECP { - bytes x = 1; - bytes y = 2; -} +package idemix; -// ECP2 is an elliptic curve point specified by its coordinates -// ECP2 corresponds to an element of the second group (G2) -message ECP2 { - bytes xa = 1; - bytes xb = 2; - bytes ya = 3; - bytes yb = 4; -} +import "bccsp/schemes/dlog/crypto/translator/amcl/amcl.proto"; // IssuerPublicKey specifies an issuer public key that consists of // attribute_names - a list of the attribute names of a credential issued by the issuer @@ -36,12 +24,12 @@ message ECP2 { // hash is a hash of the public key appended to it message IssuerPublicKey { repeated string attribute_names = 1; - ECP h_sk = 2; - ECP h_rand = 3; - repeated ECP h_attrs = 4; - ECP2 w = 5; - ECP bar_g1 = 6; - ECP bar_g2 = 7; + amcl.ECP h_sk = 2; + amcl.ECP h_rand = 3; + repeated amcl.ECP h_attrs = 4; + amcl.ECP2 w = 5; + amcl.ECP bar_g1 = 6; + amcl.ECP bar_g2 = 7; bytes proof_c = 8; bytes proof_s = 9; bytes hash = 10; @@ -59,8 +47,8 @@ message IssuerKey { // a, b, e, s - signature value // attrs - attribute values message Credential { - ECP a = 1; - ECP b = 2; + amcl.ECP a = 1; + amcl.ECP b = 2; bytes e = 3; bytes s = 4; repeated bytes attrs = 5; @@ -72,12 +60,17 @@ message Credential { // proof_c, proof_s - a zero-knowledge proof of knowledge of the // user secret inside Nym message CredRequest { - ECP nym = 1; + amcl.ECP nym = 1; bytes issuer_nonce = 2; bytes proof_c = 3; bytes proof_s = 4; } +message EIDNym { + amcl.ECP nym = 1; + bytes proof_s_eid = 2; +} + // Signature specifies a signature object that consists of // a_prime, a_bar, b_prime, proof_* - randomized credential signature values // and a zero-knowledge proof of knowledge of a credential @@ -85,9 +78,9 @@ message CredRequest { // nonce - a fresh nonce used for the signature // nym - a fresh pseudonym (a commitment to to the user secret) message Signature { - ECP a_prime = 1; - ECP a_bar = 2; - ECP b_prime = 3; + amcl.ECP a_prime = 1; + amcl.ECP a_bar = 2; + amcl.ECP b_prime = 3; bytes proof_c = 4; bytes proof_s_sk = 5; bytes proof_s_e = 6; @@ -96,12 +89,13 @@ message Signature { bytes proof_s_s_prime = 9; repeated bytes proof_s_attrs = 10; bytes nonce = 11; - ECP nym = 12; + amcl.ECP nym = 12; bytes proof_s_r_nym = 13; - ECP2 revocation_epoch_pk = 14; + amcl.ECP2 revocation_epoch_pk = 14; bytes revocation_pk_sig = 15; int64 epoch = 16; NonRevocationProof non_revocation_proof = 17; + EIDNym eid_nym = 18; } // NonRevocationProof contains proof that the credential is not revoked @@ -131,7 +125,7 @@ message CredentialRevocationInformation { int64 epoch = 1; // epoch_pk is the public key that is used by the revocation authority in this epoch - ECP2 epoch_pk = 2; + amcl.ECP2 epoch_pk = 2; // epoch_pk_sig is a signature on the EpochPK valid under the revocation authority's long term key bytes epoch_pk_sig = 3; @@ -141,4 +135,4 @@ message CredentialRevocationInformation { // revocation_data contains data specific to the revocation algorithm used bytes revocation_data = 5; -} \ No newline at end of file +} diff --git a/idemix/issuerkey.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/issuerkey.go similarity index 52% rename from idemix/issuerkey.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/issuerkey.go index b06ae886b3d..3ee5d483ac0 100644 --- a/idemix/issuerkey.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/issuerkey.go @@ -7,9 +7,11 @@ SPDX-License-Identifier: Apache-2.0 package idemix import ( + "io" + + amcl "github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl" + math "github.com/IBM/mathlib" "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-amcl/amcl" - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" "github.com/pkg/errors" ) @@ -26,7 +28,11 @@ import ( // NewIssuerKey creates a new issuer key pair taking an array of attribute names // that will be contained in credentials certified by this issuer (a credential specification) // See http://eprint.iacr.org/2016/663.pdf Sec. 4.3, for references. -func NewIssuerKey(AttributeNames []string, rng *amcl.RAND) (*IssuerKey, error) { +func (i *Idemix) NewIssuerKey(AttributeNames []string, rng io.Reader, t Translator) (*IssuerKey, error) { + return newIssuerKey(AttributeNames, rng, i.Curve, t) +} + +func newIssuerKey(AttributeNames []string, rng io.Reader, curve *math.Curve, t Translator) (*IssuerKey, error) { // validate inputs // check for duplicated attributes @@ -41,97 +47,139 @@ func NewIssuerKey(AttributeNames []string, rng *amcl.RAND) (*IssuerKey, error) { key := new(IssuerKey) // generate issuer secret key - ISk := RandModOrder(rng) - key.Isk = BigToBytes(ISk) + ISk := curve.NewRandomZr(rng) + key.Isk = ISk.Bytes() // generate the corresponding public key key.Ipk = new(IssuerPublicKey) key.Ipk.AttributeNames = AttributeNames - W := GenG2.Mul(ISk) - key.Ipk.W = Ecp2ToProto(W) + W := curve.GenG2.Mul(ISk) + key.Ipk.W = t.G2ToProto(W) // generate bases that correspond to the attributes - key.Ipk.HAttrs = make([]*ECP, len(AttributeNames)) + key.Ipk.HAttrs = make([]*amcl.ECP, len(AttributeNames)) for i := 0; i < len(AttributeNames); i++ { - key.Ipk.HAttrs[i] = EcpToProto(GenG1.Mul(RandModOrder(rng))) + key.Ipk.HAttrs[i] = t.G1ToProto(curve.GenG1.Mul(curve.NewRandomZr(rng))) } // generate base for the secret key - HSk := GenG1.Mul(RandModOrder(rng)) - key.Ipk.HSk = EcpToProto(HSk) + HSk := curve.GenG1.Mul(curve.NewRandomZr(rng)) + key.Ipk.HSk = t.G1ToProto(HSk) // generate base for the randomness - HRand := GenG1.Mul(RandModOrder(rng)) - key.Ipk.HRand = EcpToProto(HRand) + HRand := curve.GenG1.Mul(curve.NewRandomZr(rng)) + key.Ipk.HRand = t.G1ToProto(HRand) - BarG1 := GenG1.Mul(RandModOrder(rng)) - key.Ipk.BarG1 = EcpToProto(BarG1) + BarG1 := curve.GenG1.Mul(curve.NewRandomZr(rng)) + key.Ipk.BarG1 = t.G1ToProto(BarG1) BarG2 := BarG1.Mul(ISk) - key.Ipk.BarG2 = EcpToProto(BarG2) + key.Ipk.BarG2 = t.G1ToProto(BarG2) // generate a zero-knowledge proof of knowledge (ZK PoK) of the secret key which // is in W and BarG2. // Sample the randomness needed for the proof - r := RandModOrder(rng) + r := curve.NewRandomZr(rng) // Step 1: First message (t-values) - t1 := GenG2.Mul(r) // t1 = g_2^r, cover W - t2 := BarG1.Mul(r) // t2 = (\bar g_1)^r, cover BarG2 + t1 := curve.GenG2.Mul(r) // t1 = g_2^r, cover W + t2 := BarG1.Mul(r) // t2 = (\bar g_1)^r, cover BarG2 // Step 2: Compute the Fiat-Shamir hash, forming the challenge of the ZKP. - proofData := make([]byte, 18*FieldBytes+3) + proofData := make([]byte, 18*curve.FieldBytes+3) index := 0 index = appendBytesG2(proofData, index, t1) index = appendBytesG1(proofData, index, t2) - index = appendBytesG2(proofData, index, GenG2) + index = appendBytesG2(proofData, index, curve.GenG2) index = appendBytesG1(proofData, index, BarG1) index = appendBytesG2(proofData, index, W) - appendBytesG1(proofData, index, BarG2) + index = appendBytesG1(proofData, index, BarG2) - proofC := HashModOrder(proofData) - key.Ipk.ProofC = BigToBytes(proofC) + proofC := curve.HashToZr(proofData) + key.Ipk.ProofC = proofC.Bytes() // Step 3: reply to the challenge message (s-values) - proofS := Modadd(FP256BN.Modmul(proofC, ISk, GroupOrder), r, GroupOrder) // // s = r + C \cdot ISk - key.Ipk.ProofS = BigToBytes(proofS) + proofS := curve.ModAdd(curve.ModMul(proofC, ISk, curve.GroupOrder), r, curve.GroupOrder) // // s = r + C \cdot ISk + key.Ipk.ProofS = proofS.Bytes() // Hash the public key serializedIPk, err := proto.Marshal(key.Ipk) if err != nil { return nil, errors.Wrap(err, "failed to marshal issuer public key") } - key.Ipk.Hash = BigToBytes(HashModOrder(serializedIPk)) + key.Ipk.Hash = curve.HashToZr(serializedIPk).Bytes() // We are done return key, nil } +func (i *Idemix) NewIssuerKeyFromBytes(raw []byte) (*IssuerKey, error) { + return newIssuerKeyFromBytes(raw) +} + +func newIssuerKeyFromBytes(raw []byte) (*IssuerKey, error) { + ik := &IssuerKey{} + if err := proto.Unmarshal(raw, ik); err != nil { + return nil, err + } + + //raw, err :=proto.Marshal(ik.Ipk.W) + //if err != nil { + // panic(err) + //} + //fmt.Printf("IPKW : [%v]", ik.Ipk.W.Xa) + + return ik, nil +} + // Check checks that this issuer public key is valid, i.e. // that all components are present and a ZK proofs verifies -func (IPk *IssuerPublicKey) Check() error { +func (IPk *IssuerPublicKey) Check(curve *math.Curve, t Translator) error { // Unmarshall the public key NumAttrs := len(IPk.GetAttributeNames()) - HSk := EcpFromProto(IPk.GetHSk()) - HRand := EcpFromProto(IPk.GetHRand()) - HAttrs := make([]*FP256BN.ECP, len(IPk.GetHAttrs())) + HSk, err := t.G1FromProto(IPk.GetHSk()) + if err != nil { + return err + } + + HRand, err := t.G1FromProto(IPk.GetHRand()) + if err != nil { + return err + } + + HAttrs := make([]*math.G1, len(IPk.GetHAttrs())) for i := 0; i < len(IPk.GetHAttrs()); i++ { - HAttrs[i] = EcpFromProto(IPk.GetHAttrs()[i]) + HAttrs[i], err = t.G1FromProto(IPk.GetHAttrs()[i]) + if err != nil { + return err + } } - BarG1 := EcpFromProto(IPk.GetBarG1()) - BarG2 := EcpFromProto(IPk.GetBarG2()) - W := Ecp2FromProto(IPk.GetW()) - ProofC := FP256BN.FromBytes(IPk.GetProofC()) - ProofS := FP256BN.FromBytes(IPk.GetProofS()) + BarG1, err := t.G1FromProto(IPk.GetBarG1()) + if err != nil { + return err + } + + BarG2, err := t.G1FromProto(IPk.GetBarG2()) + if err != nil { + return err + } + + W, err := t.G2FromProto(IPk.GetW()) + if err != nil { + return err + } + + ProofC := curve.NewZrFromBytes(IPk.GetProofC()) + ProofS := curve.NewZrFromBytes(IPk.GetProofS()) // Check that the public key is well-formed if NumAttrs < 0 || HSk == nil || HRand == nil || BarG1 == nil || - BarG1.Is_infinity() || + BarG1.IsInfinity() || BarG2 == nil || HAttrs == nil || len(IPk.HAttrs) < NumAttrs { @@ -146,38 +194,38 @@ func (IPk *IssuerPublicKey) Check() error { // Verify Proof // Recompute challenge - proofData := make([]byte, 18*FieldBytes+3) + proofData := make([]byte, 18*curve.FieldBytes+3) index := 0 // Recompute t-values using s-values - t1 := GenG2.Mul(ProofS) - t1.Add(W.Mul(FP256BN.Modneg(ProofC, GroupOrder))) // t1 = g_2^s \cdot W^{-C} + t1 := curve.GenG2.Mul(ProofS) + t1.Add(W.Mul(curve.ModNeg(ProofC, curve.GroupOrder))) // t1 = g_2^s \cdot W^{-C} t2 := BarG1.Mul(ProofS) - t2.Add(BarG2.Mul(FP256BN.Modneg(ProofC, GroupOrder))) // t2 = {\bar g_1}^s \cdot {\bar g_2}^C + t2.Add(BarG2.Mul(curve.ModNeg(ProofC, curve.GroupOrder))) // t2 = {\bar g_1}^s \cdot {\bar g_2}^C index = appendBytesG2(proofData, index, t1) index = appendBytesG1(proofData, index, t2) - index = appendBytesG2(proofData, index, GenG2) + index = appendBytesG2(proofData, index, curve.GenG2) index = appendBytesG1(proofData, index, BarG1) index = appendBytesG2(proofData, index, W) - appendBytesG1(proofData, index, BarG2) + index = appendBytesG1(proofData, index, BarG2) // Verify that the challenge is the same - if *ProofC != *HashModOrder(proofData) { + if !ProofC.Equals(curve.HashToZr(proofData)) { return errors.Errorf("zero knowledge proof in public key invalid") } - return IPk.SetHash() + return IPk.SetHash(curve) } // SetHash appends a hash of a serialized public key -func (IPk *IssuerPublicKey) SetHash() error { +func (IPk *IssuerPublicKey) SetHash(curve *math.Curve) error { IPk.Hash = nil serializedIPk, err := proto.Marshal(IPk) if err != nil { return errors.Wrap(err, "Failed to marshal issuer public key") } - IPk.Hash = BigToBytes(HashModOrder(serializedIPk)) + IPk.Hash = curve.HashToZr(serializedIPk).Bytes() return nil } diff --git a/idemix/logging.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/logging.go similarity index 100% rename from idemix/logging.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/logging.go diff --git a/idemix/nonrevocation-prover.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/nonrevocation-prover.go similarity index 65% rename from idemix/nonrevocation-prover.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/nonrevocation-prover.go index fd259abc6cd..c9146b5367e 100644 --- a/idemix/nonrevocation-prover.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/nonrevocation-prover.go @@ -7,28 +7,29 @@ SPDX-License-Identifier: Apache-2.0 package idemix import ( - "github.com/hyperledger/fabric-amcl/amcl" - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" + "io" + + math "github.com/IBM/mathlib" "github.com/pkg/errors" ) // nonRevokedProver is the Prover of the ZK proof system that handles revocation. type nonRevokedProver interface { // getFSContribution returns the non-revocation contribution to the Fiat-Shamir hash, forming the challenge of the ZKP, - getFSContribution(rh *FP256BN.BIG, rRh *FP256BN.BIG, cri *CredentialRevocationInformation, rng *amcl.RAND) ([]byte, error) + getFSContribution(rh *math.Zr, rRh *math.Zr, cri *CredentialRevocationInformation, rng io.Reader) ([]byte, error) // getNonRevokedProof returns a proof of non-revocation with the respect to passed challenge - getNonRevokedProof(chal *FP256BN.BIG) (*NonRevocationProof, error) + getNonRevokedProof(chal *math.Zr) (*NonRevocationProof, error) } // nopNonRevokedProver is an empty nonRevokedProver type nopNonRevokedProver struct{} -func (prover *nopNonRevokedProver) getFSContribution(rh *FP256BN.BIG, rRh *FP256BN.BIG, cri *CredentialRevocationInformation, rng *amcl.RAND) ([]byte, error) { +func (prover *nopNonRevokedProver) getFSContribution(rh *math.Zr, rRh *math.Zr, cri *CredentialRevocationInformation, rng io.Reader) ([]byte, error) { return nil, nil } -func (prover *nopNonRevokedProver) getNonRevokedProof(chal *FP256BN.BIG) (*NonRevocationProof, error) { +func (prover *nopNonRevokedProver) getNonRevokedProof(chal *math.Zr) (*NonRevocationProof, error) { ret := &NonRevocationProof{} ret.RevocationAlg = int32(ALG_NO_REVOCATION) return ret, nil diff --git a/idemix/nonrevocation-verifier.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/nonrevocation-verifier.go similarity index 77% rename from idemix/nonrevocation-verifier.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/nonrevocation-verifier.go index 75526342d5f..a018aa5ecea 100644 --- a/idemix/nonrevocation-verifier.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/nonrevocation-verifier.go @@ -7,20 +7,20 @@ SPDX-License-Identifier: Apache-2.0 package idemix import ( - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" + math "github.com/IBM/mathlib" "github.com/pkg/errors" ) // nonRevokedProver is the Verifier of the ZK proof system that handles revocation. type nonRevocationVerifier interface { // recomputeFSContribution recomputes the contribution of the non-revocation proof to the ZKP challenge - recomputeFSContribution(proof *NonRevocationProof, chal *FP256BN.BIG, epochPK *FP256BN.ECP2, proofSRh *FP256BN.BIG) ([]byte, error) + recomputeFSContribution(proof *NonRevocationProof, chal *math.Zr, epochPK *math.G2, proofSRh *math.Zr) ([]byte, error) } // nopNonRevocationVerifier is an empty nonRevocationVerifier that produces an empty contribution type nopNonRevocationVerifier struct{} -func (verifier *nopNonRevocationVerifier) recomputeFSContribution(proof *NonRevocationProof, chal *FP256BN.BIG, epochPK *FP256BN.ECP2, proofSRh *FP256BN.BIG) ([]byte, error) { +func (verifier *nopNonRevocationVerifier) recomputeFSContribution(proof *NonRevocationProof, chal *math.Zr, epochPK *math.G2, proofSRh *math.Zr) ([]byte, error) { return nil, nil } diff --git a/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/nymsignature.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/nymsignature.go new file mode 100644 index 00000000000..713486cc8c3 --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/nymsignature.go @@ -0,0 +1,128 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package idemix + +import ( + "io" + + math "github.com/IBM/mathlib" + "github.com/pkg/errors" +) + +// NewSignature creates a new idemix pseudonym signature +func (i *Idemix) NewNymSignature(sk *math.Zr, Nym *math.G1, RNym *math.Zr, ipk *IssuerPublicKey, msg []byte, rng io.Reader, tr Translator) (*NymSignature, error) { + return newNymSignature(sk, Nym, RNym, ipk, msg, rng, i.Curve, tr) +} + +func newNymSignature(sk *math.Zr, Nym *math.G1, RNym *math.Zr, ipk *IssuerPublicKey, msg []byte, rng io.Reader, curve *math.Curve, tr Translator) (*NymSignature, error) { + // Validate inputs + if sk == nil || Nym == nil || RNym == nil || ipk == nil || rng == nil { + return nil, errors.Errorf("cannot create NymSignature: received nil input") + } + + Nonce := curve.NewRandomZr(rng) + + HRand, err := tr.G1FromProto(ipk.HRand) + if err != nil { + return nil, err + } + + HSk, err := tr.G1FromProto(ipk.HSk) + if err != nil { + return nil, err + } + + // The rest of this function constructs the non-interactive zero knowledge proof proving that + // the signer 'owns' this pseudonym, i.e., it knows the secret key and randomness on which it is based. + // Recall that (Nym,RNym) is the output of MakeNym. Therefore, Nym = h_{sk}^sk \cdot h_r^r + + // Sample the randomness needed for the proof + rSk := curve.NewRandomZr(rng) + rRNym := curve.NewRandomZr(rng) + + // Step 1: First message (t-values) + t := HSk.Mul2(rSk, HRand, rRNym) // t = h_{sk}^{r_sk} \cdot h_r^{r_{RNym} + + // Step 2: Compute the Fiat-Shamir hash, forming the challenge of the ZKP. + // proofData will hold the data being hashed, it consists of: + // - the signature label + // - 2 elements of G1 each taking 2*math.FieldBytes+1 bytes + // - one bigint (hash of the issuer public key) of length math.FieldBytes + // - disclosed attributes + // - message being signed + proofData := make([]byte, len([]byte(signLabel))+2*(2*curve.FieldBytes+1)+curve.FieldBytes+len(msg)) + index := 0 + index = appendBytesString(proofData, index, signLabel) + index = appendBytesG1(proofData, index, t) + index = appendBytesG1(proofData, index, Nym) + copy(proofData[index:], ipk.Hash) + index = index + curve.FieldBytes + copy(proofData[index:], msg) + c := curve.HashToZr(proofData) + // combine the previous hash and the nonce and hash again to compute the final Fiat-Shamir value 'ProofC' + index = 0 + proofData = proofData[:2*curve.FieldBytes] + index = appendBytesBig(proofData, index, c) + index = appendBytesBig(proofData, index, Nonce) + ProofC := curve.HashToZr(proofData) + + // Step 3: reply to the challenge message (s-values) + ProofSSk := curve.ModAdd(rSk, curve.ModMul(ProofC, sk, curve.GroupOrder), curve.GroupOrder) // s_{sk} = r_{sk} + C \cdot sk + ProofSRNym := curve.ModAdd(rRNym, curve.ModMul(ProofC, RNym, curve.GroupOrder), curve.GroupOrder) // s_{RNym} = r_{RNym} + C \cdot RNym + + // The signature consists of the Fiat-Shamir hash (ProofC), the s-values (ProofSSk, ProofSRNym), and the nonce. + return &NymSignature{ + ProofC: ProofC.Bytes(), + ProofSSk: ProofSSk.Bytes(), + ProofSRNym: ProofSRNym.Bytes(), + Nonce: Nonce.Bytes()}, nil +} + +// Ver verifies an idemix NymSignature +func (sig *NymSignature) Ver(nym *math.G1, ipk *IssuerPublicKey, msg []byte, curve *math.Curve, tr Translator) error { + ProofC := curve.NewZrFromBytes(sig.GetProofC()) + ProofSSk := curve.NewZrFromBytes(sig.GetProofSSk()) + ProofSRNym := curve.NewZrFromBytes(sig.GetProofSRNym()) + Nonce := curve.NewZrFromBytes(sig.GetNonce()) + + HRand, err := tr.G1FromProto(ipk.HRand) + if err != nil { + return err + } + + HSk, err := tr.G1FromProto(ipk.HSk) + if err != nil { + return err + } + + // Verify Proof + + // Recompute t-values using s-values + t := HSk.Mul2(ProofSSk, HRand, ProofSRNym) + t.Sub(nym.Mul(ProofC)) // t = h_{sk}^{s_{sk} \ cdot h_r^{s_{RNym} + + // Recompute challenge + proofData := make([]byte, len([]byte(signLabel))+2*(2*curve.FieldBytes+1)+curve.FieldBytes+len(msg)) + index := 0 + index = appendBytesString(proofData, index, signLabel) + index = appendBytesG1(proofData, index, t) + index = appendBytesG1(proofData, index, nym) + copy(proofData[index:], ipk.Hash) + index = index + curve.FieldBytes + copy(proofData[index:], msg) + c := curve.HashToZr(proofData) + index = 0 + proofData = proofData[:2*curve.FieldBytes] + index = appendBytesBig(proofData, index, c) + index = appendBytesBig(proofData, index, Nonce) + + if !ProofC.Equals(curve.HashToZr(proofData)) { + return errors.Errorf("pseudonym signature invalid: zero-knowledge proof is invalid") + } + + return nil +} diff --git a/idemix/revocation_authority.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/revocation_authority.go similarity index 60% rename from idemix/revocation_authority.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/revocation_authority.go index 1835f17bca3..a50fa376138 100644 --- a/idemix/revocation_authority.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/revocation_authority.go @@ -12,11 +12,12 @@ import ( "crypto/rand" "crypto/sha256" "encoding/asn1" + "io" "math/big" + amcl "github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl" + math "github.com/IBM/mathlib" "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-amcl/amcl" - "github.com/hyperledger/fabric-amcl/amcl/FP256BN" "github.com/pkg/errors" ) @@ -31,15 +32,37 @@ var ProofBytes = map[RevocationAlgorithm]int{ } // GenerateLongTermRevocationKey generates a long term signing key that will be used for revocation -func GenerateLongTermRevocationKey() (*ecdsa.PrivateKey, error) { +func (i *Idemix) GenerateLongTermRevocationKey() (*ecdsa.PrivateKey, error) { + return generateLongTermRevocationKey() +} + +func generateLongTermRevocationKey() (*ecdsa.PrivateKey, error) { return ecdsa.GenerateKey(elliptic.P384(), rand.Reader) } +// GenerateLongTermRevocationKey generates a long term signing key that will be used for revocation +func (i *Idemix) LongTermRevocationKeyFromBytes(raw []byte) (*ecdsa.PrivateKey, error) { + return longTermRevocationKeyFromBytes(raw) +} + +func longTermRevocationKeyFromBytes(raw []byte) (*ecdsa.PrivateKey, error) { + priv := &ecdsa.PrivateKey{} + priv.D = new(big.Int).SetBytes(raw) + priv.PublicKey.Curve = elliptic.P384() + priv.PublicKey.X, priv.PublicKey.Y = elliptic.P384().ScalarBaseMult(priv.D.Bytes()) + + return priv, nil +} + // CreateCRI creates the Credential Revocation Information for a certain time period (epoch). // Users can use the CRI to prove that they are not revoked. // Note that when not using revocation (i.e., alg = ALG_NO_REVOCATION), the entered unrevokedHandles are not used, // and the resulting CRI can be used by any signer. -func CreateCRI(key *ecdsa.PrivateKey, unrevokedHandles []*FP256BN.BIG, epoch int, alg RevocationAlgorithm, rng *amcl.RAND) (*CredentialRevocationInformation, error) { +func (i *Idemix) CreateCRI(key *ecdsa.PrivateKey, unrevokedHandles []*math.Zr, epoch int, alg RevocationAlgorithm, rng io.Reader, t Translator) (*CredentialRevocationInformation, error) { + return createCRI(key, unrevokedHandles, epoch, alg, rng, i.Curve, t) +} + +func createCRI(key *ecdsa.PrivateKey, unrevokedHandles []*math.Zr, epoch int, alg RevocationAlgorithm, rng io.Reader, curve *math.Curve, t Translator) (*CredentialRevocationInformation, error) { if key == nil || rng == nil { return nil, errors.Errorf("CreateCRI received nil input") } @@ -49,11 +72,11 @@ func CreateCRI(key *ecdsa.PrivateKey, unrevokedHandles []*FP256BN.BIG, epoch int if alg == ALG_NO_REVOCATION { // put a dummy PK in the proto - cri.EpochPk = Ecp2ToProto(GenG2) + cri.EpochPk = t.G2ToProto(curve.GenG2) } else { // create epoch key - _, epochPk := WBBKeyGen(rng) - cri.EpochPk = Ecp2ToProto(epochPk) + _, epochPk := wbbKeyGen(curve, rng) + cri.EpochPk = t.G2ToProto(epochPk) } // sign epoch + epoch key with long term key @@ -81,7 +104,11 @@ func CreateCRI(key *ecdsa.PrivateKey, unrevokedHandles []*FP256BN.BIG, epoch int // Note that even if we use no revocation (i.e., alg = ALG_NO_REVOCATION), we need // to verify the signature to make sure the issuer indeed signed that no revocation // is used in this epoch. -func VerifyEpochPK(pk *ecdsa.PublicKey, epochPK *ECP2, epochPkSig []byte, epoch int, alg RevocationAlgorithm) error { +func (i *Idemix) VerifyEpochPK(pk *ecdsa.PublicKey, epochPK *amcl.ECP2, epochPkSig []byte, epoch int, alg RevocationAlgorithm) error { + return verifyEpochPK(pk, epochPK, epochPkSig, epoch, alg) +} + +func verifyEpochPK(pk *ecdsa.PublicKey, epochPK *amcl.ECP2, epochPkSig []byte, epoch int, alg RevocationAlgorithm) error { if pk == nil || epochPK == nil { return errors.Errorf("EpochPK invalid: received nil input") } diff --git a/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/signature.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/signature.go new file mode 100644 index 00000000000..d2eddbbe33a --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/signature.go @@ -0,0 +1,892 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package idemix + +import ( + "crypto/ecdsa" + "fmt" + "io" + "sort" + + opts "github.com/IBM/idemix/bccsp/schemes" + math "github.com/IBM/mathlib" + "github.com/pkg/errors" +) + +// signLabel is the label used in zero-knowledge proof (ZKP) to identify that this ZKP is a signature of knowledge +const signLabel = "sign" +const signWithEidNymLabel = "signWithEidNym" + +// A signature that is produced using an Identity Mixer credential is a so-called signature of knowledge +// (for details see C.P.Schnorr "Efficient Identification and Signatures for Smart Cards") +// An Identity Mixer signature is a signature of knowledge that signs a message and proves (in zero-knowledge) +// the knowledge of the user secret (and possibly attributes) signed inside a credential +// that was issued by a certain issuer (referred to with the issuer public key) +// The signature is verified using the message being signed and the public key of the issuer +// Some of the attributes from the credential can be selectively disclosed or different statements can be proven about +// credential attributes without disclosing them in the clear +// The difference between a standard signature using X.509 certificates and an Identity Mixer signature is +// the advanced privacy features provided by Identity Mixer (due to zero-knowledge proofs): +// - Unlinkability of the signatures produced with the same credential +// - Selective attribute disclosure and predicates over attributes + +// Make a slice of all the attribute indices that will not be disclosed +func hiddenIndices(Disclosure []byte) []int { + HiddenIndices := make([]int, 0) + for index, disclose := range Disclosure { + if disclose == 0 { + HiddenIndices = append(HiddenIndices, index) + } + } + return HiddenIndices +} + +// NewSignature creates a new idemix signature (Schnorr-type signature) +// The []byte Disclosure steers which attributes are disclosed: +// if Disclosure[i] == 0 then attribute i remains hidden and otherwise it is disclosed. +// We require the revocation handle to remain undisclosed (i.e., Disclosure[rhIndex] == 0). +// We use the zero-knowledge proof by http://eprint.iacr.org/2016/663.pdf, Sec. 4.5 to prove knowledge of a BBS+ signature +func (i *Idemix) NewSignature( + cred *Credential, + sk *math.Zr, + Nym *math.G1, + RNym *math.Zr, + ipk *IssuerPublicKey, + Disclosure []byte, + msg []byte, + rhIndex, eidIndex int, + cri *CredentialRevocationInformation, + rng io.Reader, + tr Translator, + sigType opts.SignatureType, +) (*Signature, *opts.IdemixSignerMetadata, error) { + switch sigType { + case opts.Standard: + return newSignature(cred, sk, Nym, RNym, ipk, Disclosure, msg, rhIndex, cri, rng, i.Curve, tr) + case opts.EidNym: + return newSignatureWithEIDNym(cred, sk, Nym, RNym, ipk, Disclosure, msg, rhIndex, eidIndex, cri, rng, i.Curve, tr) + } + + panic(fmt.Sprintf("programming error, requested signature type %d", sigType)) +} + +func newSignatureWithEIDNym( + cred *Credential, + sk *math.Zr, + Nym *math.G1, + RNym *math.Zr, + ipk *IssuerPublicKey, + Disclosure []byte, + msg []byte, + rhIndex, eidIndex int, + cri *CredentialRevocationInformation, + rng io.Reader, + curve *math.Curve, + tr Translator, +) (*Signature, *opts.IdemixSignerMetadata, error) { + if Disclosure[eidIndex] != 0 { + return nil, nil, errors.Errorf("cannot create idemix signature: disclosure of enrollment ID requested for NewSignatureWithEIDNym") + } + + t1, t2, t3, APrime, ABar, BPrime, nonRevokedProofHashData, E, Nonce, rSk, rSPrime, rR2, rR3, r2, r3, re, sPrime, rRNym, rAttrs, prover, HiddenIndices, err := prepare(cred, sk, Nym, RNym, ipk, Disclosure, msg, rhIndex, cri, rng, curve, tr) + if err != nil { + return nil, nil, err + } + + return finalise( + cred, + sk, + Nym, + RNym, + ipk, + Disclosure, + msg, + rhIndex, eidIndex, + cri, + rng, + curve, + tr, + t1, t2, t3, + APrime, ABar, BPrime, + nonRevokedProofHashData, + E, + Nonce, + rSk, rSPrime, rR2, rR3, r2, r3, re, sPrime, rRNym, + rAttrs, + prover, + HiddenIndices, + opts.EidNym, + ) +} + +func newSignature( + cred *Credential, + sk *math.Zr, + Nym *math.G1, + RNym *math.Zr, + ipk *IssuerPublicKey, + Disclosure []byte, + msg []byte, + rhIndex int, + cri *CredentialRevocationInformation, + rng io.Reader, + curve *math.Curve, + tr Translator, +) (*Signature, *opts.IdemixSignerMetadata, error) { + t1, t2, t3, APrime, ABar, BPrime, nonRevokedProofHashData, E, Nonce, rSk, rSPrime, rR2, rR3, r2, r3, re, sPrime, rRNym, rAttrs, prover, HiddenIndices, err := prepare(cred, sk, Nym, RNym, ipk, Disclosure, msg, rhIndex, cri, rng, curve, tr) + if err != nil { + return nil, nil, err + } + + return finalise( + cred, + sk, + Nym, + RNym, + ipk, + Disclosure, + msg, + rhIndex, -1, + cri, + rng, + curve, + tr, + t1, t2, t3, + APrime, ABar, BPrime, + nonRevokedProofHashData, + E, + Nonce, + rSk, rSPrime, rR2, rR3, r2, r3, re, sPrime, rRNym, + rAttrs, + prover, + HiddenIndices, + opts.Standard, + ) +} + +func prepare( + cred *Credential, + sk *math.Zr, + Nym *math.G1, + RNym *math.Zr, + ipk *IssuerPublicKey, + Disclosure []byte, + msg []byte, + rhIndex int, + cri *CredentialRevocationInformation, + rng io.Reader, + curve *math.Curve, + tr Translator, +) (*math.G1, *math.G1, *math.G1, *math.G1, *math.G1, *math.G1, + []byte, + *math.Zr, + *math.Zr, + *math.Zr, *math.Zr, *math.Zr, *math.Zr, *math.Zr, *math.Zr, *math.Zr, *math.Zr, *math.Zr, + []*math.Zr, + nonRevokedProver, + []int, error, +) { + // Validate inputs + if cred == nil || sk == nil || Nym == nil || RNym == nil || ipk == nil || rng == nil || cri == nil { + return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, errors.Errorf("cannot create idemix signature: received nil input") + } + + if rhIndex < 0 || rhIndex >= len(ipk.AttributeNames) || len(Disclosure) != len(ipk.AttributeNames) { + return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, errors.Errorf("cannot create idemix signature: received invalid input") + } + + if cri.RevocationAlg != int32(ALG_NO_REVOCATION) && Disclosure[rhIndex] == 1 { + return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, errors.Errorf("Attribute %d is disclosed but also used as revocation handle attribute, which should remain hidden.", rhIndex) + } + + // locate the indices of the attributes to hide and sample randomness for them + HiddenIndices := hiddenIndices(Disclosure) + + // Generate required randomness r_1, r_2 + r1 := curve.NewRandomZr(rng) + r2 := curve.NewRandomZr(rng) + // Set r_3 as \frac{1}{r_1} + r3 := r1.Copy() + r3.InvModP(curve.GroupOrder) + + // Sample a nonce + Nonce := curve.NewRandomZr(rng) + + // Parse credential + A, err := tr.G1FromProto(cred.A) + if err != nil { + return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err + } + + B, err := tr.G1FromProto(cred.B) + if err != nil { + return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err + } + + // Randomize credential + + // Compute A' as A^{r_1} + APrime := A.Mul(r1) + // logger.Printf("Signature Generation : \n"+ + // " [APrime:%v]\n", + // APrime.Bytes(), + // ) + + // Compute ABar as A'^{-e} b^{r1} + ABar := B.Mul(r1) + ABar.Sub(APrime.Mul(curve.NewZrFromBytes(cred.E))) + // logger.Printf("Signature Generation : \n"+ + // " [ABar:%v]\n", + // ABar.Bytes(), + // ) + + // Compute B' as b^{r1} / h_r^{r2}, where h_r is h_r + BPrime := B.Mul(r1) + HRand, err := tr.G1FromProto(ipk.HRand) + if err != nil { + return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err + } + + // Parse h_{sk} from ipk + HSk, err := tr.G1FromProto(ipk.HSk) + if err != nil { + return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err + } + + BPrime.Sub(HRand.Mul(r2)) + + S := curve.NewZrFromBytes(cred.S) + E := curve.NewZrFromBytes(cred.E) + + // Compute s' as s - r_2 \cdot r_3 + sPrime := curve.ModSub(S, curve.ModMul(r2, r3, curve.GroupOrder), curve.GroupOrder) + + // The rest of this function constructs the non-interactive zero knowledge proof + // that links the signature, the non-disclosed attributes and the nym. + + // Sample the randomness used to compute the commitment values (aka t-values) for the ZKP + rSk := curve.NewRandomZr(rng) + re := curve.NewRandomZr(rng) + rR2 := curve.NewRandomZr(rng) + rR3 := curve.NewRandomZr(rng) + rSPrime := curve.NewRandomZr(rng) + rRNym := curve.NewRandomZr(rng) + + rAttrs := make([]*math.Zr, len(HiddenIndices)) + for i := range HiddenIndices { + rAttrs[i] = curve.NewRandomZr(rng) + } + + // First compute the non-revocation proof. + // The challenge of the ZKP needs to depend on it, as well. + prover, err := getNonRevocationProver(RevocationAlgorithm(cri.RevocationAlg)) + if err != nil { + return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err + } + nonRevokedProofHashData, err := prover.getFSContribution( + curve.NewZrFromBytes(cred.Attrs[rhIndex]), + rAttrs[sort.SearchInts(HiddenIndices, rhIndex)], + cri, + rng, + ) + if err != nil { + return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, errors.Wrap(err, "failed to compute non-revoked proof") + } + + // Step 1: First message (t-values) + + HAttrs := make([]*math.G1, len(ipk.HAttrs)) + for i := range ipk.HAttrs { + var err error + HAttrs[i], err = tr.G1FromProto(ipk.HAttrs[i]) + if err != nil { + return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err + } + } + + // t1 is related to knowledge of the credential (recall, it is a BBS+ signature) + t1 := APrime.Mul2(re, HRand, rR2) // A'^{r_E} \cdot h_r^{r_{r2}} + + // t2: is related to knowledge of the non-disclosed attributes that signed in (A,B,S,E) + t2 := HRand.Mul(rSPrime) // h_r^{r_{s'}} + t2.Add(BPrime.Mul2(rR3, HSk, rSk)) // B'^{r_{r3}} \cdot h_{sk}^{r_{sk}} + for i := 0; i < len(HiddenIndices)/2; i++ { + t2.Add( + // \cdot h_{2 \cdot i}^{r_{attrs,i} + HAttrs[HiddenIndices[2*i]].Mul2( + rAttrs[2*i], + HAttrs[HiddenIndices[2*i+1]], + rAttrs[2*i+1], + ), + ) + } + if len(HiddenIndices)%2 != 0 { + t2.Add(HAttrs[HiddenIndices[len(HiddenIndices)-1]].Mul(rAttrs[len(HiddenIndices)-1])) + } + + // t3 is related to the knowledge of the secrets behind the pseudonym, which is also signed in (A,B,S,E) + t3 := HSk.Mul2(rSk, HRand, rRNym) // h_{sk}^{r_{sk}} \cdot h_r^{r_{rnym}} + + return t1, t2, t3, + APrime, ABar, BPrime, + nonRevokedProofHashData, + E, + Nonce, + rSk, rSPrime, rR2, rR3, r2, r3, re, sPrime, rRNym, + rAttrs, + prover, + HiddenIndices, nil +} + +func finalise( + cred *Credential, + sk *math.Zr, + Nym *math.G1, + RNym *math.Zr, + ipk *IssuerPublicKey, + Disclosure []byte, + msg []byte, + rhIndex, eidIndex int, + cri *CredentialRevocationInformation, + rng io.Reader, + curve *math.Curve, + tr Translator, + t1, t2, t3 *math.G1, + APrime, ABar, BPrime *math.G1, + nonRevokedProofHashData []byte, + E *math.Zr, + Nonce *math.Zr, + rSk, rSPrime, rR2, rR3, r2, r3, re, sPrime, rRNym *math.Zr, + rAttrs []*math.Zr, + prover nonRevokedProver, + HiddenIndices []int, + sigType opts.SignatureType, +) (*Signature, *opts.IdemixSignerMetadata, error) { + + var Nym_eid *math.G1 + var t4 *math.G1 + var r_r_eid, r_eid *math.Zr + if sigType == opts.EidNym { + r_a_eid := rAttrs[sort.SearchInts(HiddenIndices, eidIndex)] + H_a_eid, err := tr.G1FromProto(ipk.HAttrs[eidIndex]) + if err != nil { + return nil, nil, err + } + + a_eid := curve.NewZrFromBytes(cred.Attrs[eidIndex]) + HRand, err := tr.G1FromProto(ipk.HRand) + if err != nil { + return nil, nil, err + } + + // Generate new required randomness r_eid and r_r_eid + r_eid = curve.NewRandomZr(rng) + r_r_eid = curve.NewRandomZr(rng) + + // Nym_eid is a hiding and binding commitment to the enrollment id + Nym_eid = H_a_eid.Mul2(a_eid, HRand, r_eid) // H_{a_{eid}}^{a_{eid}} \cdot H_{r}^{r_{eid}} + + // t4 is the new t-value for the eid nym computed above + t4 = H_a_eid.Mul2(r_a_eid, HRand, r_r_eid) // H_{a_{eid}}^{r_{a_{2}}} \cdot H_{r}^{r_{r_{eid}}} + } + + // Step 2: Compute the Fiat-Shamir hash, forming the challenge of the ZKP. + + // Compute the Fiat-Shamir hash, forming the challenge of the ZKP. + // proofData is the data being hashed, it consists of: + // the signature label + // 7 elements of G1 each taking 2*math.FieldBytes+1 bytes + // one bigint (hash of the issuer public key) of length math.FieldBytes + // disclosed attributes + // message being signed + // the amount of bytes needed for the nonrevocation proof + pdl := len([]byte(signLabel)) + 7*(2*curve.FieldBytes+1) + curve.FieldBytes + len(Disclosure) + len(msg) + ProofBytes[RevocationAlgorithm(cri.RevocationAlg)] + if sigType == opts.EidNym { + pdl = len([]byte(signWithEidNymLabel)) + 9*(2*curve.FieldBytes+1) + curve.FieldBytes + len(Disclosure) + len(msg) + ProofBytes[RevocationAlgorithm(cri.RevocationAlg)] + } + proofData := make([]byte, pdl) + index := 0 + switch sigType { + case opts.Standard: + index = appendBytesString(proofData, index, signLabel) + case opts.EidNym: + index = appendBytesString(proofData, index, signWithEidNymLabel) + default: + panic("programming error") + } + index = appendBytesG1(proofData, index, t1) + index = appendBytesG1(proofData, index, t2) + index = appendBytesG1(proofData, index, t3) + index = appendBytesG1(proofData, index, APrime) + index = appendBytesG1(proofData, index, ABar) + index = appendBytesG1(proofData, index, BPrime) + index = appendBytesG1(proofData, index, Nym) + if sigType == opts.EidNym { + index = appendBytesG1(proofData, index, Nym_eid) + index = appendBytesG1(proofData, index, t4) + } + index = appendBytes(proofData, index, nonRevokedProofHashData) + copy(proofData[index:], ipk.Hash) + index = index + curve.FieldBytes + copy(proofData[index:], Disclosure) + index = index + len(Disclosure) + copy(proofData[index:], msg) + c := curve.HashToZr(proofData) + + // add the previous hash and the nonce and hash again to compute a second hash (C value) + index = 0 + proofData = proofData[:2*curve.FieldBytes] + index = appendBytesBig(proofData, index, c) + appendBytesBig(proofData, index, Nonce) + ProofC := curve.HashToZr(proofData) + + // Step 3: reply to the challenge message (s-values) + ProofSSk := curve.ModAdd(rSk, curve.ModMul(ProofC, sk, curve.GroupOrder), curve.GroupOrder) // s_sk = rSK + C \cdot sk + ProofSE := curve.ModSub(re, curve.ModMul(ProofC, E, curve.GroupOrder), curve.GroupOrder) // s_e = re + C \cdot E + ProofSR2 := curve.ModAdd(rR2, curve.ModMul(ProofC, r2, curve.GroupOrder), curve.GroupOrder) // s_r2 = rR2 + C \cdot r2 + ProofSR3 := curve.ModSub(rR3, curve.ModMul(ProofC, r3, curve.GroupOrder), curve.GroupOrder) // s_r3 = rR3 + C \cdot r3 + ProofSSPrime := curve.ModAdd(rSPrime, curve.ModMul(ProofC, sPrime, curve.GroupOrder), curve.GroupOrder) // s_S' = rSPrime + C \cdot sPrime + ProofSRNym := curve.ModAdd(rRNym, curve.ModMul(ProofC, RNym, curve.GroupOrder), curve.GroupOrder) // s_RNym = rRNym + C \cdot RNym + ProofSAttrs := make([][]byte, len(HiddenIndices)) + for i, j := range HiddenIndices { + ProofSAttrs[i] = + // s_attrsi = rAttrsi + C \cdot cred.Attrs[j] + curve.ModAdd(rAttrs[i], curve.ModMul(ProofC, curve.NewZrFromBytes(cred.Attrs[j]), curve.GroupOrder), curve.GroupOrder).Bytes() + } + + // Compute the revocation part + nonRevokedProof, err := prover.getNonRevokedProof(ProofC) + if err != nil { + return nil, nil, err + } + + // logger.Printf("Signature Generation : \n"+ + // " [t1:%v]\n,"+ + // " [t2:%v]\n,"+ + // " [t3:%v]\n,"+ + // " [APrime:%v]\n,"+ + // " [ABar:%v]\n,"+ + // " [BPrime:%v]\n,"+ + // " [Nym:%v]\n,"+ + // " [nonRevokedProofBytes:%v]\n,"+ + // " [ipk.Hash:%v]\n,"+ + // " [Disclosure:%v]\n,"+ + // " [msg:%v]\n,"+ + // " [ProofData:%v]\n,"+ + // " [ProofC:%v]\n"+ + // " [HSk:%v]\n,"+ + // " [ProofSSK:%v]\n,"+ + // " [HRand:%v]\n,"+ + // " [ProofSRNym:%v]\n", + // t1.Bytes(), + // t2.Bytes(), + // t3.Bytes(), + // APrime.Bytes(), + // ABar.Bytes(), + // BPrime.Bytes(), + // Nym.Bytes(), + // nil, + // ipk.Hash, + // Disclosure, + // msg, + // proofData, + // ProofC.Bytes(), + // HSk.Bytes(), + // ProofSSk.Bytes(), + // HRand.Bytes(), + // ProofSRNym.Bytes(), + // ) + + // We are done. Return signature + sig := &Signature{ + APrime: tr.G1ToProto(APrime), + ABar: tr.G1ToProto(ABar), + BPrime: tr.G1ToProto(BPrime), + ProofC: ProofC.Bytes(), + ProofSSk: ProofSSk.Bytes(), + ProofSE: ProofSE.Bytes(), + ProofSR2: ProofSR2.Bytes(), + ProofSR3: ProofSR3.Bytes(), + ProofSSPrime: ProofSSPrime.Bytes(), + ProofSAttrs: ProofSAttrs, + Nonce: Nonce.Bytes(), + Nym: tr.G1ToProto(Nym), + ProofSRNym: ProofSRNym.Bytes(), + RevocationEpochPk: cri.EpochPk, + RevocationPkSig: cri.EpochPkSig, + Epoch: cri.Epoch, + NonRevocationProof: nonRevokedProof, + } + + if sigType == opts.EidNym { + ProofSEid := curve.ModAdd(r_r_eid, curve.ModMul(ProofC, r_eid, curve.GroupOrder), curve.GroupOrder) // s_{r{eid}} = r_r_eid + C \cdot r_eid + sig.EidNym = &EIDNym{ + Nym: tr.G1ToProto(Nym_eid), + ProofSEid: ProofSEid.Bytes(), + } + } + + var m *opts.IdemixSignerMetadata + if sigType == opts.EidNym { + m = &opts.IdemixSignerMetadata{ + NymEIDAuditData: &opts.NymEIDAuditData{ + RNymEid: r_eid, + EID: curve.NewZrFromBytes(cred.Attrs[eidIndex]), + }, + } + } + + return sig, m, nil +} + +func (sig *Signature) AuditNymEid( + ipk *IssuerPublicKey, + eidAttr *math.Zr, + eidIndex int, + RNymEid *math.Zr, + curve *math.Curve, + t Translator, +) error { + // Validate inputs + if ipk == nil { + return errors.Errorf("cannot verify idemix signature: received nil input") + } + + if sig.EidNym == nil || sig.EidNym.Nym == nil { + return errors.Errorf("no EidNym provided") + } + + if len(ipk.HAttrs) <= eidIndex { + return errors.Errorf("could not access H_a_eid in array") + } + + H_a_eid, err := t.G1FromProto(ipk.HAttrs[eidIndex]) + if err != nil { + return errors.Wrap(err, "could not deserialize H_a_eid") + } + + HRand, err := t.G1FromProto(ipk.HRand) + if err != nil { + return errors.Wrap(err, "could not deserialize HRand") + } + + EidNym, err := t.G1FromProto(sig.EidNym.Nym) + if err != nil { + return errors.Wrap(err, "could not deserialize EidNym") + } + + Nym_eid := H_a_eid.Mul2(eidAttr, HRand, RNymEid) + + if !Nym_eid.Equals(EidNym) { + return errors.New("eid nym does not match") + } + + return nil +} + +// Ver verifies an idemix signature +// Disclosure steers which attributes it expects to be disclosed +// attributeValues contains the desired attribute values. +// This function will check that if attribute i is disclosed, the i-th attribute equals attributeValues[i]. +func (sig *Signature) Ver( + Disclosure []byte, + ipk *IssuerPublicKey, + msg []byte, + attributeValues []*math.Zr, + rhIndex, eidIndex int, + revPk *ecdsa.PublicKey, + epoch int, + curve *math.Curve, + t Translator, + verType opts.VerificationType, + meta *opts.IdemixSignerMetadata, +) error { + // Validate inputs + if ipk == nil || revPk == nil { + return errors.Errorf("cannot verify idemix signature: received nil input") + } + + if rhIndex < 0 || rhIndex >= len(ipk.AttributeNames) || len(Disclosure) != len(ipk.AttributeNames) { + return errors.Errorf("cannot verify idemix signature: received invalid input") + } + + if sig.NonRevocationProof.RevocationAlg != int32(ALG_NO_REVOCATION) && Disclosure[rhIndex] == 1 { + return errors.Errorf("Attribute %d is disclosed but is also used as revocation handle, which should remain hidden.", rhIndex) + } + + if verType == opts.ExpectEidNym && + (sig.EidNym == nil || sig.EidNym.Nym == nil || sig.EidNym.ProofSEid == nil) { + return errors.Errorf("no EidNym provided but ExpectEidNym required") + } + + if verType == opts.ExpectStandard && sig.EidNym != nil { + return errors.Errorf("EidNym available but ExpectStandard required") + } + + verifyEIDNym := (verType == opts.BestEffort && sig.EidNym != nil) || verType == opts.ExpectEidNym + + HiddenIndices := hiddenIndices(Disclosure) + + // Parse signature + APrime, err := t.G1FromProto(sig.GetAPrime()) + if err != nil { + return err + } + //logger.Printf("Signature Verification : \n"+ + // " [APrime:%v]\n", + // APrime.Bytes(), + //) + ABar, err := t.G1FromProto(sig.GetABar()) + if err != nil { + return err + } + //logger.Printf("Signature Verification : \n"+ + // " [ABar:%v]\n", + // ABar.Bytes(), + //) + BPrime, err := t.G1FromProto(sig.GetBPrime()) + if err != nil { + return err + } + Nym, err := t.G1FromProto(sig.GetNym()) + if err != nil { + return err + } + ProofC := curve.NewZrFromBytes(sig.GetProofC()) + ProofSSk := curve.NewZrFromBytes(sig.GetProofSSk()) + ProofSE := curve.NewZrFromBytes(sig.GetProofSE()) + ProofSR2 := curve.NewZrFromBytes(sig.GetProofSR2()) + ProofSR3 := curve.NewZrFromBytes(sig.GetProofSR3()) + ProofSSPrime := curve.NewZrFromBytes(sig.GetProofSSPrime()) + ProofSRNym := curve.NewZrFromBytes(sig.GetProofSRNym()) + ProofSAttrs := make([]*math.Zr, len(sig.GetProofSAttrs())) + + if len(sig.ProofSAttrs) != len(HiddenIndices) { + return errors.Errorf("signature invalid: incorrect amount of s-values for AttributeProofSpec") + } + for i, b := range sig.ProofSAttrs { + ProofSAttrs[i] = curve.NewZrFromBytes(b) + } + Nonce := curve.NewZrFromBytes(sig.GetNonce()) + + // Parse issuer public key + W, err := t.G2FromProto(ipk.W) + if err != nil { + return err + } + HRand, err := t.G1FromProto(ipk.HRand) + if err != nil { + return err + } + HSk, err := t.G1FromProto(ipk.HSk) + if err != nil { + return err + } + //logger.Printf("Signature Verification : \n"+ + // " [W:%v]\n", + // W.Bytes(), + //) + + // Verify signature + if APrime.IsInfinity() { + return errors.Errorf("signature invalid: APrime = 1") + } + temp1 := curve.Pairing(W, APrime) + temp2 := curve.Pairing(curve.GenG2, ABar) + temp2.Inverse() + temp1.Mul(temp2) + if !curve.FExp(temp1).IsUnity() { + return errors.Errorf("signature invalid: APrime and ABar don't have the expected structure") + } + + // Verify ZK proof + + // Recover t-values + + HAttrs := make([]*math.G1, len(ipk.HAttrs)) + for i := range ipk.HAttrs { + var err error + HAttrs[i], err = t.G1FromProto(ipk.HAttrs[i]) + if err != nil { + return err + } + } + + // Recompute t1 + t1 := APrime.Mul2(ProofSE, HRand, ProofSR2) + temp := curve.NewG1() + temp.Clone(ABar) + temp.Sub(BPrime) + t1.Sub(temp.Mul(ProofC)) + + // Recompute t2 + t2 := HRand.Mul(ProofSSPrime) + t2.Add(BPrime.Mul2(ProofSR3, HSk, ProofSSk)) + for i := 0; i < len(HiddenIndices)/2; i++ { + t2.Add(HAttrs[HiddenIndices[2*i]].Mul2(ProofSAttrs[2*i], HAttrs[HiddenIndices[2*i+1]], ProofSAttrs[2*i+1])) + } + if len(HiddenIndices)%2 != 0 { + t2.Add(HAttrs[HiddenIndices[len(HiddenIndices)-1]].Mul(ProofSAttrs[len(HiddenIndices)-1])) + } + temp = curve.NewG1() + temp.Clone(curve.GenG1) + for index, disclose := range Disclosure { + if disclose != 0 { + temp.Add(HAttrs[index].Mul(attributeValues[index])) + } + } + t2.Add(temp.Mul(ProofC)) + + // Recompute t3 + t3 := HSk.Mul2(ProofSSk, HRand, ProofSRNym) + t3.Sub(Nym.Mul(ProofC)) + + var t4 *math.G1 + if verifyEIDNym { + H_a_eid, err := t.G1FromProto(ipk.HAttrs[eidIndex]) + if err != nil { + return err + } + + t4 = H_a_eid.Mul2(ProofSAttrs[sort.SearchInts(HiddenIndices, eidIndex)], HRand, curve.NewZrFromBytes(sig.EidNym.ProofSEid)) + EidNym, err := t.G1FromProto(sig.EidNym.Nym) + if err != nil { + return err + } + t4.Sub(EidNym.Mul(ProofC)) + } + + // add contribution from the non-revocation proof + nonRevokedVer, err := getNonRevocationVerifier(RevocationAlgorithm(sig.NonRevocationProof.RevocationAlg)) + if err != nil { + return err + } + + i := sort.SearchInts(HiddenIndices, rhIndex) + proofSRh := ProofSAttrs[i] + RevocationEpochPk, err := t.G2FromProto(sig.RevocationEpochPk) + if err != nil { + return err + } + + nonRevokedProofBytes, err := nonRevokedVer.recomputeFSContribution(sig.NonRevocationProof, ProofC, RevocationEpochPk, proofSRh) + if err != nil { + return err + } + + // Recompute challenge + // proofData is the data being hashed, it consists of: + // the signature label + // 7 elements of G1 each taking 2*math.FieldBytes+1 bytes + // one bigint (hash of the issuer public key) of length math.FieldBytes + // disclosed attributes + // message that was signed + pdl := len([]byte(signLabel)) + 7*(2*curve.FieldBytes+1) + curve.FieldBytes + len(Disclosure) + len(msg) + ProofBytes[RevocationAlgorithm(sig.NonRevocationProof.RevocationAlg)] + if verifyEIDNym { + pdl = len([]byte(signWithEidNymLabel)) + 9*(2*curve.FieldBytes+1) + curve.FieldBytes + len(Disclosure) + len(msg) + ProofBytes[RevocationAlgorithm(sig.NonRevocationProof.RevocationAlg)] + } + proofData := make([]byte, pdl) + index := 0 + if verifyEIDNym { + index = appendBytesString(proofData, index, signWithEidNymLabel) + } else { + index = appendBytesString(proofData, index, signLabel) + } + index = appendBytesG1(proofData, index, t1) + index = appendBytesG1(proofData, index, t2) + index = appendBytesG1(proofData, index, t3) + index = appendBytesG1(proofData, index, APrime) + index = appendBytesG1(proofData, index, ABar) + index = appendBytesG1(proofData, index, BPrime) + index = appendBytesG1(proofData, index, Nym) + if verifyEIDNym { + Nym, err := t.G1FromProto(sig.EidNym.Nym) + if err != nil { + return err + } + + index = appendBytesG1(proofData, index, Nym) + index = appendBytesG1(proofData, index, t4) + } + index = appendBytes(proofData, index, nonRevokedProofBytes) + copy(proofData[index:], ipk.Hash) + index = index + curve.FieldBytes + copy(proofData[index:], Disclosure) + index = index + len(Disclosure) + copy(proofData[index:], msg) + + c := curve.HashToZr(proofData) + index = 0 + proofData = proofData[:2*curve.FieldBytes] + index = appendBytesBig(proofData, index, c) + appendBytesBig(proofData, index, Nonce) + + // audit eid nym if data provided and verification requested + if verifyEIDNym && meta != nil && meta.NymEIDAuditData != nil { + H_a_eid, err := t.G1FromProto(ipk.HAttrs[eidIndex]) + if err != nil { + return err + } + + EidNym, err := t.G1FromProto(sig.EidNym.Nym) + if err != nil { + return err + } + + Nym_eid := H_a_eid.Mul2(meta.NymEIDAuditData.EID, HRand, meta.NymEIDAuditData.RNymEid) + if !Nym_eid.Equals(EidNym) { + return errors.Errorf("signature invalid: nym eid validation failed") + } + } + + recomputedProofC := curve.HashToZr(proofData) + if !ProofC.Equals(recomputedProofC) { + // This debug line helps identify where the mismatch happened + logger.Printf("Signature Verification : \n"+ + " [t1:%v]\n,"+ + " [t2:%v]\n,"+ + " [t3:%v]\n,"+ + " [APrime:%v]\n,"+ + " [ABar:%v]\n,"+ + " [BPrime:%v]\n,"+ + " [Nym:%v]\n,"+ + " [nonRevokedProofBytes:%v]\n,"+ + " [ipk.Hash:%v]\n,"+ + " [Disclosure:%v]\n,"+ + " [msg:%v]\n,"+ + " [proofdata:%v]\n,"+ + " [ProofC:%v]\n,"+ + " [recomputedProofC:%v]\n,"+ + " [HSk:%v]\n,"+ + " [ProofSSK:%v]\n,"+ + " [HRand:%v]\n,"+ + " [ProofSRNym:%v]\n", + t1.Bytes(), + t2.Bytes(), + t3.Bytes(), + APrime.Bytes(), + ABar.Bytes(), + BPrime.Bytes(), + Nym.Bytes(), + nonRevokedProofBytes, + ipk.Hash, + Disclosure, + msg, + proofData, + ProofC.Bytes(), + recomputedProofC.Bytes(), + HSk.Bytes(), + ProofSSk.Bytes(), + HRand.Bytes(), + ProofSRNym.Bytes(), + ) + return errors.Errorf("signature invalid: zero-knowledge proof is invalid") + } + + // Signature is valid + return nil +} diff --git a/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl/amcl.pb.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl/amcl.pb.go new file mode 100644 index 00000000000..2a7a385ca82 --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl/amcl.pb.go @@ -0,0 +1,160 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: bccsp/schemes/dlog/crypto/translator/amcl/amcl.proto + +package amcl + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +// ECP is an elliptic curve point specified by its coordinates +// ECP corresponds to an element of the first group (G1) +type ECP struct { + X []byte `protobuf:"bytes,1,opt,name=x,proto3" json:"x,omitempty"` + Y []byte `protobuf:"bytes,2,opt,name=y,proto3" json:"y,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ECP) Reset() { *m = ECP{} } +func (m *ECP) String() string { return proto.CompactTextString(m) } +func (*ECP) ProtoMessage() {} +func (*ECP) Descriptor() ([]byte, []int) { + return fileDescriptor_250ddfa5c5f8dbbb, []int{0} +} + +func (m *ECP) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ECP.Unmarshal(m, b) +} +func (m *ECP) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ECP.Marshal(b, m, deterministic) +} +func (m *ECP) XXX_Merge(src proto.Message) { + xxx_messageInfo_ECP.Merge(m, src) +} +func (m *ECP) XXX_Size() int { + return xxx_messageInfo_ECP.Size(m) +} +func (m *ECP) XXX_DiscardUnknown() { + xxx_messageInfo_ECP.DiscardUnknown(m) +} + +var xxx_messageInfo_ECP proto.InternalMessageInfo + +func (m *ECP) GetX() []byte { + if m != nil { + return m.X + } + return nil +} + +func (m *ECP) GetY() []byte { + if m != nil { + return m.Y + } + return nil +} + +// ECP2 is an elliptic curve point specified by its coordinates +// ECP2 corresponds to an element of the second group (G2) +type ECP2 struct { + Xa []byte `protobuf:"bytes,1,opt,name=xa,proto3" json:"xa,omitempty"` + Xb []byte `protobuf:"bytes,2,opt,name=xb,proto3" json:"xb,omitempty"` + Ya []byte `protobuf:"bytes,3,opt,name=ya,proto3" json:"ya,omitempty"` + Yb []byte `protobuf:"bytes,4,opt,name=yb,proto3" json:"yb,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ECP2) Reset() { *m = ECP2{} } +func (m *ECP2) String() string { return proto.CompactTextString(m) } +func (*ECP2) ProtoMessage() {} +func (*ECP2) Descriptor() ([]byte, []int) { + return fileDescriptor_250ddfa5c5f8dbbb, []int{1} +} + +func (m *ECP2) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ECP2.Unmarshal(m, b) +} +func (m *ECP2) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ECP2.Marshal(b, m, deterministic) +} +func (m *ECP2) XXX_Merge(src proto.Message) { + xxx_messageInfo_ECP2.Merge(m, src) +} +func (m *ECP2) XXX_Size() int { + return xxx_messageInfo_ECP2.Size(m) +} +func (m *ECP2) XXX_DiscardUnknown() { + xxx_messageInfo_ECP2.DiscardUnknown(m) +} + +var xxx_messageInfo_ECP2 proto.InternalMessageInfo + +func (m *ECP2) GetXa() []byte { + if m != nil { + return m.Xa + } + return nil +} + +func (m *ECP2) GetXb() []byte { + if m != nil { + return m.Xb + } + return nil +} + +func (m *ECP2) GetYa() []byte { + if m != nil { + return m.Ya + } + return nil +} + +func (m *ECP2) GetYb() []byte { + if m != nil { + return m.Yb + } + return nil +} + +func init() { + proto.RegisterType((*ECP)(nil), "amcl.ECP") + proto.RegisterType((*ECP2)(nil), "amcl.ECP2") +} + +func init() { + proto.RegisterFile("bccsp/schemes/dlog/crypto/translator/amcl/amcl.proto", fileDescriptor_250ddfa5c5f8dbbb) +} + +var fileDescriptor_250ddfa5c5f8dbbb = []byte{ + // 185 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x49, 0x4a, 0x4e, 0x2e, + 0x2e, 0xd0, 0x2f, 0x4e, 0xce, 0x48, 0xcd, 0x4d, 0x2d, 0xd6, 0x4f, 0xc9, 0xc9, 0x4f, 0xd7, 0x4f, + 0x2e, 0xaa, 0x2c, 0x28, 0xc9, 0xd7, 0x2f, 0x29, 0x4a, 0xcc, 0x2b, 0xce, 0x49, 0x2c, 0xc9, 0x2f, + 0xd2, 0x4f, 0xcc, 0x4d, 0xce, 0x01, 0x13, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x2c, 0x20, + 0xb6, 0x92, 0x22, 0x17, 0xb3, 0xab, 0x73, 0x80, 0x10, 0x0f, 0x17, 0x63, 0x85, 0x04, 0xa3, 0x02, + 0xa3, 0x06, 0x4f, 0x10, 0x63, 0x05, 0x88, 0x57, 0x29, 0xc1, 0x04, 0xe1, 0x55, 0x2a, 0xb9, 0x71, + 0xb1, 0xb8, 0x3a, 0x07, 0x18, 0x09, 0xf1, 0x71, 0x31, 0x55, 0x24, 0x42, 0x15, 0x31, 0x55, 0x24, + 0x82, 0xf9, 0x49, 0x50, 0x65, 0x4c, 0x15, 0x49, 0x20, 0x7e, 0x65, 0xa2, 0x04, 0x33, 0x84, 0x5f, + 0x09, 0x96, 0xaf, 0x4c, 0x92, 0x60, 0x81, 0xf2, 0x93, 0x9c, 0x1c, 0xa3, 0xec, 0xd3, 0x33, 0x4b, + 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x3d, 0x9d, 0x7c, 0xf5, 0x33, 0x53, 0x52, 0x73, + 0x33, 0x2b, 0xf4, 0x89, 0x76, 0x7e, 0x12, 0x1b, 0xd8, 0xe9, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xae, 0x4d, 0xeb, 0xe4, 0xf2, 0x00, 0x00, 0x00, +} diff --git a/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl/amcl.proto b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl/amcl.proto new file mode 100644 index 00000000000..6ecfef314d1 --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl/amcl.proto @@ -0,0 +1,32 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +syntax = "proto3"; + +package amcl; + +option go_package = "github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl"; + +// The Identity Mixer protocols make use of pairings (bilinear maps) - +// functions that can be described as e: G1 x G2 -> GT that +// map group elements from the source groups (G1 and G2) to the target group +// Such groups can be represented by the points on an elliptic curve + +// ECP is an elliptic curve point specified by its coordinates +// ECP corresponds to an element of the first group (G1) +message ECP { + bytes x = 1; + bytes y = 2; +} + +// ECP2 is an elliptic curve point specified by its coordinates +// ECP2 corresponds to an element of the second group (G2) +message ECP2 { + bytes xa = 1; + bytes xb = 2; + bytes ya = 3; + bytes yb = 4; +} \ No newline at end of file diff --git a/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl/fp256bn.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl/fp256bn.go new file mode 100644 index 00000000000..6ba11b6590d --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl/fp256bn.go @@ -0,0 +1,168 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package amcl + +import ( + fmt "fmt" + + math "github.com/IBM/mathlib" +) + +type Fp256bn struct { + C *math.Curve +} + +func (a *Fp256bn) G1ToProto(g1 *math.G1) *ECP { + if g1 == nil { + panic("nil argument") + } + + bytes := g1.Bytes()[1:] + l := len(bytes) / 2 + return &ECP{ + X: bytes[:l], + Y: bytes[l:], + } +} + +func (a *Fp256bn) G1FromRawBytes(raw []byte) (*math.G1, error) { + l := len(raw) / 2 + + return a.G1FromProto(&ECP{ + X: raw[:l], + Y: raw[l:], + }) +} + +func (a *Fp256bn) G1FromProto(e *ECP) (*math.G1, error) { + if e == nil { + return nil, fmt.Errorf("nil argument") + } + + if len(e.X) != a.C.FieldBytes || len(e.Y) != a.C.FieldBytes { + return nil, fmt.Errorf("invalid marshalled length") + } + + bytes := make([]byte, len(e.X)*2+1) + l := len(e.X) + bytes[0] = 0x04 + copy(bytes[1:], e.X) + copy(bytes[l+1:], e.Y) + return a.C.NewG1FromBytes(bytes) +} + +func (a *Fp256bn) G2ToProto(g2 *math.G2) *ECP2 { + if g2 == nil { + panic("nil argument") + } + + bytes := g2.Bytes() + l := len(bytes) / 4 + return &ECP2{ + Xa: bytes[0:l], + Xb: bytes[l : 2*l], + Ya: bytes[2*l : 3*l], + Yb: bytes[3*l:], + } + +} + +func (a *Fp256bn) G2FromProto(e *ECP2) (*math.G2, error) { + if e == nil { + return nil, fmt.Errorf("nil argument") + } + + if len(e.Xa) != a.C.FieldBytes || len(e.Xb) != a.C.FieldBytes || len(e.Ya) != a.C.FieldBytes || len(e.Yb) != a.C.FieldBytes { + return nil, fmt.Errorf("invalid marshalled length") + } + + bytes := make([]byte, len(e.Xa)*4) + l := len(e.Xa) + copy(bytes[0:l], e.Xa) + copy(bytes[l:2*l], e.Xb) + copy(bytes[2*l:3*l], e.Ya) + copy(bytes[3*l:], e.Yb) + return a.C.NewG2FromBytes(bytes) +} + +type Fp256bnMiracl struct { + C *math.Curve +} + +func (a *Fp256bnMiracl) G1ToProto(g1 *math.G1) *ECP { + if g1 == nil { + panic("nil argument") + } + + bytes := g1.Bytes()[1:] + l := len(bytes) / 2 + return &ECP{ + X: bytes[:l], + Y: bytes[l:], + } +} + +func (a *Fp256bnMiracl) G1FromRawBytes(raw []byte) (*math.G1, error) { + l := len(raw) / 2 + + return a.G1FromProto(&ECP{ + X: raw[:l], + Y: raw[l:], + }) +} + +func (a *Fp256bnMiracl) G1FromProto(e *ECP) (*math.G1, error) { + if e == nil { + return nil, fmt.Errorf("nil argument") + } + + if len(e.X) != a.C.FieldBytes || len(e.Y) != a.C.FieldBytes { + return nil, fmt.Errorf("invalid marshalled length") + } + + bytes := make([]byte, len(e.X)*2+1) + l := len(e.X) + bytes[0] = 0x04 + copy(bytes[1:], e.X) + copy(bytes[l+1:], e.Y) + return a.C.NewG1FromBytes(bytes) +} + +func (a *Fp256bnMiracl) G2ToProto(g2 *math.G2) *ECP2 { + if g2 == nil { + panic("nil argument") + } + + bytes := g2.Bytes()[1:] + l := len(bytes) / 4 + return &ECP2{ + Xa: bytes[0:l], + Xb: bytes[l : 2*l], + Ya: bytes[2*l : 3*l], + Yb: bytes[3*l:], + } + +} + +func (a *Fp256bnMiracl) G2FromProto(e *ECP2) (*math.G2, error) { + if e == nil { + return nil, fmt.Errorf("nil argument") + } + + if len(e.Xa) != a.C.FieldBytes || len(e.Xb) != a.C.FieldBytes || len(e.Ya) != a.C.FieldBytes || len(e.Yb) != a.C.FieldBytes { + return nil, fmt.Errorf("invalid marshalled length") + } + + bytes := make([]byte, 1+len(e.Xa)*4) + bytes[0] = 0x04 + l := len(e.Xa) + copy(bytes[1:], e.Xa) + copy(bytes[1+l:], e.Xb) + copy(bytes[1+2*l:], e.Ya) + copy(bytes[1+3*l:], e.Yb) + return a.C.NewG2FromBytes(bytes) +} diff --git a/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl/gurvy.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl/gurvy.go new file mode 100644 index 00000000000..2be82f27294 --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl/gurvy.go @@ -0,0 +1,64 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package amcl + +import ( + math "github.com/IBM/mathlib" +) + +type Gurvy struct { + C *math.Curve +} + +func (a *Gurvy) G1ToProto(g1 *math.G1) *ECP { + bytes := g1.Bytes() + + l := len(bytes) / 2 + return &ECP{ + X: bytes[:l], + Y: bytes[l:], + } +} + +func (a *Gurvy) G1FromRawBytes(raw []byte) (*math.G1, error) { + l := len(raw) / 2 + + return a.G1FromProto(&ECP{ + X: raw[:l], + Y: raw[l:], + }) +} + +func (a *Gurvy) G1FromProto(e *ECP) (*math.G1, error) { + bytes := make([]byte, len(e.X)*2) + l := len(e.X) + copy(bytes, e.X) + copy(bytes[l:], e.Y) + return a.C.NewG1FromBytes(bytes) +} + +func (a *Gurvy) G2ToProto(g2 *math.G2) *ECP2 { + bytes := g2.Bytes() + l := len(bytes) / 4 + return &ECP2{ + Xa: bytes[0:l], + Xb: bytes[l : 2*l], + Ya: bytes[2*l : 3*l], + Yb: bytes[3*l:], + } + +} + +func (a *Gurvy) G2FromProto(e *ECP2) (*math.G2, error) { + bytes := make([]byte, len(e.Xa)*4) + l := len(e.Xa) + copy(bytes[0:l], e.Xa) + copy(bytes[l:2*l], e.Xb) + copy(bytes[2*l:3*l], e.Ya) + copy(bytes[3*l:], e.Yb) + return a.C.NewG2FromBytes(bytes) +} diff --git a/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/util.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/util.go new file mode 100644 index 00000000000..6edeaabe337 --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/util.go @@ -0,0 +1,71 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package idemix + +import ( + "io" + + amcl "github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl" + math "github.com/IBM/mathlib" +) + +func appendBytes(data []byte, index int, bytesToAdd []byte) int { + copy(data[index:], bytesToAdd) + return index + len(bytesToAdd) +} +func appendBytesG1(data []byte, index int, E *math.G1) int { + return appendBytes(data, index, E.Bytes()) +} +func appendBytesG2(data []byte, index int, E *math.G2) int { + return appendBytes(data, index, E.Bytes()) +} +func appendBytesBig(data []byte, index int, B *math.Zr) int { + return appendBytes(data, index, B.Bytes()) +} +func appendBytesString(data []byte, index int, s string) int { + bytes := []byte(s) + copy(data[index:], bytes) + return index + len(bytes) +} + +// MakeNym creates a new unlinkable pseudonym +func (i *Idemix) MakeNym(sk *math.Zr, IPk *IssuerPublicKey, rng io.Reader, t Translator) (*math.G1, *math.Zr, error) { + return makeNym(sk, IPk, rng, i.Curve, t) +} + +func makeNym(sk *math.Zr, IPk *IssuerPublicKey, rng io.Reader, curve *math.Curve, t Translator) (*math.G1, *math.Zr, error) { + // Construct a commitment to the sk + // Nym = h_{sk}^sk \cdot h_r^r + RandNym := curve.NewRandomZr(rng) + HSk, err := t.G1FromProto(IPk.HSk) + if err != nil { + return nil, nil, err + } + HRand, err := t.G1FromProto(IPk.HRand) + if err != nil { + return nil, nil, err + } + Nym := HSk.Mul2(sk, HRand, RandNym) + return Nym, RandNym, nil +} + +func (i *Idemix) MakeNymFromBytes(raw []byte) (*math.G1, *math.Zr, error) { + return makeNymFromBytes(i.Curve, raw, i.Translator) +} + +func makeNymFromBytes(curve *math.Curve, raw []byte, translator Translator) (*math.G1, *math.Zr, error) { + RandNym := curve.NewZrFromBytes(raw[:curve.FieldBytes]) + pk, err := translator.G1FromProto(&amcl.ECP{ + X: raw[curve.FieldBytes : 2*curve.FieldBytes], + Y: raw[2*curve.FieldBytes:], + }) + if err != nil { + return nil, nil, err + } + + return pk, RandNym, nil +} diff --git a/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/weak-bb.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/weak-bb.go new file mode 100644 index 00000000000..a228ae67433 --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/crypto/weak-bb.go @@ -0,0 +1,50 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package idemix + +import ( + "io" + + math "github.com/IBM/mathlib" + "github.com/pkg/errors" +) + +// wbbKeyGen creates a fresh weak-Boneh-Boyen signature key pair (http://ia.cr/2004/171) +func wbbKeyGen(curve *math.Curve, rng io.Reader) (*math.Zr, *math.G2) { + // sample sk uniform from Zq + sk := curve.NewRandomZr(rng) + // set pk = g2^sk + pk := curve.GenG2.Mul(sk) + return sk, pk +} + +// wbbSign places a weak Boneh-Boyen signature on message m using secret key sk +func wbbSign(curve *math.Curve, sk *math.Zr, m *math.Zr) *math.G1 { + // compute exp = 1/(m + sk) mod q + exp := curve.ModAdd(sk, m, curve.GroupOrder) + exp.InvModP(curve.GroupOrder) + + // return signature sig = g1^(1/(m + sk)) + return curve.GenG1.Mul(exp) +} + +// wbbVerify verifies a weak Boneh-Boyen signature sig on message m with public key pk +func wbbVerify(curve *math.Curve, pk *math.G2, sig *math.G1, m *math.Zr) error { + if pk == nil || sig == nil || m == nil { + return errors.Errorf("Weak-BB signature invalid: received nil input") + } + // Set P = pk * g2^m + P := curve.NewG2() + P.Clone(pk) + P.Add(curve.GenG2.Mul(m)) + P.Affine() + // check that e(sig, pk * g2^m) = e(g1, g2) + if !curve.FExp(curve.Pairing(P, sig)).Equals(curve.GenGt) { + return errors.Errorf("Weak-BB signature is invalid") + } + return nil +} diff --git a/bccsp/idemix/handlers/cred.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/cred.go similarity index 92% rename from bccsp/idemix/handlers/cred.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/cred.go index 83e792819e0..cf78abd62b0 100644 --- a/bccsp/idemix/handlers/cred.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/cred.go @@ -6,7 +6,7 @@ SPDX-License-Identifier: Apache-2.0 package handlers import ( - "github.com/hyperledger/fabric/bccsp" + bccsp "github.com/IBM/idemix/bccsp/schemes" "github.com/pkg/errors" ) @@ -17,7 +17,7 @@ type CredentialRequestSigner struct { } func (c *CredentialRequestSigner) Sign(k bccsp.Key, digest []byte, opts bccsp.SignerOpts) ([]byte, error) { - userSecretKey, ok := k.(*userSecretKey) + userSecretKey, ok := k.(*UserSecretKey) if !ok { return nil, errors.New("invalid key, expected *userSecretKey") } @@ -33,7 +33,7 @@ func (c *CredentialRequestSigner) Sign(k bccsp.Key, digest []byte, opts bccsp.Si return nil, errors.New("invalid options, expected IssuerPK as *issuerPublicKey") } - return c.CredRequest.Sign(userSecretKey.sk, issuerPK.pk, credentialRequestSignerOpts.IssuerNonce) + return c.CredRequest.Sign(userSecretKey.Sk, issuerPK.pk, credentialRequestSignerOpts.IssuerNonce) } // CredentialRequestVerifier verifies credential requests @@ -87,7 +87,7 @@ type CredentialVerifier struct { } func (v *CredentialVerifier) Verify(k bccsp.Key, signature, digest []byte, opts bccsp.SignerOpts) (valid bool, err error) { - userSecretKey, ok := k.(*userSecretKey) + userSecretKey, ok := k.(*UserSecretKey) if !ok { return false, errors.New("invalid key, expected *userSecretKey") } @@ -106,7 +106,7 @@ func (v *CredentialVerifier) Verify(k bccsp.Key, signature, digest []byte, opts return false, errors.New("invalid signature, it must not be empty") } - err = v.Credential.Verify(userSecretKey.sk, ipk.pk, signature, credOpts.Attributes) + err = v.Credential.Verify(userSecretKey.Sk, ipk.pk, signature, credOpts.Attributes) if err != nil { return false, err } diff --git a/bccsp/idemix/handlers/idemix.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/idemix.go similarity index 77% rename from bccsp/idemix/handlers/idemix.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/idemix.go index 47fb51e3740..fea7d2b9956 100644 --- a/bccsp/idemix/handlers/idemix.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/idemix.go @@ -8,7 +8,8 @@ package handlers import ( "crypto/ecdsa" - "github.com/hyperledger/fabric/bccsp" + bccsp "github.com/IBM/idemix/bccsp/schemes" + math "github.com/IBM/mathlib" ) // IssuerPublicKey is the issuer public key @@ -37,6 +38,10 @@ type Issuer interface { // NewKey generates a new idemix issuer key w.r.t the passed attribute names. NewKey(AttributeNames []string) (IssuerSecretKey, error) + // NewPublicKeyFromBytes converts the passed bytes to an Issuer key + // It makes sure that the so obtained key has the passed attributes, if specified + NewKeyFromBytes(raw []byte, attributes []string) (IssuerSecretKey, error) + // NewPublicKeyFromBytes converts the passed bytes to an Issuer public key // It makes sure that the so obtained public key has the passed attributes, if specified NewPublicKeyFromBytes(raw []byte, attributes []string) (IssuerPublicKey, error) @@ -45,28 +50,30 @@ type Issuer interface { // Big represent a big integer type Big interface { // Bytes returns the byte representation of this key - Bytes() ([]byte, error) + Bytes() []byte } // Ecp represents an elliptic curve point type Ecp interface { // Bytes returns the byte representation of this key - Bytes() ([]byte, error) + Bytes() []byte } // User is a local interface to decouple from the idemix implementation type User interface { // NewKey generates a new User secret key - NewKey() (Big, error) + NewKey() (*math.Zr, error) // NewKeyFromBytes converts the passed bytes to a User secret key - NewKeyFromBytes(raw []byte) (Big, error) + NewKeyFromBytes(raw []byte) (*math.Zr, error) // MakeNym creates a new unlinkable pseudonym - MakeNym(sk Big, key IssuerPublicKey) (Ecp, Big, error) + MakeNym(sk *math.Zr, key IssuerPublicKey) (*math.G1, *math.Zr, error) + + NewNymFromBytes(raw []byte) (*math.G1, *math.Zr, error) // NewPublicNymFromBytes converts the passed bytes to a public nym - NewPublicNymFromBytes(raw []byte) (Ecp, error) + NewPublicNymFromBytes(raw []byte) (*math.G1, error) } // CredRequest is a local interface to decouple from the idemix implementation @@ -74,7 +81,7 @@ type User interface { type CredRequest interface { // Sign creates a new Credential Request, the first message of the interactive credential issuance protocol // (from user to issuer) - Sign(sk Big, ipk IssuerPublicKey, nonce []byte) ([]byte, error) + Sign(sk *math.Zr, ipk IssuerPublicKey, nonce []byte) ([]byte, error) // Verify verifies the credential request Verify(credRequest []byte, ipk IssuerPublicKey, nonce []byte) error @@ -91,7 +98,7 @@ type Credential interface { // Verify cryptographically verifies the credential by verifying the signature // on the attribute values and user's secret key - Verify(sk Big, ipk IssuerPublicKey, credential []byte, attributes []bccsp.IdemixAttribute) error + Verify(sk *math.Zr, ipk IssuerPublicKey, credential []byte, attributes []bccsp.IdemixAttribute) error } // Revocation is a local interface to decouple from the idemix implementation @@ -101,6 +108,9 @@ type Revocation interface { // NewKey generates a long term signing key that will be used for revocation NewKey() (*ecdsa.PrivateKey, error) + // NewKeyFromBytes generates a long term signing key that will be used for revocation from the passed bytes + NewKeyFromBytes(raw []byte) (*ecdsa.PrivateKey, error) + // Sign creates the Credential Revocation Information for a certain time period (epoch). // Users can use the CRI to prove that they are not revoked. // Note that when not using revocation (i.e., alg = ALG_NO_REVOCATION), the entered unrevokedHandles are not used, @@ -132,8 +142,8 @@ type SignatureScheme interface { // rhIndex: revocation handle index relative to attributes; // cri: the serialized version of the Credential Revocation Information (it contains the epoch this signature // is created in reference to). - Sign(cred []byte, sk Big, Nym Ecp, RNym Big, ipk IssuerPublicKey, attributes []bccsp.IdemixAttribute, - msg []byte, rhIndex int, cri []byte) ([]byte, error) + Sign(cred []byte, sk *math.Zr, Nym *math.G1, RNym *math.Zr, ipk IssuerPublicKey, attributes []bccsp.IdemixAttribute, + msg []byte, rhIndex, eidIndex int, cri []byte, sigType bccsp.SignatureType) ([]byte, *bccsp.IdemixSignerMetadata, error) // Verify verifies an idemix signature. // The attribute slice steers which attributes it expects to be disclosed @@ -148,15 +158,20 @@ type SignatureScheme interface { // rhIndex: revocation handle index relative to attributes; // revocationPublicKey: revocation public key; // epoch: revocation epoch. - Verify(ipk IssuerPublicKey, signature, msg []byte, attributes []bccsp.IdemixAttribute, rhIndex int, revocationPublicKey *ecdsa.PublicKey, epoch int) error + Verify(ipk IssuerPublicKey, signature, msg []byte, attributes []bccsp.IdemixAttribute, rhIndex, eidIndex int, + revocationPublicKey *ecdsa.PublicKey, epoch int, verType bccsp.VerificationType, meta *bccsp.IdemixSignerMetadata) error + + // AuditNymEid permits the auditing of the nym eid generated by a signer + AuditNymEid(ipk IssuerPublicKey, eidIndex int, signature []byte, + enrollmentID string, RNymEid *math.Zr) error } // NymSignatureScheme is a local interface to decouple from the idemix implementation // the nym sign-related operations type NymSignatureScheme interface { // Sign creates a new idemix pseudonym signature - Sign(sk Big, Nym Ecp, RNym Big, ipk IssuerPublicKey, digest []byte) ([]byte, error) + Sign(sk *math.Zr, Nym *math.G1, RNym *math.Zr, ipk IssuerPublicKey, digest []byte) ([]byte, error) // Verify verifies an idemix NymSignature - Verify(pk IssuerPublicKey, Nym Ecp, signature, digest []byte) error + Verify(pk IssuerPublicKey, Nym *math.G1, signature, digest []byte) error } diff --git a/bccsp/idemix/handlers/issuer.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/issuer.go similarity index 75% rename from bccsp/idemix/handlers/issuer.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/issuer.go index b98efafbfba..ce122e4609b 100644 --- a/bccsp/idemix/handlers/issuer.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/issuer.go @@ -6,7 +6,7 @@ SPDX-License-Identifier: Apache-2.0 package handlers import ( - "github.com/hyperledger/fabric/bccsp" + bccsp "github.com/IBM/idemix/bccsp/schemes" "github.com/pkg/errors" ) @@ -134,3 +134,38 @@ func (i *IssuerPublicKeyImporter) KeyImport(raw interface{}, opts bccsp.KeyImpor return &issuerPublicKey{pk}, nil } + +// IssuerKeyImporter imports issuer public keys +type IssuerKeyImporter struct { + // exportable is a flag to allow an issuer secret key to be marked as exportable. + // If a secret key is marked as exportable, its Bytes method will return the key's byte representation. + Exportable bool + // Issuer implements the underlying cryptographic algorithms + Issuer Issuer +} + +func (i *IssuerKeyImporter) KeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.Key, err error) { + der, ok := raw.([]byte) + if !ok { + return nil, errors.New("invalid raw, expected byte array") + } + + if len(der) == 0 { + return nil, errors.New("invalid raw, it must not be nil") + } + + o, ok := opts.(*bccsp.IdemixIssuerKeyImportOpts) + if !ok { + return nil, errors.New("invalid options, expected *bccsp.IdemixIssuerKeyImportOpts") + } + + sk, err := i.Issuer.NewKeyFromBytes(raw.([]byte), o.AttributeNames) + if err != nil { + return nil, err + } + + return &issuerSecretKey{ + sk: sk, + exportable: i.Exportable, + }, nil +} diff --git a/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/nym.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/nym.go new file mode 100644 index 00000000000..9d7170fd44d --- /dev/null +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/nym.go @@ -0,0 +1,193 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +package handlers + +import ( + "crypto/sha256" + + bccsp "github.com/IBM/idemix/bccsp/schemes" + idemix "github.com/IBM/idemix/bccsp/schemes/dlog/crypto" + math "github.com/IBM/mathlib" + "github.com/pkg/errors" +) + +// NymSecretKey contains the nym secret key +type NymSecretKey struct { + // SKI of this key + Ski []byte + // Sk is the idemix reference to the nym secret + Sk *math.Zr + // Pk is the idemix reference to the nym public part + Pk *math.G1 + // Exportable if true, sk can be exported via the Bytes function + Exportable bool + + Translator idemix.Translator +} + +func computeSKI(serialise func() []byte) []byte { + raw := serialise() + + hash := sha256.New() + hash.Write(raw) + return hash.Sum(nil) + +} + +func NewNymSecretKey(sk *math.Zr, pk *math.G1, translator idemix.Translator, exportable bool) (*NymSecretKey, error) { + ski := computeSKI(sk.Bytes) + return &NymSecretKey{Ski: ski, Sk: sk, Pk: pk, Exportable: exportable, Translator: translator}, nil +} + +func (k *NymSecretKey) Bytes() ([]byte, error) { + if k.Exportable { + return k.Sk.Bytes(), nil + } + + return nil, errors.New("not supported") +} + +func (k *NymSecretKey) SKI() []byte { + c := make([]byte, len(k.Ski)) + copy(c, k.Ski) + return c +} + +func (*NymSecretKey) Symmetric() bool { + return false +} + +func (*NymSecretKey) Private() bool { + return true +} + +func (k *NymSecretKey) PublicKey() (bccsp.Key, error) { + ski := computeSKI(k.Pk.Bytes) + return &nymPublicKey{ski: ski, pk: k.Pk, translator: k.Translator}, nil +} + +type nymPublicKey struct { + // SKI of this key + ski []byte + // pk is the idemix reference to the nym public part + pk *math.G1 + + translator idemix.Translator +} + +func NewNymPublicKey(pk *math.G1, translator idemix.Translator) *nymPublicKey { + return &nymPublicKey{pk: pk, translator: translator} +} + +func (k *nymPublicKey) Bytes() ([]byte, error) { + ecp := k.translator.G1ToProto(k.pk) + return append(ecp.X, ecp.Y...), nil +} + +func (k *nymPublicKey) SKI() []byte { + return computeSKI(k.pk.Bytes) +} + +func (*nymPublicKey) Symmetric() bool { + return false +} + +func (*nymPublicKey) Private() bool { + return false +} + +func (k *nymPublicKey) PublicKey() (bccsp.Key, error) { + return k, nil +} + +// NymKeyDerivation derives nyms +type NymKeyDerivation struct { + // Exportable is a flag to allow an issuer secret key to be marked as Exportable. + // If a secret key is marked as Exportable, its Bytes method will return the key's byte representation. + Exportable bool + // User implements the underlying cryptographic algorithms + User User + + Translator idemix.Translator +} + +func (kd *NymKeyDerivation) KeyDeriv(k bccsp.Key, opts bccsp.KeyDerivOpts) (dk bccsp.Key, err error) { + userSecretKey, ok := k.(*UserSecretKey) + if !ok { + return nil, errors.New("invalid key, expected *userSecretKey") + } + nymKeyDerivationOpts, ok := opts.(*bccsp.IdemixNymKeyDerivationOpts) + if !ok { + return nil, errors.New("invalid options, expected *IdemixNymKeyDerivationOpts") + } + if nymKeyDerivationOpts.IssuerPK == nil { + return nil, errors.New("invalid options, missing issuer public key") + } + issuerPK, ok := nymKeyDerivationOpts.IssuerPK.(*issuerPublicKey) + if !ok { + return nil, errors.New("invalid options, expected IssuerPK as *issuerPublicKey") + } + + Nym, RandNym, err := kd.User.MakeNym(userSecretKey.Sk, issuerPK.pk) + if err != nil { + return nil, err + } + + return NewNymSecretKey(RandNym, Nym, kd.Translator, kd.Exportable) +} + +// NymPublicKeyImporter imports nym public keys +type NymPublicKeyImporter struct { + // User implements the underlying cryptographic algorithms + User User + + Translator idemix.Translator +} + +func (i *NymPublicKeyImporter) KeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.Key, err error) { + bytes, ok := raw.([]byte) + if !ok { + return nil, errors.New("invalid raw, expected byte array") + } + + if len(bytes) == 0 { + return nil, errors.New("invalid raw, it must not be nil") + } + + pk, err := i.User.NewPublicNymFromBytes(bytes) + if err != nil { + return nil, err + } + + return &nymPublicKey{pk: pk, translator: i.Translator}, nil +} + +// NymKeyImporter imports nym public keys +type NymKeyImporter struct { + Exportable bool + // User implements the underlying cryptographic algorithms + User User + + Translator idemix.Translator +} + +func (i *NymKeyImporter) KeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.Key, err error) { + bytes, ok := raw.([]byte) + if !ok { + return nil, errors.New("invalid raw, expected byte array") + } + + if len(bytes) == 0 { + return nil, errors.New("invalid raw, it must not be nil") + } + + pk, sk, err := i.User.NewNymFromBytes(bytes) + if err != nil { + return nil, err + } + + return NewNymSecretKey(sk, pk, i.Translator, i.Exportable) +} diff --git a/bccsp/idemix/handlers/nymsigner.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/nymsigner.go similarity index 92% rename from bccsp/idemix/handlers/nymsigner.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/nymsigner.go index 6517957274f..121b85a5a65 100644 --- a/bccsp/idemix/handlers/nymsigner.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/nymsigner.go @@ -6,7 +6,7 @@ SPDX-License-Identifier: Apache-2.0 package handlers import ( - "github.com/hyperledger/fabric/bccsp" + bccsp "github.com/IBM/idemix/bccsp/schemes" "github.com/pkg/errors" ) @@ -15,7 +15,7 @@ type NymSigner struct { } func (s *NymSigner) Sign(k bccsp.Key, digest []byte, opts bccsp.SignerOpts) ([]byte, error) { - userSecretKey, ok := k.(*userSecretKey) + userSecretKey, ok := k.(*UserSecretKey) if !ok { return nil, errors.New("invalid key, expected *userSecretKey") } @@ -38,14 +38,14 @@ func (s *NymSigner) Sign(k bccsp.Key, digest []byte, opts bccsp.SignerOpts) ([]b if signerOpts.Nym == nil { return nil, errors.New("invalid options, missing nym key") } - nymSk, ok := signerOpts.Nym.(*nymSecretKey) + nymSk, ok := signerOpts.Nym.(*NymSecretKey) if !ok { return nil, errors.New("invalid nym key, expected *nymSecretKey") } sigma, err := s.NymSignatureScheme.Sign( - userSecretKey.sk, - nymSk.pk, nymSk.sk, + userSecretKey.Sk, + nymSk.Pk, nymSk.Sk, ipk.pk, digest) if err != nil { diff --git a/bccsp/idemix/handlers/revocation.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/revocation.go similarity index 85% rename from bccsp/idemix/handlers/revocation.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/revocation.go index 176221e3a20..5c43f7a6ae6 100644 --- a/bccsp/idemix/handlers/revocation.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/revocation.go @@ -14,7 +14,7 @@ import ( "fmt" "reflect" - "github.com/hyperledger/fabric/bccsp" + bccsp "github.com/IBM/idemix/bccsp/schemes" "github.com/pkg/errors" ) @@ -136,8 +136,9 @@ func (g *RevocationKeyGen) KeyGen(opts bccsp.KeyGenOpts) (bccsp.Key, error) { return &revocationSecretKey{exportable: g.Exportable, privKey: key}, nil } -// RevocationPublicKeyImporter imports revocation public keys -type RevocationPublicKeyImporter struct{} +// RevocationPublicKeyImporter imports revocation public key +type RevocationPublicKeyImporter struct { +} func (i *RevocationPublicKeyImporter) KeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.Key, err error) { der, ok := raw.([]byte) @@ -165,6 +166,36 @@ func (i *RevocationPublicKeyImporter) KeyImport(raw interface{}, opts bccsp.KeyI return &revocationPublicKey{ecdsaPublicKey}, nil } +// RevocationKeyImporter imports revocation key +type RevocationKeyImporter struct { + // exportable is a flag to allow an revocation secret key to be marked as exportable. + // If a secret key is marked as exportable, its Bytes method will return the key's byte representation. + Exportable bool + // Revocation implements the underlying cryptographic algorithms + Revocation Revocation +} + +func (i *RevocationKeyImporter) KeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.Key, err error) { + der, ok := raw.([]byte) + if !ok { + return nil, errors.New("invalid raw, expected byte array") + } + + if len(der) == 0 { + return nil, errors.New("invalid raw, it must not be nil") + } + + key, err := i.Revocation.NewKeyFromBytes(raw.([]byte)) + if err != nil { + return nil, err + } + + return &revocationSecretKey{ + privKey: key, + exportable: i.Exportable, + }, nil +} + type CriSigner struct { Revocation Revocation } diff --git a/bccsp/idemix/handlers/signer.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/signer.go similarity index 65% rename from bccsp/idemix/handlers/signer.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/signer.go index c94f83aeb19..eb167cf8eee 100644 --- a/bccsp/idemix/handlers/signer.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/signer.go @@ -6,7 +6,7 @@ SPDX-License-Identifier: Apache-2.0 package handlers import ( - "github.com/hyperledger/fabric/bccsp" + bccsp "github.com/IBM/idemix/bccsp/schemes" "github.com/pkg/errors" ) @@ -15,7 +15,7 @@ type Signer struct { } func (s *Signer) Sign(k bccsp.Key, digest []byte, opts bccsp.SignerOpts) ([]byte, error) { - userSecretKey, ok := k.(*userSecretKey) + userSecretKey, ok := k.(*UserSecretKey) if !ok { return nil, errors.New("invalid key, expected *userSecretKey") } @@ -38,25 +38,29 @@ func (s *Signer) Sign(k bccsp.Key, digest []byte, opts bccsp.SignerOpts) ([]byte if signerOpts.Nym == nil { return nil, errors.New("invalid options, missing nym key") } - nymSk, ok := signerOpts.Nym.(*nymSecretKey) + nymSk, ok := signerOpts.Nym.(*NymSecretKey) if !ok { return nil, errors.New("invalid nym key, expected *nymSecretKey") } - sigma, err := s.SignatureScheme.Sign( + sigma, meta, err := s.SignatureScheme.Sign( signerOpts.Credential, - userSecretKey.sk, - nymSk.pk, nymSk.sk, + userSecretKey.Sk, + nymSk.Pk, nymSk.Sk, ipk.pk, signerOpts.Attributes, digest, signerOpts.RhIndex, + signerOpts.EidIndex, signerOpts.CRI, + signerOpts.SigType, ) if err != nil { return nil, err } + signerOpts.Metadata = meta + return sigma, nil } @@ -64,6 +68,35 @@ type Verifier struct { SignatureScheme SignatureScheme } +func (v *Verifier) AuditNymEid(k bccsp.Key, signature, digest []byte, opts bccsp.SignerOpts) (bool, error) { + issuerPublicKey, ok := k.(*issuerPublicKey) + if !ok { + return false, errors.New("invalid key, expected *issuerPublicKey") + } + + signerOpts, ok := opts.(*bccsp.EidNymAuditOpts) + if !ok { + return false, errors.New("invalid options, expected *EidNymAuditOpts") + } + + if len(signature) == 0 { + return false, errors.New("invalid signature, it must not be empty") + } + + err := v.SignatureScheme.AuditNymEid( + issuerPublicKey.pk, + signerOpts.EidIndex, + signature, + signerOpts.EnrollmentID, + signerOpts.RNymEid, + ) + if err != nil { + return false, err + } + + return true, nil +} + func (v *Verifier) Verify(k bccsp.Key, signature, digest []byte, opts bccsp.SignerOpts) (bool, error) { issuerPublicKey, ok := k.(*issuerPublicKey) if !ok { @@ -90,8 +123,11 @@ func (v *Verifier) Verify(k bccsp.Key, signature, digest []byte, opts bccsp.Sign digest, signerOpts.Attributes, signerOpts.RhIndex, + signerOpts.EidIndex, rpk.pubKey, signerOpts.Epoch, + signerOpts.VerificationType, + signerOpts.Metadata, ) if err != nil { return false, err diff --git a/bccsp/idemix/handlers/user.go b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/user.go similarity index 67% rename from bccsp/idemix/handlers/user.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/user.go index 273bb222208..af4b6c32362 100644 --- a/bccsp/idemix/handlers/user.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/dlog/handlers/user.go @@ -8,49 +8,47 @@ package handlers import ( "crypto/sha256" - "github.com/hyperledger/fabric/bccsp" + bccsp "github.com/IBM/idemix/bccsp/schemes" + math "github.com/IBM/mathlib" "github.com/pkg/errors" ) -// userSecretKey contains the User secret key -type userSecretKey struct { - // sk is the idemix reference to the User key - sk Big +// UserSecretKey contains the User secret key +type UserSecretKey struct { + // Sk is the idemix reference to the User key + Sk *math.Zr // Exportable if true, sk can be exported via the Bytes function - exportable bool + Exportable bool } -func NewUserSecretKey(sk Big, exportable bool) *userSecretKey { - return &userSecretKey{sk: sk, exportable: exportable} +func NewUserSecretKey(sk *math.Zr, exportable bool) *UserSecretKey { + return &UserSecretKey{Sk: sk, Exportable: exportable} } -func (k *userSecretKey) Bytes() ([]byte, error) { - if k.exportable { - return k.sk.Bytes() +func (k *UserSecretKey) Bytes() ([]byte, error) { + if k.Exportable { + return k.Sk.Bytes(), nil } return nil, errors.New("not exportable") } -func (k *userSecretKey) SKI() []byte { - raw, err := k.sk.Bytes() - if err != nil { - return nil - } +func (k *UserSecretKey) SKI() []byte { + raw := k.Sk.Bytes() hash := sha256.New() hash.Write(raw) return hash.Sum(nil) } -func (*userSecretKey) Symmetric() bool { +func (*UserSecretKey) Symmetric() bool { return true } -func (*userSecretKey) Private() bool { +func (*UserSecretKey) Private() bool { return true } -func (k *userSecretKey) PublicKey() (bccsp.Key, error) { +func (k *UserSecretKey) PublicKey() (bccsp.Key, error) { return nil, errors.New("cannot call this method on a symmetric key") } @@ -68,7 +66,7 @@ func (g *UserKeyGen) KeyGen(opts bccsp.KeyGenOpts) (bccsp.Key, error) { return nil, err } - return &userSecretKey{exportable: g.Exportable, sk: sk}, nil + return &UserSecretKey{Exportable: g.Exportable, Sk: sk}, nil } // UserKeyImporter import user keys @@ -95,5 +93,5 @@ func (i *UserKeyImporter) KeyImport(raw interface{}, opts bccsp.KeyImportOpts) ( return nil, err } - return &userSecretKey{exportable: i.Exportable, sk: sk}, nil + return &UserSecretKey{Exportable: i.Exportable, Sk: sk}, nil } diff --git a/bccsp/idemixerrs.go b/vendor/github.com/IBM/idemix/bccsp/schemes/idemixerrs.go similarity index 98% rename from bccsp/idemixerrs.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/idemixerrs.go index 193b8033b6c..99c620e1896 100644 --- a/bccsp/idemixerrs.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/idemixerrs.go @@ -4,7 +4,7 @@ Copyright IBM Corp. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ -package bccsp +package idemix import ( "fmt" diff --git a/bccsp/idemixopts.go b/vendor/github.com/IBM/idemix/bccsp/schemes/idemixopts.go similarity index 75% rename from bccsp/idemixopts.go rename to vendor/github.com/IBM/idemix/bccsp/schemes/idemixopts.go index a138d0e8ba1..fe1e2deeb93 100644 --- a/bccsp/idemixopts.go +++ b/vendor/github.com/IBM/idemix/bccsp/schemes/idemixopts.go @@ -3,10 +3,12 @@ Copyright IBM Corp. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ -package bccsp +package idemix import ( "crypto" + + math "github.com/IBM/mathlib" ) // RevocationAlgorithm identifies the revocation algorithm @@ -60,6 +62,24 @@ func (o *IdemixIssuerPublicKeyImportOpts) Ephemeral() bool { return o.Temporary } +// IdemixIssuerKeyImportOpts contains the options for importing of an Idemix issuer public key. +type IdemixIssuerKeyImportOpts struct { + Temporary bool + // AttributeNames is a list of attributes to ensure the import public key has + AttributeNames []string +} + +// Algorithm returns the key generation algorithm identifier (to be used). +func (*IdemixIssuerKeyImportOpts) Algorithm() string { + return IDEMIX +} + +// Ephemeral returns true if the key to generate has to be ephemeral, +// false otherwise. +func (o *IdemixIssuerKeyImportOpts) Ephemeral() bool { + return o.Temporary +} + // IdemixUserSecretKeyGenOpts contains the options for the generation of an Idemix credential secret key. type IdemixUserSecretKeyGenOpts struct { Temporary bool @@ -135,6 +155,23 @@ func (o *IdemixNymPublicKeyImportOpts) Ephemeral() bool { return o.Temporary } +// IdemixNymKeyImportOpts contains the options to import a pseudonym +type IdemixNymKeyImportOpts struct { + // Temporary tells if the key is ephemeral + Temporary bool +} + +// Algorithm returns the key derivation algorithm identifier (to be used). +func (*IdemixNymKeyImportOpts) Algorithm() string { + return IDEMIX +} + +// Ephemeral returns true if the key to derive has to be ephemeral, +// false otherwise. +func (o *IdemixNymKeyImportOpts) Ephemeral() bool { + return o.Temporary +} + // IdemixCredentialRequestSignerOpts contains the option to create a Idemix credential request. type IdemixCredentialRequestSignerOpts struct { // Attributes contains a list of indices of the attributes to be included in the @@ -199,6 +236,18 @@ func (o *IdemixCredentialSignerOpts) IssuerPublicKey() Key { return o.IssuerPK } +type NymEIDAuditData struct { + // RNymEid is the randomness used to generate the EID Nym + RNymEid *math.Zr + + // EID is the enrollment id + EID *math.Zr +} + +type IdemixSignerMetadata struct { + NymEIDAuditData *NymEIDAuditData +} + // IdemixSignerOpts contains the options to generate an Idemix signature type IdemixSignerOpts struct { // Nym is the pseudonym to be used @@ -217,6 +266,8 @@ type IdemixSignerOpts struct { // RhIndex is the index of attribute containing the revocation handler. // Notice that this attributed cannot be discloused RhIndex int + // EidIndex contains the index of the EID attrbiute + EidIndex int // CRI contains the credential revocation information CRI []byte // Epoch is the revocation epoch the signature should be produced against @@ -225,12 +276,28 @@ type IdemixSignerOpts struct { RevocationPublicKey Key // H is the hash function to be used H crypto.Hash + // SigType is the type of signature that shall be generated + SigType SignatureType + // IdemixSignerMetadata contains metadata about the signature + Metadata *IdemixSignerMetadata + // VerificationType controls what type of verification the caller expects + VerificationType VerificationType } func (o *IdemixSignerOpts) HashFunc() crypto.Hash { return o.H } +type EidNymAuditOpts struct { + EidIndex int + EnrollmentID string + RNymEid *math.Zr +} + +func (o *EidNymAuditOpts) HashFunc() crypto.Hash { + return 0 +} + // IdemixNymSignerOpts contains the options to generate an idemix pseudonym signature. type IdemixNymSignerOpts struct { // Nym is the pseudonym to be used @@ -281,6 +348,22 @@ func (o *IdemixRevocationPublicKeyImportOpts) Ephemeral() bool { return o.Temporary } +// IdemixRevocationKeyImportOpts contains the options for importing of an Idemix revocation key pair. +type IdemixRevocationKeyImportOpts struct { + Temporary bool +} + +// Algorithm returns the key generation algorithm identifier (to be used). +func (*IdemixRevocationKeyImportOpts) Algorithm() string { + return IDEMIX +} + +// Ephemeral returns true if the key to generate has to be ephemeral, +// false otherwise. +func (o *IdemixRevocationKeyImportOpts) Ephemeral() bool { + return o.Temporary +} + // IdemixCRISignerOpts contains the options to generate an Idemix CRI. // The CRI is supposed to be generated by the Issuing authority and // can be verified publicly by using the revocation public key. @@ -295,3 +378,27 @@ type IdemixCRISignerOpts struct { func (o *IdemixCRISignerOpts) HashFunc() crypto.Hash { return o.H } + +// SignatureType describes the type of idemix signature +type SignatureType int + +const ( + // Standard is the base signature type + Standard SignatureType = iota + // EidNym adds a hiding and binding commitment to the enrollment id and proves its correctness + EidNym +) + +// VerificationType describes the type of verification that is required +type VerificationType int + +const ( + // Basic performs the verification without any of the extensions (e.g. it ignores the nym eid) + Basic VerificationType = iota + // BestEffort performs all verifications possible given the available information in the signature/opts + BestEffort + // ExpectStandard expects a SignatureType of type Standard + ExpectStandard + // ExpectEidNym expects a SignatureType of type EidNym + ExpectEidNym +) diff --git a/vendor/github.com/IBM/idemix/common/flogging/core.go b/vendor/github.com/IBM/idemix/common/flogging/core.go new file mode 100644 index 00000000000..2e0317351f7 --- /dev/null +++ b/vendor/github.com/IBM/idemix/common/flogging/core.go @@ -0,0 +1,125 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package flogging + +import ( + "go.uber.org/zap/zapcore" +) + +type Encoding int8 + +const ( + CONSOLE = iota + JSON + LOGFMT +) + +// EncodingSelector is used to determine whether log records are +// encoded as JSON or in human readable CONSOLE or LOGFMT formats. +type EncodingSelector interface { + Encoding() Encoding +} + +// Core is a custom implementation of a zapcore.Core. It's a terrible hack that +// only exists to work around the intersection of state associated with +// encoders, implementation hiding in zapcore, and implicit, ad-hoc logger +// initialization within fabric. +// +// In addition to encoding log entries and fields to a buffer, zap Encoder +// implementations also need to maintain field state. When zapcore.Core.With is +// used, the associated encoder is cloned and the fields are added to the +// encoder. This means that encoder instances cannot be shared across cores. +// +// In terms of implementation hiding, it's difficult for our FormatEncoder to +// cleanly wrap the JSON and console implementations from zap as all methods +// from the zapcore.ObjectEncoder would need to be implemented to delegate to +// the correct backend. +// +// This implementation works by associating multiple encoders with a core. When +// fields are added to the core, the fields are added to all of the encoder +// implementations. The core also references the logging configuration to +// determine the proper encoding to use, the writer to delegate to, and the +// enabled levels. +type Core struct { + zapcore.LevelEnabler + Levels *LoggerLevels + Encoders map[Encoding]zapcore.Encoder + Selector EncodingSelector + Output zapcore.WriteSyncer + Observer Observer +} + +//go:generate counterfeiter -o mock/observer.go -fake-name Observer . Observer + +type Observer interface { + Check(e zapcore.Entry, ce *zapcore.CheckedEntry) + WriteEntry(e zapcore.Entry, fields []zapcore.Field) +} + +func (c *Core) With(fields []zapcore.Field) zapcore.Core { + clones := map[Encoding]zapcore.Encoder{} + for name, enc := range c.Encoders { + clone := enc.Clone() + addFields(clone, fields) + clones[name] = clone + } + + return &Core{ + LevelEnabler: c.LevelEnabler, + Levels: c.Levels, + Encoders: clones, + Selector: c.Selector, + Output: c.Output, + Observer: c.Observer, + } +} + +func (c *Core) Check(e zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore.CheckedEntry { + if c.Observer != nil { + c.Observer.Check(e, ce) + } + + if c.Enabled(e.Level) && c.Levels.Level(e.LoggerName).Enabled(e.Level) { + return ce.AddCore(e, c) + } + return ce +} + +func (c *Core) Write(e zapcore.Entry, fields []zapcore.Field) error { + encoding := c.Selector.Encoding() + enc := c.Encoders[encoding] + + buf, err := enc.EncodeEntry(e, fields) + if err != nil { + return err + } + _, err = c.Output.Write(buf.Bytes()) + buf.Free() + if err != nil { + return err + } + + if e.Level >= zapcore.PanicLevel { + c.Sync() + } + + if c.Observer != nil { + c.Observer.WriteEntry(e, fields) + } + + return nil +} + +func (c *Core) Sync() error { + return c.Output.Sync() +} + +func addFields(enc zapcore.ObjectEncoder, fields []zapcore.Field) { + for i := range fields { + fields[i].AddTo(enc) + } +} diff --git a/vendor/github.com/IBM/idemix/common/flogging/fabenc/color.go b/vendor/github.com/IBM/idemix/common/flogging/fabenc/color.go new file mode 100644 index 00000000000..240d0f71ce1 --- /dev/null +++ b/vendor/github.com/IBM/idemix/common/flogging/fabenc/color.go @@ -0,0 +1,39 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package fabenc + +import ( + "fmt" +) + +type Color uint8 + +const ColorNone Color = 0 + +const ( + ColorBlack Color = iota + 30 + ColorRed + ColorGreen + ColorYellow + ColorBlue + ColorMagenta + ColorCyan + ColorWhite +) + +func (c Color) Normal() string { + return fmt.Sprintf("\x1b[%dm", c) +} + +func (c Color) Bold() string { + if c == ColorNone { + return c.Normal() + } + return fmt.Sprintf("\x1b[%d;1m", c) +} + +func ResetColor() string { return ColorNone.Normal() } diff --git a/vendor/github.com/IBM/idemix/common/flogging/fabenc/encoder.go b/vendor/github.com/IBM/idemix/common/flogging/fabenc/encoder.go new file mode 100644 index 00000000000..4d19a098eb9 --- /dev/null +++ b/vendor/github.com/IBM/idemix/common/flogging/fabenc/encoder.go @@ -0,0 +1,80 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package fabenc + +import ( + "io" + "time" + + zaplogfmt "github.com/sykesm/zap-logfmt" + "go.uber.org/zap/buffer" + "go.uber.org/zap/zapcore" +) + +// A FormatEncoder is a zapcore.Encoder that formats log records according to a +// go-logging based format specifier. +type FormatEncoder struct { + zapcore.Encoder + formatters []Formatter + pool buffer.Pool +} + +// A Formatter is used to format and write data from a zap log entry. +type Formatter interface { + Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field) +} + +func NewFormatEncoder(formatters ...Formatter) *FormatEncoder { + return &FormatEncoder{ + Encoder: zaplogfmt.NewEncoder(zapcore.EncoderConfig{ + MessageKey: "", // disable + LevelKey: "", // disable + TimeKey: "", // disable + NameKey: "", // disable + CallerKey: "", // disable + StacktraceKey: "", // disable + LineEnding: "\n", + EncodeDuration: zapcore.StringDurationEncoder, + EncodeTime: func(t time.Time, enc zapcore.PrimitiveArrayEncoder) { + enc.AppendString(t.Format("2006-01-02T15:04:05.999Z07:00")) + }, + }), + formatters: formatters, + pool: buffer.NewPool(), + } +} + +// Clone creates a new instance of this encoder with the same configuration. +func (f *FormatEncoder) Clone() zapcore.Encoder { + return &FormatEncoder{ + Encoder: f.Encoder.Clone(), + formatters: f.formatters, + pool: f.pool, + } +} + +// EncodeEntry formats a zap log record. The structured fields are formatted by a +// zapcore.ConsoleEncoder and are appended as JSON to the end of the formatted entry. +// All entries are terminated by a newline. +func (f *FormatEncoder) EncodeEntry(entry zapcore.Entry, fields []zapcore.Field) (*buffer.Buffer, error) { + line := f.pool.Get() + for _, f := range f.formatters { + f.Format(line, entry, fields) + } + + encodedFields, err := f.Encoder.EncodeEntry(entry, fields) + if err != nil { + return nil, err + } + if line.Len() > 0 && encodedFields.Len() != 1 { + line.AppendString(" ") + } + line.AppendString(encodedFields.String()) + encodedFields.Free() + + return line, nil +} diff --git a/vendor/github.com/IBM/idemix/common/flogging/fabenc/formatter.go b/vendor/github.com/IBM/idemix/common/flogging/fabenc/formatter.go new file mode 100644 index 00000000000..6d6c5a8baa7 --- /dev/null +++ b/vendor/github.com/IBM/idemix/common/flogging/fabenc/formatter.go @@ -0,0 +1,295 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package fabenc + +import ( + "fmt" + "io" + "regexp" + "runtime" + "strings" + "sync" + "sync/atomic" + + "go.uber.org/zap/zapcore" +) + +// formatRegexp is broken into three groups: +// 1. the format verb +// 2. an optional colon that is ungrouped with '?:' +// 3. an optional, non-greedy format directive +// +// The grouping simplifies the verb proccssing during spec parsing. +var formatRegexp = regexp.MustCompile(`%{(color|id|level|message|module|shortfunc|time)(?::(.*?))?}`) + +// ParseFormat parses a log format spec and returns a slice of formatters +// that should be iterated over to build a formatted log record. +// +// The op-loggng specifiers supported by this formatter are: +// - %{color} - level specific SGR color escape or SGR reset +// - %{id} - a unique log sequence number +// - %{level} - the log level of the entry +// - %{message} - the log message +// - %{module} - the zap logger name +// - %{shortfunc} - the name of the function creating the log record +// - %{time} - the time the log entry was created +// +// Specifiers may include an optional format verb: +// - color: reset|bold +// - id: a fmt style numeric formatter without the leading % +// - level: a fmt style string formatter without the leading % +// - message: a fmt style string formatter without the leading % +// - module: a fmt style string formatter without the leading % +// +func ParseFormat(spec string) ([]Formatter, error) { + cursor := 0 + formatters := []Formatter{} + + // iterate over the regex groups and convert to formatters + matches := formatRegexp.FindAllStringSubmatchIndex(spec, -1) + for _, m := range matches { + start, end := m[0], m[1] + verbStart, verbEnd := m[2], m[3] + formatStart, formatEnd := m[4], m[5] + + if start > cursor { + formatters = append(formatters, StringFormatter{Value: spec[cursor:start]}) + } + + var format string + if formatStart >= 0 { + format = spec[formatStart:formatEnd] + } + + formatter, err := NewFormatter(spec[verbStart:verbEnd], format) + if err != nil { + return nil, err + } + + formatters = append(formatters, formatter) + cursor = end + } + + // handle any trailing suffix + if cursor != len(spec) { + formatters = append(formatters, StringFormatter{Value: spec[cursor:]}) + } + + return formatters, nil +} + +// A MultiFormatter presents multiple formatters as a single Formatter. It can +// be used to change the set of formatters associated with an encoder at +// runtime. +type MultiFormatter struct { + mutex sync.RWMutex + formatters []Formatter +} + +// NewMultiFormatter creates a new MultiFormatter that delegates to the +// provided formatters. The formatters are used in the order they are +// presented. +func NewMultiFormatter(formatters ...Formatter) *MultiFormatter { + return &MultiFormatter{ + formatters: formatters, + } +} + +// Format iterates over its delegates to format a log record to the provided +// buffer. +func (m *MultiFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field) { + m.mutex.RLock() + for i := range m.formatters { + m.formatters[i].Format(w, entry, fields) + } + m.mutex.RUnlock() +} + +// SetFormatters replaces the delegate formatters. +func (m *MultiFormatter) SetFormatters(formatters []Formatter) { + m.mutex.Lock() + m.formatters = formatters + m.mutex.Unlock() +} + +// A StringFormatter formats a fixed string. +type StringFormatter struct{ Value string } + +// Format writes the formatter's fixed string to provided writer. +func (s StringFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field) { + fmt.Fprintf(w, "%s", s.Value) +} + +// NewFormatter creates the formatter for the provided verb. When a format is +// not provided, the default format for the verb is used. +func NewFormatter(verb, format string) (Formatter, error) { + switch verb { + case "color": + return newColorFormatter(format) + case "id": + return newSequenceFormatter(format), nil + case "level": + return newLevelFormatter(format), nil + case "message": + return newMessageFormatter(format), nil + case "module": + return newModuleFormatter(format), nil + case "shortfunc": + return newShortFuncFormatter(format), nil + case "time": + return newTimeFormatter(format), nil + default: + return nil, fmt.Errorf("unknown verb: %s", verb) + } +} + +// A ColorFormatter formats an SGR color code. +type ColorFormatter struct { + Bold bool // set the bold attribute + Reset bool // reset colors and attributes +} + +func newColorFormatter(f string) (ColorFormatter, error) { + switch f { + case "bold": + return ColorFormatter{Bold: true}, nil + case "reset": + return ColorFormatter{Reset: true}, nil + case "": + return ColorFormatter{}, nil + default: + return ColorFormatter{}, fmt.Errorf("invalid color option: %s", f) + } +} + +// LevelColor returns the Color associated with a specific zap logging level. +func (c ColorFormatter) LevelColor(l zapcore.Level) Color { + switch l { + case zapcore.DebugLevel: + return ColorCyan + case zapcore.InfoLevel: + return ColorBlue + case zapcore.WarnLevel: + return ColorYellow + case zapcore.ErrorLevel: + return ColorRed + case zapcore.DPanicLevel, zapcore.PanicLevel: + return ColorMagenta + case zapcore.FatalLevel: + return ColorMagenta + default: + return ColorNone + } +} + +// Format writes the SGR color code to the provided writer. +func (c ColorFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field) { + switch { + case c.Reset: + fmt.Fprint(w, ResetColor()) + case c.Bold: + fmt.Fprint(w, c.LevelColor(entry.Level).Bold()) + default: + fmt.Fprint(w, c.LevelColor(entry.Level).Normal()) + } +} + +// LevelFormatter formats a log level. +type LevelFormatter struct{ FormatVerb string } + +func newLevelFormatter(f string) LevelFormatter { + return LevelFormatter{FormatVerb: "%" + stringOrDefault(f, "s")} +} + +// Format writes the logging level to the provided writer. +func (l LevelFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field) { + fmt.Fprintf(w, l.FormatVerb, entry.Level.CapitalString()) +} + +// MessageFormatter formats a log message. +type MessageFormatter struct{ FormatVerb string } + +func newMessageFormatter(f string) MessageFormatter { + return MessageFormatter{FormatVerb: "%" + stringOrDefault(f, "s")} +} + +// Format writes the log entry message to the provided writer. +func (m MessageFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field) { + fmt.Fprintf(w, m.FormatVerb, strings.TrimRight(entry.Message, "\n")) +} + +// ModuleFormatter formats the zap logger name. +type ModuleFormatter struct{ FormatVerb string } + +func newModuleFormatter(f string) ModuleFormatter { + return ModuleFormatter{FormatVerb: "%" + stringOrDefault(f, "s")} +} + +// Format writes the zap logger name to the specified writer. +func (m ModuleFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field) { + fmt.Fprintf(w, m.FormatVerb, entry.LoggerName) +} + +// sequence maintains the global sequence number shared by all SequeneFormatter +// instances. +var sequence uint64 + +// SetSequence explicitly sets the global sequence number. +func SetSequence(s uint64) { atomic.StoreUint64(&sequence, s) } + +// SequenceFormatter formats a global sequence number. +type SequenceFormatter struct{ FormatVerb string } + +func newSequenceFormatter(f string) SequenceFormatter { + return SequenceFormatter{FormatVerb: "%" + stringOrDefault(f, "d")} +} + +// SequenceFormatter increments a global sequence number and writes it to the +// provided writer. +func (s SequenceFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field) { + fmt.Fprintf(w, s.FormatVerb, atomic.AddUint64(&sequence, 1)) +} + +// ShortFuncFormatter formats the name of the function creating the log record. +type ShortFuncFormatter struct{ FormatVerb string } + +func newShortFuncFormatter(f string) ShortFuncFormatter { + return ShortFuncFormatter{FormatVerb: "%" + stringOrDefault(f, "s")} +} + +// Format writes the calling function name to the provided writer. The name is obtained from +// the runtime and the package and line numbers are discarded. +func (s ShortFuncFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field) { + f := runtime.FuncForPC(entry.Caller.PC) + if f == nil { + fmt.Fprintf(w, s.FormatVerb, "(unknown)") + return + } + + fname := f.Name() + funcIdx := strings.LastIndex(fname, ".") + fmt.Fprintf(w, s.FormatVerb, fname[funcIdx+1:]) +} + +// TimeFormatter formats the time from the zap log entry. +type TimeFormatter struct{ Layout string } + +func newTimeFormatter(f string) TimeFormatter { + return TimeFormatter{Layout: stringOrDefault(f, "2006-01-02T15:04:05.999Z07:00")} +} + +// Format writes the log record time stamp to the provided writer. +func (t TimeFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field) { + fmt.Fprint(w, entry.Time.Format(t.Layout)) +} + +func stringOrDefault(str, dflt string) string { + if str != "" { + return str + } + return dflt +} diff --git a/vendor/github.com/IBM/idemix/common/flogging/global.go b/vendor/github.com/IBM/idemix/common/flogging/global.go new file mode 100644 index 00000000000..7db1588bf6f --- /dev/null +++ b/vendor/github.com/IBM/idemix/common/flogging/global.go @@ -0,0 +1,84 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package flogging + +import ( + "io" + + "go.uber.org/zap/zapcore" + "google.golang.org/grpc/grpclog" +) + +const ( + defaultFormat = "%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}" + defaultLevel = zapcore.InfoLevel +) + +var Global *Logging + +func init() { + logging, err := New(Config{}) + if err != nil { + panic(err) + } + + Global = logging + grpcLogger := Global.ZapLogger("grpc") + grpclog.SetLogger(NewGRPCLogger(grpcLogger)) +} + +// Init initializes logging with the provided config. +func Init(config Config) { + err := Global.Apply(config) + if err != nil { + panic(err) + } +} + +// Reset sets logging to the defaults defined in this package. +// +// Used in tests and in the package init +func Reset() { + Global.Apply(Config{}) +} + +// LoggerLevel gets the current logging level for the logger with the +// provided name. +func LoggerLevel(loggerName string) string { + return Global.Level(loggerName).String() +} + +// MustGetLogger creates a logger with the specified name. If an invalid name +// is provided, the operation will panic. +func MustGetLogger(loggerName string) *FabricLogger { + return Global.Logger(loggerName) +} + +// ActivateSpec is used to activate a logging specification. +func ActivateSpec(spec string) { + err := Global.ActivateSpec(spec) + if err != nil { + panic(err) + } +} + +// DefaultLevel returns the default log level. +func DefaultLevel() string { + return defaultLevel.String() +} + +// SetWriter calls SetWriter returning the previous value +// of the writer. +func SetWriter(w io.Writer) io.Writer { + return Global.SetWriter(w) +} + +// SetObserver calls SetObserver returning the previous value +// of the observer. +func SetObserver(observer Observer) Observer { + return Global.SetObserver(observer) +} diff --git a/vendor/github.com/IBM/idemix/common/flogging/levels.go b/vendor/github.com/IBM/idemix/common/flogging/levels.go new file mode 100644 index 00000000000..dae518def48 --- /dev/null +++ b/vendor/github.com/IBM/idemix/common/flogging/levels.go @@ -0,0 +1,68 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package flogging + +import ( + "fmt" + "math" + + "go.uber.org/zap/zapcore" +) + +const ( + // DisabledLevel represents a disabled log level. Logs at this level should + // never be emitted. + DisabledLevel = zapcore.Level(math.MinInt8) + + // PayloadLevel is used to log the extremely detailed message level debug + // information. + PayloadLevel = zapcore.Level(zapcore.DebugLevel - 1) +) + +// NameToLevel converts a level name to a zapcore.Level. If the level name is +// unknown, zapcore.InfoLevel is returned. +func NameToLevel(level string) zapcore.Level { + l, err := nameToLevel(level) + if err != nil { + return zapcore.InfoLevel + } + return l +} + +func nameToLevel(level string) (zapcore.Level, error) { + switch level { + case "PAYLOAD", "payload": + return PayloadLevel, nil + case "DEBUG", "debug": + return zapcore.DebugLevel, nil + case "INFO", "info": + return zapcore.InfoLevel, nil + case "WARNING", "WARN", "warning", "warn": + return zapcore.WarnLevel, nil + case "ERROR", "error": + return zapcore.ErrorLevel, nil + case "DPANIC", "dpanic": + return zapcore.DPanicLevel, nil + case "PANIC", "panic": + return zapcore.PanicLevel, nil + case "FATAL", "fatal": + return zapcore.FatalLevel, nil + + case "NOTICE", "notice": + return zapcore.InfoLevel, nil // future + case "CRITICAL", "critical": + return zapcore.ErrorLevel, nil // future + + default: + return DisabledLevel, fmt.Errorf("invalid log level: %s", level) + } +} + +func IsValidLevel(level string) bool { + _, err := nameToLevel(level) + return err == nil +} diff --git a/vendor/github.com/IBM/idemix/common/flogging/loggerlevels.go b/vendor/github.com/IBM/idemix/common/flogging/loggerlevels.go new file mode 100644 index 00000000000..8af426f81eb --- /dev/null +++ b/vendor/github.com/IBM/idemix/common/flogging/loggerlevels.go @@ -0,0 +1,174 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package flogging + +import ( + "fmt" + "regexp" + "sort" + "strings" + "sync" + + "github.com/pkg/errors" + "go.uber.org/zap/zapcore" +) + +// LoggerLevels tracks the logging level of named loggers. +type LoggerLevels struct { + mutex sync.RWMutex + levelCache map[string]zapcore.Level + specs map[string]zapcore.Level + defaultLevel zapcore.Level + minLevel zapcore.Level +} + +// DefaultLevel returns the default logging level for loggers that do not have +// an explicit level set. +func (l *LoggerLevels) DefaultLevel() zapcore.Level { + l.mutex.RLock() + lvl := l.defaultLevel + l.mutex.RUnlock() + return lvl +} + +// ActivateSpec is used to modify logging levels. +// +// The logging specification has the following form: +// [[,...]=][:[[,...]=]...] +func (l *LoggerLevels) ActivateSpec(spec string) error { + l.mutex.Lock() + defer l.mutex.Unlock() + + defaultLevel := zapcore.InfoLevel + specs := map[string]zapcore.Level{} + for _, field := range strings.Split(spec, ":") { + split := strings.Split(field, "=") + switch len(split) { + case 1: // level + if field != "" && !IsValidLevel(field) { + return errors.Errorf("invalid logging specification '%s': bad segment '%s'", spec, field) + } + defaultLevel = NameToLevel(field) + + case 2: // [,...]= + if split[0] == "" { + return errors.Errorf("invalid logging specification '%s': no logger specified in segment '%s'", spec, field) + } + if field != "" && !IsValidLevel(split[1]) { + return errors.Errorf("invalid logging specification '%s': bad segment '%s'", spec, field) + } + + level := NameToLevel(split[1]) + loggers := strings.Split(split[0], ",") + for _, logger := range loggers { + // check if the logger name in the spec is valid. The + // trailing period is trimmed as logger names in specs + // ending with a period signifies that this part of the + // spec refers to the exact logger name (i.e. is not a prefix) + if !isValidLoggerName(strings.TrimSuffix(logger, ".")) { + return errors.Errorf("invalid logging specification '%s': bad logger name '%s'", spec, logger) + } + specs[logger] = level + } + + default: + return errors.Errorf("invalid logging specification '%s': bad segment '%s'", spec, field) + } + } + + minLevel := defaultLevel + for _, lvl := range specs { + if lvl < minLevel { + minLevel = lvl + } + } + + l.minLevel = minLevel + l.defaultLevel = defaultLevel + l.specs = specs + l.levelCache = map[string]zapcore.Level{} + + return nil +} + +// logggerNameRegexp defines the valid logger names +var loggerNameRegexp = regexp.MustCompile(`^[[:alnum:]_#:-]+(\.[[:alnum:]_#:-]+)*$`) + +// isValidLoggerName checks whether a logger name contains only valid +// characters. Names that begin/end with periods or contain special +// characters (other than periods, underscores, pound signs, colons +// and dashes) are invalid. +func isValidLoggerName(loggerName string) bool { + return loggerNameRegexp.MatchString(loggerName) +} + +// Level returns the effective logging level for a logger. If a level has not +// been explicitly set for the logger, the default logging level will be +// returned. +func (l *LoggerLevels) Level(loggerName string) zapcore.Level { + if level, ok := l.cachedLevel(loggerName); ok { + return level + } + + l.mutex.Lock() + level := l.calculateLevel(loggerName) + l.levelCache[loggerName] = level + l.mutex.Unlock() + + return level +} + +// calculateLevel walks the logger name back to find the appropriate +// log level from the current spec. +func (l *LoggerLevels) calculateLevel(loggerName string) zapcore.Level { + candidate := loggerName + "." + for { + if lvl, ok := l.specs[candidate]; ok { + return lvl + } + + idx := strings.LastIndex(candidate, ".") + if idx <= 0 { + return l.defaultLevel + } + candidate = candidate[:idx] + } +} + +// cachedLevel attempts to retrieve the effective log level for a logger from the +// cache. If the logger is not found, ok will be false. +func (l *LoggerLevels) cachedLevel(loggerName string) (lvl zapcore.Level, ok bool) { + l.mutex.RLock() + level, ok := l.levelCache[loggerName] + l.mutex.RUnlock() + return level, ok +} + +// Spec returns a normalized version of the active logging spec. +func (l *LoggerLevels) Spec() string { + l.mutex.RLock() + defer l.mutex.RUnlock() + + var fields []string + for k, v := range l.specs { + fields = append(fields, fmt.Sprintf("%s=%s", k, v)) + } + + sort.Strings(fields) + fields = append(fields, l.defaultLevel.String()) + + return strings.Join(fields, ":") +} + +// Enabled function is an enabled check that evaluates the minimum active logging level. +// It serves as a fast check before the (relatively) expensive Check call in the core. +func (l *LoggerLevels) Enabled(lvl zapcore.Level) bool { + l.mutex.RLock() + enabled := l.minLevel.Enabled(lvl) + l.mutex.RUnlock() + return enabled +} diff --git a/vendor/github.com/IBM/idemix/common/flogging/logging.go b/vendor/github.com/IBM/idemix/common/flogging/logging.go new file mode 100644 index 00000000000..fa416d56951 --- /dev/null +++ b/vendor/github.com/IBM/idemix/common/flogging/logging.go @@ -0,0 +1,250 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package flogging + +import ( + "fmt" + "io" + "os" + "sync" + + "github.com/IBM/idemix/common/flogging/fabenc" + zaplogfmt "github.com/sykesm/zap-logfmt" + "go.uber.org/zap" + "go.uber.org/zap/zapcore" +) + +// Config is used to provide dependencies to a Logging instance. +type Config struct { + // Format is the log record format specifier for the Logging instance. If the + // spec is the string "json", log records will be formatted as JSON. Any + // other string will be provided to the FormatEncoder. Please see + // fabenc.ParseFormat for details on the supported verbs. + // + // If Format is not provided, a default format that provides basic information will + // be used. + Format string + + // LogSpec determines the log levels that are enabled for the logging system. The + // spec must be in a format that can be processed by ActivateSpec. + // + // If LogSpec is not provided, loggers will be enabled at the INFO level. + LogSpec string + + // Writer is the sink for encoded and formatted log records. + // + // If a Writer is not provided, os.Stderr will be used as the log sink. + Writer io.Writer +} + +// Logging maintains the state associated with the fabric logging system. It is +// intended to bridge between the legacy logging infrastructure built around +// go-logging and the structured, level logging provided by zap. +type Logging struct { + *LoggerLevels + + mutex sync.RWMutex + encoding Encoding + encoderConfig zapcore.EncoderConfig + multiFormatter *fabenc.MultiFormatter + writer zapcore.WriteSyncer + observer Observer +} + +// New creates a new logging system and initializes it with the provided +// configuration. +func New(c Config) (*Logging, error) { + encoderConfig := zap.NewProductionEncoderConfig() + encoderConfig.NameKey = "name" + + l := &Logging{ + LoggerLevels: &LoggerLevels{ + defaultLevel: defaultLevel, + }, + encoderConfig: encoderConfig, + multiFormatter: fabenc.NewMultiFormatter(), + } + + err := l.Apply(c) + if err != nil { + return nil, err + } + return l, nil +} + +// Apply applies the provided configuration to the logging system. +func (l *Logging) Apply(c Config) error { + err := l.SetFormat(c.Format) + if err != nil { + return err + } + + if c.LogSpec == "" { + c.LogSpec = os.Getenv("FABRIC_LOGGING_SPEC") + } + if c.LogSpec == "" { + c.LogSpec = defaultLevel.String() + } + + err = l.LoggerLevels.ActivateSpec(c.LogSpec) + if err != nil { + return err + } + + if c.Writer == nil { + c.Writer = os.Stderr + } + l.SetWriter(c.Writer) + + return nil +} + +// SetFormat updates how log records are formatted and encoded. Log entries +// created after this method has completed will use the new format. +// +// An error is returned if the log format specification cannot be parsed. +func (l *Logging) SetFormat(format string) error { + l.mutex.Lock() + defer l.mutex.Unlock() + if format == "" { + format = defaultFormat + } + + if format == "json" { + l.encoding = JSON + return nil + } + + if format == "logfmt" { + l.encoding = LOGFMT + return nil + } + + formatters, err := fabenc.ParseFormat(format) + if err != nil { + return err + } + l.multiFormatter.SetFormatters(formatters) + l.encoding = CONSOLE + + return nil +} + +// SetWriter controls which writer formatted log records are written to. +// Writers, with the exception of an *os.File, need to be safe for concurrent +// use by multiple go routines. +func (l *Logging) SetWriter(w io.Writer) io.Writer { + var sw zapcore.WriteSyncer + switch t := w.(type) { + case *os.File: + sw = zapcore.Lock(t) + case zapcore.WriteSyncer: + sw = t + default: + sw = zapcore.AddSync(w) + } + + l.mutex.Lock() + ow := l.writer + l.writer = sw + l.mutex.Unlock() + + return ow +} + +// SetObserver is used to provide a log observer that will be called as log +// levels are checked or written.. Only a single observer is supported. +func (l *Logging) SetObserver(observer Observer) Observer { + l.mutex.Lock() + so := l.observer + l.observer = observer + l.mutex.Unlock() + + return so +} + +// Write satisfies the io.Write contract. It delegates to the writer argument +// of SetWriter or the Writer field of Config. The Core uses this when encoding +// log records. +func (l *Logging) Write(b []byte) (int, error) { + l.mutex.RLock() + w := l.writer + l.mutex.RUnlock() + + return w.Write(b) +} + +// Sync satisfies the zapcore.WriteSyncer interface. It is used by the Core to +// flush log records before terminating the process. +func (l *Logging) Sync() error { + l.mutex.RLock() + w := l.writer + l.mutex.RUnlock() + + return w.Sync() +} + +// Encoding satisfies the Encoding interface. It determines whether the JSON or +// CONSOLE encoder should be used by the Core when log records are written. +func (l *Logging) Encoding() Encoding { + l.mutex.RLock() + e := l.encoding + l.mutex.RUnlock() + return e +} + +// ZapLogger instantiates a new zap.Logger with the specified name. The name is +// used to determine which log levels are enabled. +func (l *Logging) ZapLogger(name string) *zap.Logger { + if !isValidLoggerName(name) { + panic(fmt.Sprintf("invalid logger name: %s", name)) + } + + l.mutex.RLock() + core := &Core{ + LevelEnabler: l.LoggerLevels, + Levels: l.LoggerLevels, + Encoders: map[Encoding]zapcore.Encoder{ + JSON: zapcore.NewJSONEncoder(l.encoderConfig), + CONSOLE: fabenc.NewFormatEncoder(l.multiFormatter), + LOGFMT: zaplogfmt.NewEncoder(l.encoderConfig), + }, + Selector: l, + Output: l, + Observer: l, + } + l.mutex.RUnlock() + + return NewZapLogger(core).Named(name) +} + +func (l *Logging) Check(e zapcore.Entry, ce *zapcore.CheckedEntry) { + l.mutex.RLock() + observer := l.observer + l.mutex.RUnlock() + + if observer != nil { + observer.Check(e, ce) + } +} + +func (l *Logging) WriteEntry(e zapcore.Entry, fields []zapcore.Field) { + l.mutex.RLock() + observer := l.observer + l.mutex.RUnlock() + + if observer != nil { + observer.WriteEntry(e, fields) + } +} + +// Logger instantiates a new FabricLogger with the specified name. The name is +// used to determine which log levels are enabled. +func (l *Logging) Logger(name string) *FabricLogger { + zl := l.ZapLogger(name) + return NewFabricLogger(zl) +} diff --git a/vendor/github.com/IBM/idemix/common/flogging/zap.go b/vendor/github.com/IBM/idemix/common/flogging/zap.go new file mode 100644 index 00000000000..6319833bc4d --- /dev/null +++ b/vendor/github.com/IBM/idemix/common/flogging/zap.go @@ -0,0 +1,105 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package flogging + +import ( + "fmt" + "strings" + + "go.uber.org/zap" + "go.uber.org/zap/zapcore" + "go.uber.org/zap/zapgrpc" +) + +// NewZapLogger creates a zap logger around a new zap.Core. The core will use +// the provided encoder and sinks and a level enabler that is associated with +// the provided logger name. The logger that is returned will be named the same +// as the logger. +func NewZapLogger(core zapcore.Core, options ...zap.Option) *zap.Logger { + return zap.New( + core, + append([]zap.Option{ + zap.AddCaller(), + zap.AddStacktrace(zapcore.ErrorLevel), + }, options...)..., + ) +} + +// NewGRPCLogger creates a grpc.Logger that delegates to a zap.Logger. +func NewGRPCLogger(l *zap.Logger) *zapgrpc.Logger { + l = l.WithOptions( + zap.AddCaller(), + zap.AddCallerSkip(3), + ) + return zapgrpc.NewLogger(l, zapgrpc.WithDebug()) +} + +// NewFabricLogger creates a logger that delegates to the zap.SugaredLogger. +func NewFabricLogger(l *zap.Logger, options ...zap.Option) *FabricLogger { + return &FabricLogger{ + s: l.WithOptions(append(options, zap.AddCallerSkip(1))...).Sugar(), + } +} + +// A FabricLogger is an adapter around a zap.SugaredLogger that provides +// structured logging capabilities while preserving much of the legacy logging +// behavior. +// +// The most significant difference between the FabricLogger and the +// zap.SugaredLogger is that methods without a formatting suffix (f or w) build +// the log entry message with fmt.Sprintln instead of fmt.Sprint. Without this +// change, arguments are not separated by spaces. +type FabricLogger struct{ s *zap.SugaredLogger } + +func (f *FabricLogger) DPanic(args ...interface{}) { f.s.DPanicf(formatArgs(args)) } +func (f *FabricLogger) DPanicf(template string, args ...interface{}) { f.s.DPanicf(template, args...) } +func (f *FabricLogger) DPanicw(msg string, kvPairs ...interface{}) { f.s.DPanicw(msg, kvPairs...) } +func (f *FabricLogger) Debug(args ...interface{}) { f.s.Debugf(formatArgs(args)) } +func (f *FabricLogger) Debugf(template string, args ...interface{}) { f.s.Debugf(template, args...) } +func (f *FabricLogger) Debugw(msg string, kvPairs ...interface{}) { f.s.Debugw(msg, kvPairs...) } +func (f *FabricLogger) Error(args ...interface{}) { f.s.Errorf(formatArgs(args)) } +func (f *FabricLogger) Errorf(template string, args ...interface{}) { f.s.Errorf(template, args...) } +func (f *FabricLogger) Errorw(msg string, kvPairs ...interface{}) { f.s.Errorw(msg, kvPairs...) } +func (f *FabricLogger) Fatal(args ...interface{}) { f.s.Fatalf(formatArgs(args)) } +func (f *FabricLogger) Fatalf(template string, args ...interface{}) { f.s.Fatalf(template, args...) } +func (f *FabricLogger) Fatalw(msg string, kvPairs ...interface{}) { f.s.Fatalw(msg, kvPairs...) } +func (f *FabricLogger) Info(args ...interface{}) { f.s.Infof(formatArgs(args)) } +func (f *FabricLogger) Infof(template string, args ...interface{}) { f.s.Infof(template, args...) } +func (f *FabricLogger) Infow(msg string, kvPairs ...interface{}) { f.s.Infow(msg, kvPairs...) } +func (f *FabricLogger) Panic(args ...interface{}) { f.s.Panicf(formatArgs(args)) } +func (f *FabricLogger) Panicf(template string, args ...interface{}) { f.s.Panicf(template, args...) } +func (f *FabricLogger) Panicw(msg string, kvPairs ...interface{}) { f.s.Panicw(msg, kvPairs...) } +func (f *FabricLogger) Warn(args ...interface{}) { f.s.Warnf(formatArgs(args)) } +func (f *FabricLogger) Warnf(template string, args ...interface{}) { f.s.Warnf(template, args...) } +func (f *FabricLogger) Warnw(msg string, kvPairs ...interface{}) { f.s.Warnw(msg, kvPairs...) } +func (f *FabricLogger) Warning(args ...interface{}) { f.s.Warnf(formatArgs(args)) } +func (f *FabricLogger) Warningf(template string, args ...interface{}) { f.s.Warnf(template, args...) } + +// for backwards compatibility +func (f *FabricLogger) Critical(args ...interface{}) { f.s.Errorf(formatArgs(args)) } +func (f *FabricLogger) Criticalf(template string, args ...interface{}) { f.s.Errorf(template, args...) } +func (f *FabricLogger) Notice(args ...interface{}) { f.s.Infof(formatArgs(args)) } +func (f *FabricLogger) Noticef(template string, args ...interface{}) { f.s.Infof(template, args...) } + +func (f *FabricLogger) Named(name string) *FabricLogger { return &FabricLogger{s: f.s.Named(name)} } +func (f *FabricLogger) Sync() error { return f.s.Sync() } +func (f *FabricLogger) Zap() *zap.Logger { return f.s.Desugar() } + +func (f *FabricLogger) IsEnabledFor(level zapcore.Level) bool { + return f.s.Desugar().Core().Enabled(level) +} + +func (f *FabricLogger) With(args ...interface{}) *FabricLogger { + return &FabricLogger{s: f.s.With(args...)} +} + +func (f *FabricLogger) WithOptions(opts ...zap.Option) *FabricLogger { + l := f.s.Desugar().WithOptions(opts...) + return &FabricLogger{s: l.Sugar()} +} + +func formatArgs(args []interface{}) string { return strings.TrimSuffix(fmt.Sprintln(args...), "\n") } diff --git a/vendor/github.com/IBM/idemix/go.mod b/vendor/github.com/IBM/idemix/go.mod new file mode 100644 index 00000000000..20a127f3db1 --- /dev/null +++ b/vendor/github.com/IBM/idemix/go.mod @@ -0,0 +1,21 @@ +module github.com/IBM/idemix + +go 1.16 + +require ( + github.com/IBM/mathlib v0.0.0-20210928081244-f5486459a290 + github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect + github.com/alecthomas/units v0.0.0-20210912230133-d1bdfacee922 // indirect + github.com/golang/protobuf v1.3.3 + github.com/hyperledger/fabric-protos-go v0.0.0-20210911123859-041d13f0980c + github.com/onsi/ginkgo v1.14.0 + github.com/onsi/gomega v1.10.1 + github.com/pkg/errors v0.9.1 + github.com/stretchr/testify v1.7.1-0.20210116013205-6990a05d54c2 // includes ErrorContains + github.com/sykesm/zap-logfmt v0.0.2 + go.uber.org/zap v1.16.0 + google.golang.org/grpc v1.31.0 + gopkg.in/alecthomas/kingpin.v2 v2.2.6 +) + +replace github.com/onsi/gomega => github.com/onsi/gomega v1.9.0 diff --git a/vendor/github.com/IBM/idemix/go.sum b/vendor/github.com/IBM/idemix/go.sum new file mode 100644 index 00000000000..76f71af7470 --- /dev/null +++ b/vendor/github.com/IBM/idemix/go.sum @@ -0,0 +1,155 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/IBM/mathlib v0.0.0-20210928081244-f5486459a290 h1:usgCPts8YnOT6ba6CQLPzQ5Yb1crnQ8iU132Zm679IM= +github.com/IBM/mathlib v0.0.0-20210928081244-f5486459a290/go.mod h1:grSmaMdY3LbW9QwqMrzuTUCHjES4rzT4Dm7q6yIL9vs= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20210912230133-d1bdfacee922 h1:8ypNbf5sd3Sm3cKJ9waOGoQv6dKAFiFty9L6NP1AqJ4= +github.com/alecthomas/units v0.0.0-20210912230133-d1bdfacee922/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/consensys/bavard v0.1.8-0.20210329205436-c3e862ba4e5f/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ= +github.com/consensys/gnark-crypto v0.4.0 h1:KHf7Ta876Ys6L8+i0DLRRKOAa3PfJ8oobAX1CEeIa4A= +github.com/consensys/gnark-crypto v0.4.0/go.mod h1:wK/gpXP9B06qTzTVML71GhKD1ygP9xOzukbI68NJqsQ= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/hyperledger/fabric-amcl v0.0.0-20210603140002-2670f91851c8 h1:BCR8ZlOZ+deUbWxyY6fpoY8LbB7PR5wGGwCTvWQOU2g= +github.com/hyperledger/fabric-amcl v0.0.0-20210603140002-2670f91851c8/go.mod h1:X+DIyUsaTmalOpmpQfIvFZjKHQedrURQ5t4YqquX7lE= +github.com/hyperledger/fabric-protos-go v0.0.0-20210911123859-041d13f0980c h1:QPhSriw6EzMOj/d7gcGiKEvozVvQ5HLk9UWie4KAvSs= +github.com/hyperledger/fabric-protos-go v0.0.0-20210911123859-041d13f0980c/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= +github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= +github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/gomega v1.9.0 h1:R1uwffexN6Pr340GtYRIdZmAiN4J+iw6WG4wog1DUXg= +github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.7.1-0.20210116013205-6990a05d54c2 h1:oevpAKCW58ZYJe1hqfgLqg+1zXmYrQ9xf7HLUdfS+qM= +github.com/stretchr/testify v1.7.1-0.20210116013205-6990a05d54c2/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/sykesm/zap-logfmt v0.0.2 h1:czSzn+PIXCOAP/4NAIHTTziIKB8201PzoDkKTn+VR/8= +github.com/sykesm/zap-logfmt v0.0.2/go.mod h1:TerDJT124HaO8UTpZ2wJCipJRAKQ9XONM1mzUabIh6M= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk= +go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A= +go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.16.0 h1:uFRZXykJGK9lLY4HtgSw44DnIcAM+kRBP7x5m+NpAOM= +go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210326220804-49726bf1d181 h1:64ChN/hjER/taL4YJuA+gpLfIMT+/NFherRZixbxOhg= +golang.org/x/sys v0.0.0-20210326220804-49726bf1d181/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.31.0 h1:T7P4R73V3SSDPhH7WW7ATbfViLtmamH0DKrP3f9AuDI= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/msp/idemix_roles.go b/vendor/github.com/IBM/idemix/idemix_roles.go similarity index 99% rename from msp/idemix_roles.go rename to vendor/github.com/IBM/idemix/idemix_roles.go index 8c379065b5e..53e823b45d9 100644 --- a/msp/idemix_roles.go +++ b/vendor/github.com/IBM/idemix/idemix_roles.go @@ -3,7 +3,7 @@ Copyright IBM Corp. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ -package msp +package idemix import ( m "github.com/hyperledger/fabric-protos-go/msp" diff --git a/msp/idemixmsp.go b/vendor/github.com/IBM/idemix/idemixmsp.go similarity index 78% rename from msp/idemixmsp.go rename to vendor/github.com/IBM/idemix/idemixmsp.go index cb7bebd53f1..213bc6ad31c 100644 --- a/msp/idemixmsp.go +++ b/vendor/github.com/IBM/idemix/idemixmsp.go @@ -4,19 +4,25 @@ Copyright IBM Corp. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ -package msp +package idemix import ( "bytes" "encoding/hex" "fmt" + "io/ioutil" + "path/filepath" "time" + idemix "github.com/IBM/idemix/bccsp" + "github.com/IBM/idemix/bccsp/keystore" + bccsp "github.com/IBM/idemix/bccsp/schemes" + "github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl" + "github.com/IBM/idemix/common/flogging" + math "github.com/IBM/mathlib" "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-protos-go/msp" m "github.com/hyperledger/fabric-protos-go/msp" - "github.com/hyperledger/fabric/bccsp" - idemixbccsp "github.com/hyperledger/fabric/bccsp/idemix" - "github.com/hyperledger/fabric/bccsp/sw" "github.com/pkg/errors" "go.uber.org/zap/zapcore" ) @@ -49,34 +55,48 @@ const ( AttributeNameRevocationHandle = "RevocationHandle" ) +type MSPVersion int + +const ( + MSPv1_0 = iota + MSPv1_1 + MSPv1_3 + MSPv1_4_3 +) + // index of the revocation handle attribute in the credential const rhIndex = 3 +const eidIndex = 2 -type idemixmsp struct { +type Idemixmsp struct { csp bccsp.BCCSP version MSPVersion ipk bccsp.Key - signer *idemixSigningIdentity + signer *IdemixSigningIdentity name string revocationPK bccsp.Key epoch int } -// newIdemixMsp creates a new instance of idemixmsp -func newIdemixMsp(version MSPVersion) (MSP, error) { +var mspLogger = flogging.MustGetLogger("idemix") +var mspIdentityLogger = flogging.MustGetLogger("idemix.identity") + +// NewIdemixMsp creates a new instance of idemixmsp +func NewIdemixMsp(version MSPVersion) (MSP, error) { mspLogger.Debugf("Creating Idemix-based MSP instance") - csp, err := idemixbccsp.New(sw.NewDummyKeyStore()) + curve := math.Curves[math.FP256BN_AMCL] + csp, err := idemix.New(&keystore.Dummy{}, curve, &amcl.Fp256bn{C: curve}, true) if err != nil { panic(fmt.Sprintf("unexpected condition, error received [%s]", err)) } - msp := idemixmsp{csp: csp} + msp := Idemixmsp{csp: csp} msp.version = version return &msp, nil } -func (msp *idemixmsp) Setup(conf1 *m.MSPConfig) error { +func (msp *Idemixmsp) Setup(conf1 *m.MSPConfig) error { mspLogger.Debugf("Setting up Idemix-based MSP instance") if conf1 == nil { @@ -213,8 +233,9 @@ func (msp *idemixmsp) Setup(conf1 *m.MSPConfig) error { {Type: bccsp.IdemixHiddenAttribute}, {Type: bccsp.IdemixHiddenAttribute}, }, - RhIndex: rhIndex, - CRI: conf.Signer.CredentialRevocationInformation, + RhIndex: rhIndex, + EidIndex: eidIndex, + CRI: conf.Signer.CredentialRevocationInformation, }, ) if err != nil { @@ -222,31 +243,30 @@ func (msp *idemixmsp) Setup(conf1 *m.MSPConfig) error { } // Set up default signer - msp.signer = &idemixSigningIdentity{ - idemixidentity: newIdemixIdentity(msp, NymPublicKey, role, ou, proof), + msp.signer = &IdemixSigningIdentity{ + Idemixidentity: newIdemixIdentity(msp, NymPublicKey, role, ou, proof), Cred: conf.Signer.Cred, UserKey: UserKey, NymKey: NymKey, - enrollmentId: enrollmentId, - } + enrollmentId: enrollmentId} return nil } // GetVersion returns the version of this MSP -func (msp *idemixmsp) GetVersion() MSPVersion { +func (msp *Idemixmsp) GetVersion() MSPVersion { return msp.version } -func (msp *idemixmsp) GetType() ProviderType { +func (msp *Idemixmsp) GetType() ProviderType { return IDEMIX } -func (msp *idemixmsp) GetIdentifier() (string, error) { +func (msp *Idemixmsp) GetIdentifier() (string, error) { return msp.name, nil } -func (msp *idemixmsp) GetDefaultSigningIdentity() (SigningIdentity, error) { +func (msp *Idemixmsp) GetDefaultSigningIdentity() (SigningIdentity, error) { mspLogger.Debugf("Obtaining default idemix signing identity") if msp.signer == nil { @@ -255,7 +275,7 @@ func (msp *idemixmsp) GetDefaultSigningIdentity() (SigningIdentity, error) { return msp.signer, nil } -func (msp *idemixmsp) DeserializeIdentity(serializedID []byte) (Identity, error) { +func (msp *Idemixmsp) DeserializeIdentity(serializedID []byte) (Identity, error) { sID := &m.SerializedIdentity{} err := proto.Unmarshal(serializedID, sID) if err != nil { @@ -266,10 +286,10 @@ func (msp *idemixmsp) DeserializeIdentity(serializedID []byte) (Identity, error) return nil, errors.Errorf("expected MSP ID %s, received %s", msp.name, sID.Mspid) } - return msp.deserializeIdentityInternal(sID.GetIdBytes()) + return msp.DeserializeIdentityInternal(sID.GetIdBytes()) } -func (msp *idemixmsp) deserializeIdentityInternal(serializedID []byte) (Identity, error) { +func (msp *Idemixmsp) DeserializeIdentityInternal(serializedID []byte) (Identity, error) { mspLogger.Debug("idemixmsp: deserializing identity") serialized := new(m.SerializedIdemixIdentity) err := proto.Unmarshal(serializedID, serialized) @@ -309,13 +329,13 @@ func (msp *idemixmsp) deserializeIdentityInternal(serializedID []byte) (Identity return newIdemixIdentity(msp, NymPublicKey, role, ou, serialized.Proof), nil } -func (msp *idemixmsp) Validate(id Identity) error { - var identity *idemixidentity +func (msp *Idemixmsp) Validate(id Identity) error { + var identity *Idemixidentity switch t := id.(type) { - case *idemixidentity: - identity = id.(*idemixidentity) - case *idemixSigningIdentity: - identity = id.(*idemixSigningIdentity).idemixidentity + case *Idemixidentity: + identity = id.(*Idemixidentity) + case *IdemixSigningIdentity: + identity = id.(*IdemixSigningIdentity).Idemixidentity default: return errors.Errorf("identity type %T is not recognized", t) } @@ -327,7 +347,7 @@ func (msp *idemixmsp) Validate(id Identity) error { return identity.verifyProof() } -func (id *idemixidentity) verifyProof() error { +func (id *Idemixidentity) verifyProof() error { // Verify signature valid, err := id.msp.csp.Verify( id.msp.ipk, @@ -341,8 +361,9 @@ func (id *idemixidentity) verifyProof() error { {Type: bccsp.IdemixHiddenAttribute}, {Type: bccsp.IdemixHiddenAttribute}, }, - RhIndex: rhIndex, - Epoch: id.msp.epoch, + RhIndex: rhIndex, + EidIndex: eidIndex, + Epoch: id.msp.epoch, }, ) if err == nil && !valid { @@ -352,7 +373,7 @@ func (id *idemixidentity) verifyProof() error { return err } -func (msp *idemixmsp) SatisfiesPrincipal(id Identity, principal *m.MSPPrincipal) error { +func (msp *Idemixmsp) SatisfiesPrincipal(id Identity, principal *m.MSPPrincipal) error { err := msp.Validate(id) if err != nil { return errors.Wrap(err, "identity is not valid with respect to this MSP") @@ -363,7 +384,7 @@ func (msp *idemixmsp) SatisfiesPrincipal(id Identity, principal *m.MSPPrincipal) // satisfiesPrincipalValidated performs all the tasks of satisfiesPrincipal except the identity validation, // such that combined principals will not cause multiple expensive identity validations. -func (msp *idemixmsp) satisfiesPrincipalValidated(id Identity, principal *m.MSPPrincipal) error { +func (msp *Idemixmsp) satisfiesPrincipalValidated(id Identity, principal *m.MSPPrincipal) error { switch principal.PrincipalClassification { // in this case, we have to check whether the // identity has a role in the msp - member or admin @@ -390,7 +411,7 @@ func (msp *idemixmsp) satisfiesPrincipalValidated(id Identity, principal *m.MSPP return nil case m.MSPRole_ADMIN: mspLogger.Debugf("Checking if identity satisfies ADMIN role for %s", msp.name) - if id.(*idemixidentity).Role.Role != m.MSPRole_ADMIN { + if id.(*Idemixidentity).Role.Role != m.MSPRole_ADMIN { return errors.Errorf("user is not an admin") } return nil @@ -437,7 +458,7 @@ func (msp *idemixmsp) satisfiesPrincipalValidated(id Identity, principal *m.MSPP return errors.Errorf("the identity is a member of a different MSP (expected %s, got %s)", ou.MspIdentifier, id.GetMSPIdentifier()) } - if ou.OrganizationalUnitIdentifier != id.(*idemixidentity).OU.OrganizationalUnitIdentifier { + if ou.OrganizationalUnitIdentifier != id.(*Idemixidentity).OU.OrganizationalUnitIdentifier { return errors.Errorf("user is not part of the desired organizational unit") } @@ -493,7 +514,7 @@ func (msp *idemixmsp) satisfiesPrincipalValidated(id Identity, principal *m.MSPP // IsWellFormed checks if the given identity can be deserialized into its provider-specific . // In this MSP implementation, an identity is considered well formed if it contains a // marshaled SerializedIdemixIdentity protobuf message. -func (id *idemixmsp) IsWellFormed(identity *m.SerializedIdentity) error { +func (id *Idemixmsp) IsWellFormed(identity *m.SerializedIdentity) error { sId := new(m.SerializedIdemixIdentity) err := proto.Unmarshal(identity.IdBytes, sId) if err != nil { @@ -502,19 +523,19 @@ func (id *idemixmsp) IsWellFormed(identity *m.SerializedIdentity) error { return nil } -func (msp *idemixmsp) GetTLSRootCerts() [][]byte { +func (msp *Idemixmsp) GetTLSRootCerts() [][]byte { // TODO return nil } -func (msp *idemixmsp) GetTLSIntermediateCerts() [][]byte { +func (msp *Idemixmsp) GetTLSIntermediateCerts() [][]byte { // TODO return nil } -type idemixidentity struct { +type Idemixidentity struct { NymPublicKey bccsp.Key - msp *idemixmsp + msp *Idemixmsp id *IdentityIdentifier Role *m.MSPRole OU *m.OrganizationUnit @@ -524,12 +545,12 @@ type idemixidentity struct { associationProof []byte } -func (id *idemixidentity) Anonymous() bool { +func (id *Idemixidentity) Anonymous() bool { return true } -func newIdemixIdentity(msp *idemixmsp, NymPublicKey bccsp.Key, role *m.MSPRole, ou *m.OrganizationUnit, proof []byte) *idemixidentity { - id := &idemixidentity{} +func newIdemixIdentity(msp *Idemixmsp, NymPublicKey bccsp.Key, role *m.MSPRole, ou *m.OrganizationUnit, proof []byte) *Idemixidentity { + id := &Idemixidentity{} id.NymPublicKey = NymPublicKey id.msp = msp id.Role = role @@ -548,22 +569,22 @@ func newIdemixIdentity(msp *idemixmsp, NymPublicKey bccsp.Key, role *m.MSPRole, return id } -func (id *idemixidentity) ExpiresAt() time.Time { +func (id *Idemixidentity) ExpiresAt() time.Time { // Idemix MSP currently does not use expiration dates or revocation, // so we return the zero time to indicate this. return time.Time{} } -func (id *idemixidentity) GetIdentifier() *IdentityIdentifier { +func (id *Idemixidentity) GetIdentifier() *IdentityIdentifier { return id.id } -func (id *idemixidentity) GetMSPIdentifier() string { +func (id *Idemixidentity) GetMSPIdentifier() string { mspid, _ := id.msp.GetIdentifier() return mspid } -func (id *idemixidentity) GetOrganizationalUnits() []*OUIdentifier { +func (id *Idemixidentity) GetOrganizationalUnits() []*OUIdentifier { // we use the (serialized) public key of this MSP as the CertifiersIdentifier certifiersIdentifier, err := id.msp.ipk.Bytes() if err != nil { @@ -574,11 +595,11 @@ func (id *idemixidentity) GetOrganizationalUnits() []*OUIdentifier { return []*OUIdentifier{{certifiersIdentifier, id.OU.OrganizationalUnitIdentifier}} } -func (id *idemixidentity) Validate() error { +func (id *Idemixidentity) Validate() error { return id.msp.Validate(id) } -func (id *idemixidentity) Verify(msg []byte, sig []byte) error { +func (id *Idemixidentity) Verify(msg []byte, sig []byte) error { if mspIdentityLogger.IsEnabledFor(zapcore.DebugLevel) { mspIdentityLogger.Debugf("Verify Idemix sig: msg = %s", hex.Dump(msg)) mspIdentityLogger.Debugf("Verify Idemix sig: sig = %s", hex.Dump(sig)) @@ -595,11 +616,11 @@ func (id *idemixidentity) Verify(msg []byte, sig []byte) error { return err } -func (id *idemixidentity) SatisfiesPrincipal(principal *m.MSPPrincipal) error { +func (id *Idemixidentity) SatisfiesPrincipal(principal *m.MSPPrincipal) error { return id.msp.SatisfiesPrincipal(id, principal) } -func (id *idemixidentity) Serialize() ([]byte, error) { +func (id *Idemixidentity) Serialize() ([]byte, error) { serialized := &m.SerializedIdemixIdentity{} raw, err := id.NymPublicKey.Bytes() @@ -638,15 +659,15 @@ func (id *idemixidentity) Serialize() ([]byte, error) { return idBytes, nil } -type idemixSigningIdentity struct { - *idemixidentity +type IdemixSigningIdentity struct { + *Idemixidentity Cred []byte UserKey bccsp.Key NymKey bccsp.Key enrollmentId string } -func (id *idemixSigningIdentity) Sign(msg []byte) ([]byte, error) { +func (id *IdemixSigningIdentity) Sign(msg []byte) ([]byte, error) { mspLogger.Debugf("Idemix identity %s is signing", id.GetIdentifier()) sig, err := id.msp.csp.Sign( @@ -663,6 +684,59 @@ func (id *idemixSigningIdentity) Sign(msg []byte) ([]byte, error) { return sig, nil } -func (id *idemixSigningIdentity) GetPublicVersion() Identity { - return id.idemixidentity +func (id *IdemixSigningIdentity) GetPublicVersion() Identity { + return id.Idemixidentity +} + +func readFile(file string) ([]byte, error) { + fileCont, err := ioutil.ReadFile(file) + if err != nil { + return nil, errors.Wrapf(err, "could not read file %s", file) + } + + return fileCont, nil +} + +const ( + IdemixConfigDirMsp = "msp" + IdemixConfigDirUser = "user" + IdemixConfigFileIssuerPublicKey = "IssuerPublicKey" + IdemixConfigFileRevocationPublicKey = "RevocationPublicKey" + IdemixConfigFileSigner = "SignerConfig" +) + +// GetIdemixMspConfig returns the configuration for the Idemix MSP +func GetIdemixMspConfig(dir string, ID string) (*msp.MSPConfig, error) { + ipkBytes, err := readFile(filepath.Join(dir, IdemixConfigDirMsp, IdemixConfigFileIssuerPublicKey)) + if err != nil { + return nil, errors.Wrapf(err, "failed to read issuer public key file") + } + + revocationPkBytes, err := readFile(filepath.Join(dir, IdemixConfigDirMsp, IdemixConfigFileRevocationPublicKey)) + if err != nil { + return nil, errors.Wrapf(err, "failed to read revocation public key file") + } + + idemixConfig := &msp.IdemixMSPConfig{ + Name: ID, + Ipk: ipkBytes, + RevocationPk: revocationPkBytes, + } + + signerBytes, err := readFile(filepath.Join(dir, IdemixConfigDirUser, IdemixConfigFileSigner)) + if err == nil { + signerConfig := &msp.IdemixMSPSignerConfig{} + err = proto.Unmarshal(signerBytes, signerConfig) + if err != nil { + return nil, err + } + idemixConfig.Signer = signerConfig + } + + confBytes, err := proto.Marshal(idemixConfig) + if err != nil { + return nil, err + } + + return &msp.MSPConfig{Config: confBytes, Type: int32(IDEMIX)}, nil } diff --git a/vendor/github.com/IBM/idemix/msp.go b/vendor/github.com/IBM/idemix/msp.go new file mode 100644 index 00000000000..b44279173e6 --- /dev/null +++ b/vendor/github.com/IBM/idemix/msp.go @@ -0,0 +1,218 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package idemix + +import ( + "time" + + "github.com/hyperledger/fabric-protos-go/msp" +) + +// IdentityDeserializer is implemented by both MSPManger and MSP +type IdentityDeserializer interface { + // DeserializeIdentity deserializes an identity. + // Deserialization will fail if the identity is associated to + // an msp that is different from this one that is performing + // the deserialization. + DeserializeIdentity(serializedIdentity []byte) (Identity, error) + + // IsWellFormed checks if the given identity can be deserialized into its provider-specific form + IsWellFormed(identity *msp.SerializedIdentity) error +} + +// Membership service provider APIs for Hyperledger Fabric: +// +// By "membership service provider" we refer to an abstract component of the +// system that would provide (anonymous) credentials to clients, and peers for +// them to participate in Hyperledger/fabric network. Clients use these +// credentials to authenticate their transactions, and peers use these credentials +// to authenticate transaction processing results (endorsements). While +// strongly connected to the transaction processing components of the systems, +// this interface aims to have membership services components defined, in such +// a way such that alternate implementations of this can be smoothly plugged in +// without modifying the core of transaction processing components of the system. +// +// This file includes Membership service provider interface that covers the +// needs of a peer membership service provider interface. + +// MSPManager is an interface defining a manager of one or more MSPs. This +// essentially acts as a mediator to MSP calls and routes MSP related calls +// to the appropriate MSP. +// This object is immutable, it is initialized once and never changed. +type MSPManager interface { + + // IdentityDeserializer interface needs to be implemented by MSPManager + IdentityDeserializer + + // Setup the MSP manager instance according to configuration information + Setup(msps []MSP) error + + // GetMSPs Provides a list of Membership Service providers + GetMSPs() (map[string]MSP, error) +} + +// MSP is the minimal Membership Service Provider Interface to be implemented +// to accommodate peer functionality +type MSP interface { + + // IdentityDeserializer interface needs to be implemented by MSP + IdentityDeserializer + + // Setup the MSP instance according to configuration information + Setup(config *msp.MSPConfig) error + + // GetVersion returns the version of this MSP + GetVersion() MSPVersion + + // GetType returns the provider type + GetType() ProviderType + + // GetIdentifier returns the provider identifier + GetIdentifier() (string, error) + + // GetDefaultSigningIdentity returns the default signing identity + GetDefaultSigningIdentity() (SigningIdentity, error) + + // GetTLSRootCerts returns the TLS root certificates for this MSP + GetTLSRootCerts() [][]byte + + // GetTLSIntermediateCerts returns the TLS intermediate root certificates for this MSP + GetTLSIntermediateCerts() [][]byte + + // Validate checks whether the supplied identity is valid + Validate(id Identity) error + + // SatisfiesPrincipal checks whether the identity matches + // the description supplied in MSPPrincipal. The check may + // involve a byte-by-byte comparison (if the principal is + // a serialized identity) or may require MSP validation + SatisfiesPrincipal(id Identity, principal *msp.MSPPrincipal) error +} + +// OUIdentifier represents an organizational unit and +// its related chain of trust identifier. +type OUIdentifier struct { + // CertifiersIdentifier is the hash of certificates chain of trust + // related to this organizational unit + CertifiersIdentifier []byte + // OrganizationUnitIdentifier defines the organizational unit under the + // MSP identified with MSPIdentifier + OrganizationalUnitIdentifier string +} + +// From this point on, there are interfaces that are shared within the peer and client API +// of the membership service provider. + +// Identity interface defining operations associated to a "certificate". +// That is, the public part of the identity could be thought to be a certificate, +// and offers solely signature verification capabilities. This is to be used +// at the peer side when verifying certificates that transactions are signed +// with, and verifying signatures that correspond to these certificates./// +type Identity interface { + + // ExpiresAt returns the time at which the Identity expires. + // If the returned time is the zero value, it implies + // the Identity does not expire, or that its expiration + // time is unknown + ExpiresAt() time.Time + + // GetIdentifier returns the identifier of that identity + GetIdentifier() *IdentityIdentifier + + // GetMSPIdentifier returns the MSP Id for this instance + GetMSPIdentifier() string + + // Validate uses the rules that govern this identity to validate it. + // E.g., if it is a fabric TCert implemented as identity, validate + // will check the TCert signature against the assumed root certificate + // authority. + Validate() error + + // GetOrganizationalUnits returns zero or more organization units or + // divisions this identity is related to as long as this is public + // information. Certain MSP implementations may use attributes + // that are publicly associated to this identity, or the identifier of + // the root certificate authority that has provided signatures on this + // certificate. + // Examples: + // - if the identity is an x.509 certificate, this function returns one + // or more string which is encoded in the Subject's Distinguished Name + // of the type OU + // TODO: For X.509 based identities, check if we need a dedicated type + // for OU where the Certificate OU is properly namespaced by the + // signer's identity + GetOrganizationalUnits() []*OUIdentifier + + // Anonymous returns true if this is an anonymous identity, false otherwise + Anonymous() bool + + // Verify a signature over some message using this identity as reference + Verify(msg []byte, sig []byte) error + + // Serialize converts an identity to bytes + Serialize() ([]byte, error) + + // SatisfiesPrincipal checks whether this instance matches + // the description supplied in MSPPrincipal. The check may + // involve a byte-by-byte comparison (if the principal is + // a serialized identity) or may require MSP validation + SatisfiesPrincipal(principal *msp.MSPPrincipal) error +} + +// SigningIdentity is an extension of Identity to cover signing capabilities. +// E.g., signing identity should be requested in the case of a client who wishes +// to sign transactions, or fabric endorser who wishes to sign proposal +// processing outcomes. +type SigningIdentity interface { + + // Extends Identity + Identity + + // Sign the message + Sign(msg []byte) ([]byte, error) + + // GetPublicVersion returns the public parts of this identity + GetPublicVersion() Identity +} + +// IdentityIdentifier is a holder for the identifier of a specific +// identity, naturally namespaced, by its provider identifier. +type IdentityIdentifier struct { + + // The identifier of the associated membership service provider + Mspid string + + // The identifier for an identity within a provider + Id string +} + +// ProviderType indicates the type of an identity provider +type ProviderType int + +// The ProviderType of a member relative to the member API +const ( + FABRIC ProviderType = iota // MSP is of FABRIC type + IDEMIX // MSP is of IDEMIX type + OTHER // MSP is of OTHER TYPE + + // NOTE: as new types are added to this set, + // the mspTypes map below must be extended +) + +var mspTypeStrings = map[ProviderType]string{ + FABRIC: "bccsp", + IDEMIX: "idemix", +} + +// ProviderTypeToString returns a string that represents the ProviderType integer +func ProviderTypeToString(id ProviderType) string { + if res, found := mspTypeStrings[id]; found { + return res + } + + return "" +} diff --git a/vendor/github.com/IBM/mathlib/LICENSE b/vendor/github.com/IBM/mathlib/LICENSE new file mode 100644 index 00000000000..261eeb9e9f8 --- /dev/null +++ b/vendor/github.com/IBM/mathlib/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/vendor/github.com/IBM/mathlib/Makefile b/vendor/github.com/IBM/mathlib/Makefile new file mode 100644 index 00000000000..cefc0f5020a --- /dev/null +++ b/vendor/github.com/IBM/mathlib/Makefile @@ -0,0 +1,20 @@ +.PHONY: all +all: checks unit-tests unit-tests-race + +.PHONY: checks +checks: check-deps + @test -z $(shell gofmt -l -s $(shell go list -f '{{.Dir}}' ./... | grep -v mpc) | tee /dev/stderr) || (echo "Fix formatting issues"; exit 1) + @go vet -all $(shell go list -f '{{.Dir}}' ./... | grep -v mpc) + find . -name '*.go' | xargs addlicense -check || (echo "Missing license headers"; exit 1) + +.PHONY: unit-tests +unit-tests: + @go test -timeout 480s -cover $(shell go list ./...) + +.PHONY: unit-tests-race +unit-tests-race: + @export GORACE=history_size=7; go test -timeout 960s -race -cover $(shell go list ./...) + +.PHONY: check-deps +check-deps: + @go get -u github.com/google/addlicense \ No newline at end of file diff --git a/vendor/github.com/IBM/mathlib/README.md b/vendor/github.com/IBM/mathlib/README.md new file mode 100644 index 00000000000..cc1774ecc82 --- /dev/null +++ b/vendor/github.com/IBM/mathlib/README.md @@ -0,0 +1,6 @@ +# mathlib +[![License](https://img.shields.io/badge/license-Apache%202-blue)](LICENSE) +[![Go Report Card](https://goreportcard.com/badge/github.com/IBM/mathlib)](https://goreportcard.com/badge/github.com/IBM/mathlib) +[![Go](https://github.com/IBM/mathlib/actions/workflows/go.yml/badge.svg)](https://github.com/IBM/mathlib/actions/workflows/go.yml/badge.svg) + +Library to perform operations over elements of pairing-friendly elliptic curve groups diff --git a/vendor/github.com/IBM/mathlib/driver/amcl/fp256bn.go b/vendor/github.com/IBM/mathlib/driver/amcl/fp256bn.go new file mode 100644 index 00000000000..9de4b7ab0c2 --- /dev/null +++ b/vendor/github.com/IBM/mathlib/driver/amcl/fp256bn.go @@ -0,0 +1,365 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package amcl + +import ( + r "crypto/rand" + "crypto/sha256" + "io" + "math/big" + "regexp" + "strings" + + "github.com/IBM/mathlib/driver" + "github.com/IBM/mathlib/driver/common" + "github.com/hyperledger/fabric-amcl/amcl" + "github.com/hyperledger/fabric-amcl/amcl/FP256BN" + "github.com/pkg/errors" +) + +/*********************************************************************/ + +type fp256bnZr struct { + *FP256BN.BIG +} + +func (b *fp256bnZr) Plus(a driver.Zr) driver.Zr { + return &fp256bnZr{b.BIG.Plus(a.(*fp256bnZr).BIG)} +} + +func (b *fp256bnZr) PowMod(x driver.Zr) driver.Zr { + q := FP256BN.NewBIGints(FP256BN.CURVE_Order) + + return &fp256bnZr{b.BIG.Powmod(x.(*fp256bnZr).BIG, q)} +} + +func (b *fp256bnZr) Mod(a driver.Zr) { + b.BIG.Mod(a.(*fp256bnZr).BIG) +} + +func (b *fp256bnZr) InvModP(p driver.Zr) { + b.BIG.Invmodp(p.(*fp256bnZr).BIG) +} + +func (b *fp256bnZr) Bytes() []byte { + by := make([]byte, int(FP256BN.MODBYTES)) + b.BIG.ToBytes(by) + return by +} + +func (b *fp256bnZr) Equals(p driver.Zr) bool { + return *b.BIG == *(p.(*fp256bnZr).BIG) +} + +func (b *fp256bnZr) Copy() driver.Zr { + return &fp256bnZr{FP256BN.NewBIGcopy(b.BIG)} +} + +func (b *fp256bnZr) Clone(a driver.Zr) { + c := a.Copy() + b.BIG = c.(*fp256bnZr).BIG +} + +func (b *fp256bnZr) String() string { + return strings.TrimLeft(b.BIG.ToString(), "0") +} + +/*********************************************************************/ + +type fp256bnGt struct { + *FP256BN.FP12 +} + +func (a *fp256bnGt) Equals(b driver.Gt) bool { + return a.FP12.Equals(b.(*fp256bnGt).FP12) +} + +func (a *fp256bnGt) IsUnity() bool { + return a.FP12.Isunity() +} + +func (a *fp256bnGt) Inverse() { + a.FP12.Inverse() +} + +func (a *fp256bnGt) Mul(b driver.Gt) { + a.FP12.Mul(b.(*fp256bnGt).FP12) +} + +func (b *fp256bnGt) ToString() string { + return b.FP12.ToString() +} + +func (b *fp256bnGt) Bytes() []byte { + bytes := make([]byte, 12*int(FP256BN.MODBYTES)) + b.FP12.ToBytes(bytes) + return bytes +} + +/*********************************************************************/ + +type Fp256bn struct { +} + +func (*Fp256bn) Pairing(a driver.G2, b driver.G1) driver.Gt { + return &fp256bnGt{FP256BN.Ate(a.(*fp256bnG2).ECP2, b.(*fp256bnG1).ECP)} +} + +func (*Fp256bn) Pairing2(p2a, p2b driver.G2, p1a, p1b driver.G1) driver.Gt { + return &fp256bnGt{FP256BN.Ate2(p2a.(*fp256bnG2).ECP2, p1a.(*fp256bnG1).ECP, p2b.(*fp256bnG2).ECP2, p1b.(*fp256bnG1).ECP)} +} + +func (*Fp256bn) FExp(e driver.Gt) driver.Gt { + return &fp256bnGt{FP256BN.Fexp(e.(*fp256bnGt).FP12)} +} + +func (*Fp256bn) ModMul(a1, b1, m driver.Zr) driver.Zr { + return &fp256bnZr{FP256BN.Modmul(a1.(*fp256bnZr).BIG, b1.(*fp256bnZr).BIG, m.(*fp256bnZr).BIG)} +} + +func (*Fp256bn) ModNeg(a1, m driver.Zr) driver.Zr { + return &fp256bnZr{FP256BN.Modneg(a1.(*fp256bnZr).BIG, m.(*fp256bnZr).BIG)} +} + +func (*Fp256bn) GenG1() driver.G1 { + return &fp256bnG1{FP256BN.NewECPbigs(FP256BN.NewBIGints(FP256BN.CURVE_Gx), FP256BN.NewBIGints(FP256BN.CURVE_Gy))} +} + +func (*Fp256bn) GenG2() driver.G2 { + return &fp256bnG2{FP256BN.NewECP2fp2s( + FP256BN.NewFP2bigs(FP256BN.NewBIGints(FP256BN.CURVE_Pxa), FP256BN.NewBIGints(FP256BN.CURVE_Pxb)), + FP256BN.NewFP2bigs(FP256BN.NewBIGints(FP256BN.CURVE_Pya), FP256BN.NewBIGints(FP256BN.CURVE_Pyb)))} +} + +func (p *Fp256bn) GenGt() driver.Gt { + return &fp256bnGt{FP256BN.Fexp(FP256BN.Ate(p.GenG2().(*fp256bnG2).ECP2, p.GenG1().(*fp256bnG1).ECP))} +} + +func (p *Fp256bn) GroupOrder() driver.Zr { + return &fp256bnZr{FP256BN.NewBIGints(FP256BN.CURVE_Order)} +} + +func (p *Fp256bn) FieldBytes() int { + return int(FP256BN.MODBYTES) +} + +func (p *Fp256bn) NewG1() driver.G1 { + return &fp256bnG1{FP256BN.NewECP()} +} + +func (p *Fp256bn) NewG2() driver.G2 { + return &fp256bnG2{FP256BN.NewECP2()} +} + +func (p *Fp256bn) NewG1FromCoords(ix, iy driver.Zr) driver.G1 { + return &fp256bnG1{FP256BN.NewECPbigs(ix.(*fp256bnZr).BIG, iy.(*fp256bnZr).BIG)} +} + +func (p *Fp256bn) NewZrFromBytes(b []byte) driver.Zr { + return &fp256bnZr{FP256BN.FromBytes(b)} +} + +func (p *Fp256bn) NewZrFromInt(i int64) driver.Zr { + var i0, i1, i2, i3, i4 int64 + + sign := int64(1) + if i < 0 { + sign = -1 + } + + b := common.BigToBytes(big.NewInt(i * sign)) + + pos := 32 + i0 = new(big.Int).SetBytes(b[pos-7 : pos]).Int64() + pos -= 7 + i1 = new(big.Int).SetBytes(b[pos-7 : pos]).Int64() + pos -= 7 + i2 = new(big.Int).SetBytes(b[pos-7 : pos]).Int64() + pos -= 7 + i3 = new(big.Int).SetBytes(b[pos-7 : pos]).Int64() + pos -= 7 + i4 = new(big.Int).SetBytes(b[0:pos]).Int64() + + zr := FP256BN.NewBIGints([FP256BN.NLEN]FP256BN.Chunk{FP256BN.Chunk(i0), FP256BN.Chunk(i1), FP256BN.Chunk(i2), FP256BN.Chunk(i3), FP256BN.Chunk(i4)}) + if sign < 0 { + zr = FP256BN.NewBIGint(0).Minus(zr) + } + + return &fp256bnZr{zr} +} + +func (p *Fp256bn) NewG1FromBytes(b []byte) driver.G1 { + return &fp256bnG1{FP256BN.ECP_fromBytes(b)} +} + +func (p *Fp256bn) NewG2FromBytes(b []byte) driver.G2 { + return &fp256bnG2{FP256BN.ECP2_fromBytes(b)} +} + +func (p *Fp256bn) NewGtFromBytes(b []byte) driver.Gt { + return &fp256bnGt{FP256BN.FP12_fromBytes(b)} +} + +func (p *Fp256bn) ModAdd(a, b, m driver.Zr) driver.Zr { + c := a.Plus(b) + c.Mod(m) + return c +} + +func (p *Fp256bn) ModSub(a, b, m driver.Zr) driver.Zr { + return p.ModAdd(a, p.ModNeg(b, m), m) +} + +func (p *Fp256bn) HashToZr(data []byte) driver.Zr { + digest := sha256.Sum256(data) + digestBig := FP256BN.FromBytes(digest[:]) + digestBig.Mod(FP256BN.NewBIGints(FP256BN.CURVE_Order)) + return &fp256bnZr{digestBig} +} + +func (p *Fp256bn) HashToG1(data []byte) driver.G1 { + return &fp256bnG1{FP256BN.Bls_hash(string(data))} +} + +func (p *Fp256bn) Rand() (io.Reader, error) { + seedLength := 32 + b := make([]byte, seedLength) + _, err := r.Read(b) + if err != nil { + return nil, errors.Wrap(err, "error getting randomness for seed") + } + rng := amcl.NewRAND() + rng.Clean() + rng.Seed(seedLength, b) + return &rand{rng}, nil +} + +func (p *Fp256bn) NewRandomZr(rng io.Reader) driver.Zr { + // curve order q + q := FP256BN.NewBIGints(FP256BN.CURVE_Order) + + // Take random element in Zq + return &fp256bnZr{FP256BN.Randomnum(q, rng.(*rand).R)} +} + +/*********************************************************************/ + +type fp256bnG1 struct { + *FP256BN.ECP +} + +func (e *fp256bnG1) Clone(a driver.G1) { + e.ECP.Copy(a.(*fp256bnG1).ECP) +} + +func (e *fp256bnG1) Copy() driver.G1 { + c := FP256BN.NewECP() + c.Copy(e.ECP) + return &fp256bnG1{c} +} + +func (e *fp256bnG1) Add(a driver.G1) { + e.ECP.Add(a.(*fp256bnG1).ECP) +} + +func (e *fp256bnG1) Mul(a driver.Zr) driver.G1 { + return &fp256bnG1{FP256BN.G1mul(e.ECP, a.(*fp256bnZr).BIG)} +} + +func (e *fp256bnG1) Mul2(ee driver.Zr, Q driver.G1, f driver.Zr) driver.G1 { + return &fp256bnG1{e.ECP.Mul2(ee.(*fp256bnZr).BIG, Q.(*fp256bnG1).ECP, f.(*fp256bnZr).BIG)} +} + +func (e *fp256bnG1) Equals(a driver.G1) bool { + return e.ECP.Equals(a.(*fp256bnG1).ECP) +} + +func (e *fp256bnG1) IsInfinity() bool { + return e.ECP.Is_infinity() +} + +func (e *fp256bnG1) Bytes() []byte { + b := make([]byte, 2*int(FP256BN.MODBYTES)+1) + e.ECP.ToBytes(b, false) + return b +} + +func (e *fp256bnG1) Sub(a driver.G1) { + e.ECP.Sub(a.(*fp256bnG1).ECP) +} + +var g1StrRegexp *regexp.Regexp = regexp.MustCompile(`^\(([0-9a-f]+),([0-9a-f]+)\)$`) + +func (b *fp256bnG1) String() string { + rawstr := b.ECP.ToString() + m := g1StrRegexp.FindAllStringSubmatch(rawstr, -1) + return "(" + strings.TrimLeft(m[0][1], "0") + "," + strings.TrimLeft(m[0][2], "0") + ")" +} + +/*********************************************************************/ + +type fp256bnG2 struct { + *FP256BN.ECP2 +} + +func (e *fp256bnG2) Equals(a driver.G2) bool { + return e.ECP2.Equals(a.(*fp256bnG2).ECP2) +} + +func (e *fp256bnG2) Clone(a driver.G2) { + e.ECP2.Copy(a.(*fp256bnG2).ECP2) +} + +func (e *fp256bnG2) Copy() driver.G2 { + c := FP256BN.NewECP2() + c.Copy(e.ECP2) + return &fp256bnG2{c} +} + +func (e *fp256bnG2) Add(a driver.G2) { + e.ECP2.Add(a.(*fp256bnG2).ECP2) +} + +func (e *fp256bnG2) Sub(a driver.G2) { + e.ECP2.Sub(a.(*fp256bnG2).ECP2) +} + +func (e *fp256bnG2) Mul(a driver.Zr) driver.G2 { + return &fp256bnG2{e.ECP2.Mul(a.(*fp256bnZr).BIG)} +} + +func (e *fp256bnG2) Affine() { + e.ECP2.Affine() +} + +func (e *fp256bnG2) Bytes() []byte { + b := make([]byte, 4*int(FP256BN.MODBYTES)) + e.ECP2.ToBytes(b) + return b +} + +func (b *fp256bnG2) String() string { + return b.ECP2.ToString() +} + +/*********************************************************************/ + +type rand struct { + R *amcl.RAND +} + +func (*rand) Read(p []byte) (n int, err error) { + panic("not used") +} + +/*********************************************************************/ + +func bigToBytes(big *FP256BN.BIG) []byte { + ret := make([]byte, int(FP256BN.MODBYTES)) + big.ToBytes(ret) + return ret +} diff --git a/vendor/github.com/IBM/mathlib/driver/amcl/fp256bn_miracl.go b/vendor/github.com/IBM/mathlib/driver/amcl/fp256bn_miracl.go new file mode 100644 index 00000000000..5a65694a47c --- /dev/null +++ b/vendor/github.com/IBM/mathlib/driver/amcl/fp256bn_miracl.go @@ -0,0 +1,364 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package amcl + +import ( + r "crypto/rand" + "crypto/sha256" + "io" + "math/big" + "strings" + + "github.com/IBM/mathlib/driver" + "github.com/IBM/mathlib/driver/common" + "github.com/hyperledger/fabric-amcl/core" + "github.com/hyperledger/fabric-amcl/core/FP256BN" + "github.com/pkg/errors" +) + +/*********************************************************************/ + +type fp256bnMiraclZr struct { + *FP256BN.BIG +} + +func (b *fp256bnMiraclZr) Plus(a driver.Zr) driver.Zr { + return &fp256bnMiraclZr{b.BIG.Plus(a.(*fp256bnMiraclZr).BIG)} +} + +func (b *fp256bnMiraclZr) PowMod(x driver.Zr) driver.Zr { + q := FP256BN.NewBIGints(FP256BN.CURVE_Order) + + return &fp256bnMiraclZr{b.BIG.Powmod(x.(*fp256bnMiraclZr).BIG, q)} +} + +func (b *fp256bnMiraclZr) Mod(a driver.Zr) { + b.BIG.Mod(a.(*fp256bnMiraclZr).BIG) +} + +func (b *fp256bnMiraclZr) InvModP(p driver.Zr) { + b.BIG.Invmodp(p.(*fp256bnMiraclZr).BIG) +} + +func (b *fp256bnMiraclZr) Bytes() []byte { + by := make([]byte, int(FP256BN.MODBYTES)) + b.BIG.ToBytes(by) + return by +} + +func (b *fp256bnMiraclZr) Equals(p driver.Zr) bool { + return *b.BIG == *(p.(*fp256bnMiraclZr).BIG) +} + +func (b *fp256bnMiraclZr) Copy() driver.Zr { + return &fp256bnMiraclZr{FP256BN.NewBIGcopy(b.BIG)} +} + +func (b *fp256bnMiraclZr) Clone(a driver.Zr) { + c := a.Copy() + b.BIG = c.(*fp256bnMiraclZr).BIG +} + +func (b *fp256bnMiraclZr) String() string { + return strings.TrimLeft(b.BIG.ToString(), "0") +} + +/*********************************************************************/ + +type fp256bnMiraclGt struct { + *FP256BN.FP12 +} + +func (a *fp256bnMiraclGt) Equals(b driver.Gt) bool { + return a.FP12.Equals(b.(*fp256bnMiraclGt).FP12) +} + +func (a *fp256bnMiraclGt) IsUnity() bool { + return a.FP12.Isunity() +} + +func (a *fp256bnMiraclGt) Inverse() { + a.FP12.Inverse() +} + +func (a *fp256bnMiraclGt) Mul(b driver.Gt) { + a.FP12.Mul(b.(*fp256bnMiraclGt).FP12) +} + +func (b *fp256bnMiraclGt) ToString() string { + return b.FP12.ToString() +} + +func (b *fp256bnMiraclGt) Bytes() []byte { + bytes := make([]byte, 12*int(FP256BN.MODBYTES)) + b.FP12.ToBytes(bytes) + return bytes +} + +/*********************************************************************/ + +type Fp256Miraclbn struct { +} + +func (*Fp256Miraclbn) Pairing(a driver.G2, b driver.G1) driver.Gt { + return &fp256bnMiraclGt{FP256BN.Ate(a.(*fp256bnMiraclG2).ECP2, b.(*fp256bnMiraclG1).ECP)} +} + +func (*Fp256Miraclbn) Pairing2(p2a, p2b driver.G2, p1a, p1b driver.G1) driver.Gt { + return &fp256bnMiraclGt{FP256BN.Ate2(p2a.(*fp256bnMiraclG2).ECP2, p1a.(*fp256bnMiraclG1).ECP, p2b.(*fp256bnMiraclG2).ECP2, p1b.(*fp256bnMiraclG1).ECP)} +} + +func (*Fp256Miraclbn) FExp(e driver.Gt) driver.Gt { + return &fp256bnMiraclGt{FP256BN.Fexp(e.(*fp256bnMiraclGt).FP12)} +} + +func (*Fp256Miraclbn) ModMul(a1, b1, m driver.Zr) driver.Zr { + return &fp256bnMiraclZr{FP256BN.Modmul(a1.(*fp256bnMiraclZr).BIG, b1.(*fp256bnMiraclZr).BIG, m.(*fp256bnMiraclZr).BIG)} +} + +func (*Fp256Miraclbn) ModNeg(a1, m driver.Zr) driver.Zr { + return &fp256bnMiraclZr{FP256BN.Modneg(a1.(*fp256bnMiraclZr).BIG, m.(*fp256bnMiraclZr).BIG)} +} + +func (*Fp256Miraclbn) GenG1() driver.G1 { + return &fp256bnMiraclG1{FP256BN.NewECPbigs(FP256BN.NewBIGints(FP256BN.CURVE_Gx), FP256BN.NewBIGints(FP256BN.CURVE_Gy))} +} + +func (*Fp256Miraclbn) GenG2() driver.G2 { + return &fp256bnMiraclG2{FP256BN.NewECP2fp2s( + FP256BN.NewFP2bigs(FP256BN.NewBIGints(FP256BN.CURVE_Pxa), FP256BN.NewBIGints(FP256BN.CURVE_Pxb)), + FP256BN.NewFP2bigs(FP256BN.NewBIGints(FP256BN.CURVE_Pya), FP256BN.NewBIGints(FP256BN.CURVE_Pyb)))} +} + +func (p *Fp256Miraclbn) GenGt() driver.Gt { + return &fp256bnMiraclGt{FP256BN.Fexp(FP256BN.Ate(p.GenG2().(*fp256bnMiraclG2).ECP2, p.GenG1().(*fp256bnMiraclG1).ECP))} +} + +func (p *Fp256Miraclbn) GroupOrder() driver.Zr { + return &fp256bnMiraclZr{FP256BN.NewBIGints(FP256BN.CURVE_Order)} +} + +func (p *Fp256Miraclbn) FieldBytes() int { + return int(FP256BN.MODBYTES) +} + +func (p *Fp256Miraclbn) NewG1() driver.G1 { + return &fp256bnMiraclG1{FP256BN.NewECP()} +} + +func (p *Fp256Miraclbn) NewG2() driver.G2 { + return &fp256bnMiraclG2{FP256BN.NewECP2()} +} + +func (p *Fp256Miraclbn) NewG1FromCoords(ix, iy driver.Zr) driver.G1 { + return &fp256bnMiraclG1{FP256BN.NewECPbigs(ix.(*fp256bnMiraclZr).BIG, iy.(*fp256bnMiraclZr).BIG)} +} + +func (p *Fp256Miraclbn) NewZrFromBytes(b []byte) driver.Zr { + return &fp256bnMiraclZr{FP256BN.FromBytes(b)} +} + +func (p *Fp256Miraclbn) NewZrFromInt(i int64) driver.Zr { + var i0, i1, i2, i3, i4 int64 + + sign := int64(1) + if i < 0 { + sign = -1 + } + + b := common.BigToBytes(big.NewInt(i * sign)) + + pos := 32 + i0 = new(big.Int).SetBytes(b[pos-7 : pos]).Int64() + pos -= 7 + i1 = new(big.Int).SetBytes(b[pos-7 : pos]).Int64() + pos -= 7 + i2 = new(big.Int).SetBytes(b[pos-7 : pos]).Int64() + pos -= 7 + i3 = new(big.Int).SetBytes(b[pos-7 : pos]).Int64() + pos -= 7 + i4 = new(big.Int).SetBytes(b[0:pos]).Int64() + + zr := FP256BN.NewBIGints([FP256BN.NLEN]FP256BN.Chunk{FP256BN.Chunk(i0), FP256BN.Chunk(i1), FP256BN.Chunk(i2), FP256BN.Chunk(i3), FP256BN.Chunk(i4)}) + if sign < 0 { + zr = FP256BN.NewBIGint(0).Minus(zr) + } + + return &fp256bnMiraclZr{zr} +} + +func (p *Fp256Miraclbn) NewG1FromBytes(b []byte) driver.G1 { + return &fp256bnMiraclG1{FP256BN.ECP_fromBytes(b)} +} + +func (p *Fp256Miraclbn) NewG2FromBytes(b []byte) driver.G2 { + return &fp256bnMiraclG2{FP256BN.ECP2_fromBytes(b)} +} + +func (p *Fp256Miraclbn) NewGtFromBytes(b []byte) driver.Gt { + return &fp256bnMiraclGt{FP256BN.FP12_fromBytes(b)} +} + +func (p *Fp256Miraclbn) ModAdd(a, b, m driver.Zr) driver.Zr { + c := a.Plus(b) + c.Mod(m) + return c +} + +func (p *Fp256Miraclbn) ModSub(a, b, m driver.Zr) driver.Zr { + return p.ModAdd(a, p.ModNeg(b, m), m) +} + +func (p *Fp256Miraclbn) HashToZr(data []byte) driver.Zr { + digest := sha256.Sum256(data) + digestBig := FP256BN.FromBytes(digest[:]) + digestBig.Mod(FP256BN.NewBIGints(FP256BN.CURVE_Order)) + return &fp256bnMiraclZr{digestBig} +} + +func (p *Fp256Miraclbn) HashToG1(data []byte) driver.G1 { + zr := p.HashToZr(data) + fp := FP256BN.NewFPbig(zr.(*fp256bnMiraclZr).BIG) + return &fp256bnMiraclG1{FP256BN.ECP_map2point(fp)} +} + +func (p *Fp256Miraclbn) Rand() (io.Reader, error) { + seedLength := 32 + b := make([]byte, seedLength) + _, err := r.Read(b) + if err != nil { + return nil, errors.Wrap(err, "error getting randomness for seed") + } + rng := core.NewRAND() + rng.Clean() + rng.Seed(seedLength, b) + return &randMiracl{rng}, nil +} + +func (p *Fp256Miraclbn) NewRandomZr(rng io.Reader) driver.Zr { + // curve order q + q := FP256BN.NewBIGints(FP256BN.CURVE_Order) + + // Take random element in Zq + return &fp256bnMiraclZr{FP256BN.Randomnum(q, rng.(*randMiracl).R)} +} + +/*********************************************************************/ + +type fp256bnMiraclG1 struct { + *FP256BN.ECP +} + +func (e *fp256bnMiraclG1) Clone(a driver.G1) { + e.ECP.Copy(a.(*fp256bnMiraclG1).ECP) +} + +func (e *fp256bnMiraclG1) Copy() driver.G1 { + c := FP256BN.NewECP() + c.Copy(e.ECP) + return &fp256bnMiraclG1{c} +} + +func (e *fp256bnMiraclG1) Add(a driver.G1) { + e.ECP.Add(a.(*fp256bnMiraclG1).ECP) +} + +func (e *fp256bnMiraclG1) Mul(a driver.Zr) driver.G1 { + return &fp256bnMiraclG1{FP256BN.G1mul(e.ECP, a.(*fp256bnMiraclZr).BIG)} +} + +func (e *fp256bnMiraclG1) Mul2(ee driver.Zr, Q driver.G1, f driver.Zr) driver.G1 { + return &fp256bnMiraclG1{e.ECP.Mul2(ee.(*fp256bnMiraclZr).BIG, Q.(*fp256bnMiraclG1).ECP, f.(*fp256bnMiraclZr).BIG)} +} + +func (e *fp256bnMiraclG1) Equals(a driver.G1) bool { + return e.ECP.Equals(a.(*fp256bnMiraclG1).ECP) +} + +func (e *fp256bnMiraclG1) IsInfinity() bool { + return e.ECP.Is_infinity() +} + +func (e *fp256bnMiraclG1) Bytes() []byte { + b := make([]byte, 2*int(FP256BN.MODBYTES)+1) + e.ECP.ToBytes(b, false) + return b +} + +func (e *fp256bnMiraclG1) Sub(a driver.G1) { + e.ECP.Sub(a.(*fp256bnMiraclG1).ECP) +} + +func (b *fp256bnMiraclG1) String() string { + rawstr := b.ECP.ToString() + m := g1StrRegexp.FindAllStringSubmatch(rawstr, -1) + return "(" + strings.TrimLeft(m[0][1], "0") + "," + strings.TrimLeft(m[0][2], "0") + ")" +} + +/*********************************************************************/ + +type fp256bnMiraclG2 struct { + *FP256BN.ECP2 +} + +func (e *fp256bnMiraclG2) Equals(a driver.G2) bool { + return e.ECP2.Equals(a.(*fp256bnMiraclG2).ECP2) +} + +func (e *fp256bnMiraclG2) Clone(a driver.G2) { + e.ECP2.Copy(a.(*fp256bnMiraclG2).ECP2) +} + +func (e *fp256bnMiraclG2) Copy() driver.G2 { + c := FP256BN.NewECP2() + c.Copy(e.ECP2) + return &fp256bnMiraclG2{c} +} + +func (e *fp256bnMiraclG2) Add(a driver.G2) { + e.ECP2.Add(a.(*fp256bnMiraclG2).ECP2) +} + +func (e *fp256bnMiraclG2) Sub(a driver.G2) { + e.ECP2.Sub(a.(*fp256bnMiraclG2).ECP2) +} + +func (e *fp256bnMiraclG2) Mul(a driver.Zr) driver.G2 { + return &fp256bnMiraclG2{e.ECP2.Mul(a.(*fp256bnMiraclZr).BIG)} +} + +func (e *fp256bnMiraclG2) Affine() { + e.ECP2.Affine() +} + +func (e *fp256bnMiraclG2) Bytes() []byte { + b := make([]byte, 4*int(FP256BN.MODBYTES)+1) + e.ECP2.ToBytes(b, false) + return b +} + +func (b *fp256bnMiraclG2) String() string { + return b.ECP2.ToString() +} + +/*********************************************************************/ + +type randMiracl struct { + R *core.RAND +} + +func (*randMiracl) Read(p []byte) (n int, err error) { + panic("not used") +} + +/*********************************************************************/ + +func bigToBytesMiracl(big *FP256BN.BIG) []byte { + ret := make([]byte, int(FP256BN.MODBYTES)) + big.ToBytes(ret) + return ret +} diff --git a/vendor/github.com/IBM/mathlib/driver/common/big.go b/vendor/github.com/IBM/mathlib/driver/common/big.go new file mode 100644 index 00000000000..b25fb2cf2ed --- /dev/null +++ b/vendor/github.com/IBM/mathlib/driver/common/big.go @@ -0,0 +1,27 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package common + +import "math/big" + +var onebytes = []byte{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} +var onebig = new(big.Int).SetBytes(onebytes) + +func BigToBytes(bi *big.Int) []byte { + b := bi.Bytes() + + if bi.Sign() >= 0 { + return append(make([]byte, 32-len(b)), b...) + } + + twoscomp := new(big.Int).Set(onebig) + pos := new(big.Int).Neg(bi) + twoscomp = twoscomp.Sub(twoscomp, pos) + twoscomp = twoscomp.Add(twoscomp, big.NewInt(1)) + b = twoscomp.Bytes() + return append(onebytes[:32-len(b)], b...) +} diff --git a/vendor/github.com/IBM/mathlib/driver/gurvy/bn254.go b/vendor/github.com/IBM/mathlib/driver/gurvy/bn254.go new file mode 100644 index 00000000000..8d2d1d713fd --- /dev/null +++ b/vendor/github.com/IBM/mathlib/driver/gurvy/bn254.go @@ -0,0 +1,407 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package gurvy + +import ( + "crypto/rand" + "crypto/sha256" + "fmt" + "io" + "math/big" + "regexp" + "strings" + + "github.com/IBM/mathlib/driver" + "github.com/IBM/mathlib/driver/common" + "github.com/consensys/gnark-crypto/ecc/bn254" + "github.com/consensys/gnark-crypto/ecc/bn254/fr" +) + +/*********************************************************************/ + +type bn254Zr struct { + *big.Int +} + +func (z *bn254Zr) Plus(a driver.Zr) driver.Zr { + return &bn254Zr{new(big.Int).Add(z.Int, a.(*bn254Zr).Int)} +} + +func (z *bn254Zr) Mod(a driver.Zr) { + z.Int.Mod(z.Int, a.(*bn254Zr).Int) +} + +func (z *bn254Zr) PowMod(x driver.Zr) driver.Zr { + return &bn254Zr{new(big.Int).Exp(z.Int, x.(*bn254Zr).Int, fr.Modulus())} +} + +func (z *bn254Zr) InvModP(a driver.Zr) { + z.Int.ModInverse(z.Int, a.(*bn254Zr).Int) +} + +func (z *bn254Zr) Bytes() []byte { + return common.BigToBytes(z.Int) +} + +func (z *bn254Zr) Equals(a driver.Zr) bool { + return z.Int.Cmp(a.(*bn254Zr).Int) == 0 +} + +func (z *bn254Zr) Copy() driver.Zr { + return &bn254Zr{new(big.Int).Set(z.Int)} +} + +func (z *bn254Zr) Clone(a driver.Zr) { + raw := a.(*bn254Zr).Int.Bytes() + z.Int.SetBytes(raw) +} + +func (z *bn254Zr) String() string { + return z.Int.Text(16) +} + +/*********************************************************************/ + +type bn254G1 struct { + *bn254.G1Affine +} + +func (g *bn254G1) Clone(a driver.G1) { + raw := a.(*bn254G1).G1Affine.Bytes() + _, err := g.SetBytes(raw[:]) + if err != nil { + panic("could not copy point") + } +} + +func (e *bn254G1) Copy() driver.G1 { + c := &bn254.G1Affine{} + c.Set(e.G1Affine) + return &bn254G1{c} +} + +func (g *bn254G1) Add(a driver.G1) { + j := &bn254.G1Jac{} + j.FromAffine(g.G1Affine) + j.AddMixed((*bn254.G1Affine)(a.(*bn254G1).G1Affine)) + g.G1Affine.FromJacobian(j) +} + +func (g *bn254G1) Mul(a driver.Zr) driver.G1 { + gc := &bn254G1{&bn254.G1Affine{}} + gc.Clone(g) + gc.G1Affine.ScalarMultiplication(g.G1Affine, a.(*bn254Zr).Int) + + return gc +} + +func (g *bn254G1) Mul2(e driver.Zr, Q driver.G1, f driver.Zr) driver.G1 { + a := g.Mul(e) + b := Q.Mul(f) + a.Add(b) + + return a +} + +func (g *bn254G1) Equals(a driver.G1) bool { + return g.G1Affine.Equal(a.(*bn254G1).G1Affine) +} + +func (g *bn254G1) Bytes() []byte { + raw := g.G1Affine.RawBytes() + return raw[:] +} + +func (g *bn254G1) Sub(a driver.G1) { + j, k := &bn254.G1Jac{}, &bn254.G1Jac{} + j.FromAffine(g.G1Affine) + k.FromAffine(a.(*bn254G1).G1Affine) + j.SubAssign(k) + g.G1Affine.FromJacobian(j) +} + +func (g *bn254G1) IsInfinity() bool { + return g.G1Affine.IsInfinity() +} + +var g1StrRegexp *regexp.Regexp = regexp.MustCompile(`^E\([[]([0-9]+),([0-9]+)[]]\),$`) + +func (g *bn254G1) String() string { + rawstr := g.G1Affine.String() + m := g1StrRegexp.FindAllStringSubmatch(rawstr, -1) + return "(" + strings.TrimLeft(m[0][1], "0") + "," + strings.TrimLeft(m[0][2], "0") + ")" +} + +/*********************************************************************/ + +type bn254G2 struct { + *bn254.G2Affine +} + +func (g *bn254G2) Clone(a driver.G2) { + raw := a.(*bn254G2).G2Affine.Bytes() + _, err := g.SetBytes(raw[:]) + if err != nil { + panic("could not copy point") + } +} + +func (e *bn254G2) Copy() driver.G2 { + c := &bn254.G2Affine{} + c.Set(e.G2Affine) + return &bn254G2{c} +} + +func (g *bn254G2) Mul(a driver.Zr) driver.G2 { + gc := &bn254G2{&bn254.G2Affine{}} + gc.Clone(g) + gc.G2Affine.ScalarMultiplication(g.G2Affine, a.(*bn254Zr).Int) + + return gc +} + +func (g *bn254G2) Add(a driver.G2) { + j := &bn254.G2Jac{} + j.FromAffine(g.G2Affine) + j.AddMixed((*bn254.G2Affine)(a.(*bn254G2).G2Affine)) + g.G2Affine.FromJacobian(j) +} + +func (g *bn254G2) Sub(a driver.G2) { + j := &bn254.G2Jac{} + j.FromAffine(g.G2Affine) + aJac := &bn254.G2Jac{} + aJac.FromAffine((*bn254.G2Affine)(a.(*bn254G2).G2Affine)) + j.SubAssign(aJac) + g.G2Affine.FromJacobian(j) +} + +func (g *bn254G2) Affine() { + // we're always affine +} + +func (g *bn254G2) Bytes() []byte { + raw := g.G2Affine.RawBytes() + return raw[:] +} + +func (g *bn254G2) String() string { + return g.G2Affine.String() +} + +func (g *bn254G2) Equals(a driver.G2) bool { + return g.G2Affine.Equal(a.(*bn254G2).G2Affine) +} + +/*********************************************************************/ + +type bn254Gt struct { + *bn254.GT +} + +func (g *bn254Gt) Equals(a driver.Gt) bool { + return g.GT.Equal(a.(*bn254Gt).GT) +} + +func (g *bn254Gt) Inverse() { + g.GT.Inverse(g.GT) +} + +func (g *bn254Gt) Mul(a driver.Gt) { + g.GT.Mul(g.GT, a.(*bn254Gt).GT) +} + +func (g *bn254Gt) IsUnity() bool { + unity := &bn254.GT{} + unity.SetOne() + + return unity.Equal(g.GT) +} + +func (g *bn254Gt) ToString() string { + return g.GT.String() +} + +func (g *bn254Gt) Bytes() []byte { + raw := g.GT.Bytes() + return raw[:] +} + +/*********************************************************************/ + +type Bn254 struct { +} + +func (c *Bn254) Pairing(p2 driver.G2, p1 driver.G1) driver.Gt { + t, err := bn254.MillerLoop([]bn254.G1Affine{*p1.(*bn254G1).G1Affine}, []bn254.G2Affine{*p2.(*bn254G2).G2Affine}) + if err != nil { + panic(fmt.Sprintf("pairing failed [%s]", err.Error())) + } + + return &bn254Gt{&t} +} + +func (c *Bn254) Pairing2(p2a, p2b driver.G2, p1a, p1b driver.G1) driver.Gt { + t, err := bn254.MillerLoop([]bn254.G1Affine{*p1a.(*bn254G1).G1Affine, *p1b.(*bn254G1).G1Affine}, []bn254.G2Affine{*p2a.(*bn254G2).G2Affine, *p2b.(*bn254G2).G2Affine}) + if err != nil { + panic(fmt.Sprintf("pairing 2 failed [%s]", err.Error())) + } + + return &bn254Gt{&t} +} + +func (c *Bn254) FExp(a driver.Gt) driver.Gt { + gt := bn254.FinalExponentiation(a.(*bn254Gt).GT) + return &bn254Gt{>} +} + +func (*Bn254) ModAdd(a, b, m driver.Zr) driver.Zr { + c := a.Plus(b) + c.Mod(m) + return c +} + +func (c *Bn254) ModSub(a, b, m driver.Zr) driver.Zr { + return c.ModAdd(a, c.ModNeg(b, m), m) +} + +func (c *Bn254) ModNeg(a1, m driver.Zr) driver.Zr { + a := a1.Copy() + a.Mod(m) + return &bn254Zr{a.(*bn254Zr).Int.Sub(m.(*bn254Zr).Int, a.(*bn254Zr).Int)} +} + +func (c *Bn254) ModMul(a1, b1, m driver.Zr) driver.Zr { + a := a1.Copy() + b := b1.Copy() + a.Mod(m) + b.Mod(m) + return &bn254Zr{a.(*bn254Zr).Int.Mul(a.(*bn254Zr).Int, b.(*bn254Zr).Int)} +} + +func (c *Bn254) GenG1() driver.G1 { + _, _, g1, _ := bn254.Generators() + raw := g1.Bytes() + + r := &bn254.G1Affine{} + _, err := r.SetBytes(raw[:]) + if err != nil { + panic("could not generate point") + } + + return &bn254G1{r} +} + +func (c *Bn254) GenG2() driver.G2 { + _, _, _, g2 := bn254.Generators() + raw := g2.Bytes() + + r := &bn254.G2Affine{} + _, err := r.SetBytes(raw[:]) + if err != nil { + panic("could not generate point") + } + + return &bn254G2{r} +} + +func (c *Bn254) GenGt() driver.Gt { + g1 := c.GenG1() + g2 := c.GenG2() + gengt := c.Pairing(g2, g1) + gengt = c.FExp(gengt) + return gengt +} + +func (c *Bn254) GroupOrder() driver.Zr { + return &bn254Zr{fr.Modulus()} +} + +func (c *Bn254) FieldBytes() int { + return 32 +} + +func (c *Bn254) NewG1() driver.G1 { + return &bn254G1{&bn254.G1Affine{}} +} + +func (c *Bn254) NewG2() driver.G2 { + return &bn254G2{&bn254.G2Affine{}} +} + +func (c *Bn254) NewG1FromCoords(ix, iy driver.Zr) driver.G1 { + return nil +} + +func (c *Bn254) NewZrFromBytes(b []byte) driver.Zr { + return &bn254Zr{new(big.Int).SetBytes(b)} +} + +func (c *Bn254) NewZrFromInt(i int64) driver.Zr { + return &bn254Zr{big.NewInt(i)} +} + +func (c *Bn254) NewG1FromBytes(b []byte) driver.G1 { + v := &bn254.G1Affine{} + _, err := v.SetBytes(b) + if err != nil { + panic(fmt.Sprintf("set bytes failed [%s]", err.Error())) + } + + return &bn254G1{v} +} + +func (c *Bn254) NewG2FromBytes(b []byte) driver.G2 { + v := &bn254.G2Affine{} + _, err := v.SetBytes(b) + if err != nil { + panic(fmt.Sprintf("set bytes failed [%s]", err.Error())) + } + + return &bn254G2{v} +} + +func (c *Bn254) NewGtFromBytes(b []byte) driver.Gt { + v := &bn254.GT{} + err := v.SetBytes(b) + if err != nil { + panic(fmt.Sprintf("set bytes failed [%s]", err.Error())) + } + + return &bn254Gt{v} +} + +func (c *Bn254) HashToZr(data []byte) driver.Zr { + digest := sha256.Sum256(data) + digestBig := c.NewZrFromBytes(digest[:]) + digestBig.Mod(c.GroupOrder()) + return digestBig +} + +func (c *Bn254) HashToG1(data []byte) driver.G1 { + g1, err := bn254.HashToCurveG1Svdw(data, []byte{}) + if err != nil { + panic(fmt.Sprintf("HashToG1 failed [%s]", err.Error())) + } + + return &bn254G1{&g1} +} + +func (c *Bn254) NewRandomZr(rng io.Reader) driver.Zr { + res := new(big.Int) + v := &fr.Element{} + _, err := v.SetRandom() + if err != nil { + panic(err) + } + + return &bn254Zr{v.ToBigIntRegular(res)} +} + +func (c *Bn254) Rand() (io.Reader, error) { + return rand.Reader, nil +} diff --git a/vendor/github.com/IBM/mathlib/driver/math.go b/vendor/github.com/IBM/mathlib/driver/math.go new file mode 100644 index 00000000000..b223fe47d59 --- /dev/null +++ b/vendor/github.com/IBM/mathlib/driver/math.go @@ -0,0 +1,84 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package driver + +import ( + "io" +) + +type Curve interface { + Pairing(G2, G1) Gt + Pairing2(p2a, p2b G2, p1a, p1b G1) Gt + FExp(Gt) Gt + ModMul(a1, b1, m Zr) Zr + ModNeg(a1, m Zr) Zr + GenG1() G1 + GenG2() G2 + GenGt() Gt + GroupOrder() Zr + FieldBytes() int + NewG1() G1 + NewG2() G2 + NewG1FromCoords(ix, iy Zr) G1 + NewZrFromBytes(b []byte) Zr + NewZrFromInt(i int64) Zr + NewG1FromBytes(b []byte) G1 + NewG2FromBytes(b []byte) G2 + NewGtFromBytes(b []byte) Gt + ModAdd(a, b, m Zr) Zr + ModSub(a, b, m Zr) Zr + HashToZr(data []byte) Zr + HashToG1(data []byte) G1 + NewRandomZr(rng io.Reader) Zr + Rand() (io.Reader, error) +} + +type Zr interface { + Plus(Zr) Zr + Mod(Zr) + PowMod(Zr) Zr + InvModP(Zr) + Bytes() []byte + Equals(Zr) bool + Copy() Zr + Clone(a Zr) + String() string +} + +type G1 interface { + Clone(G1) + Copy() G1 + Add(G1) + Mul(Zr) G1 + Mul2(e Zr, Q G1, f Zr) G1 + Equals(G1) bool + Bytes() []byte + Sub(G1) + IsInfinity() bool + String() string +} + +type G2 interface { + Clone(G2) + Copy() G2 + Mul(Zr) G2 + Add(G2) + Sub(G2) + Affine() + Bytes() []byte + String() string + Equals(G2) bool +} + +type Gt interface { + Equals(Gt) bool + Inverse() + Mul(Gt) + IsUnity() bool + ToString() string + Bytes() []byte +} diff --git a/vendor/github.com/IBM/mathlib/go.mod b/vendor/github.com/IBM/mathlib/go.mod new file mode 100644 index 00000000000..5361b7d030c --- /dev/null +++ b/vendor/github.com/IBM/mathlib/go.mod @@ -0,0 +1,10 @@ +module github.com/IBM/mathlib + +go 1.16 + +require ( + github.com/consensys/gnark-crypto v0.4.0 + github.com/hyperledger/fabric-amcl v0.0.0-20210603140002-2670f91851c8 + github.com/pkg/errors v0.8.1 + github.com/stretchr/testify v1.4.0 +) diff --git a/vendor/github.com/IBM/mathlib/go.sum b/vendor/github.com/IBM/mathlib/go.sum new file mode 100644 index 00000000000..c444a6712f3 --- /dev/null +++ b/vendor/github.com/IBM/mathlib/go.sum @@ -0,0 +1,28 @@ +github.com/consensys/bavard v0.1.8-0.20210329205436-c3e862ba4e5f/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ= +github.com/consensys/gnark-crypto v0.4.0 h1:KHf7Ta876Ys6L8+i0DLRRKOAa3PfJ8oobAX1CEeIa4A= +github.com/consensys/gnark-crypto v0.4.0/go.mod h1:wK/gpXP9B06qTzTVML71GhKD1ygP9xOzukbI68NJqsQ= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/hyperledger/fabric-amcl v0.0.0-20210603140002-2670f91851c8 h1:BCR8ZlOZ+deUbWxyY6fpoY8LbB7PR5wGGwCTvWQOU2g= +github.com/hyperledger/fabric-amcl v0.0.0-20210603140002-2670f91851c8/go.mod h1:X+DIyUsaTmalOpmpQfIvFZjKHQedrURQ5t4YqquX7lE= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210326220804-49726bf1d181 h1:64ChN/hjER/taL4YJuA+gpLfIMT+/NFherRZixbxOhg= +golang.org/x/sys v0.0.0-20210326220804-49726bf1d181/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/IBM/mathlib/marshaler.go b/vendor/github.com/IBM/mathlib/marshaler.go new file mode 100644 index 00000000000..9dadae79879 --- /dev/null +++ b/vendor/github.com/IBM/mathlib/marshaler.go @@ -0,0 +1,106 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package math + +import "encoding/json" + +type curveElement struct { + CurveID CurveID `json:"curve" validate:"required"` + ElementBytes []byte `json:"element" validate:"required"` +} + +func (z *Zr) UnmarshalJSON(raw []byte) error { + ce := &curveElement{} + err := json.Unmarshal(raw, ce) + if err != nil { + return err + } + + z.curveID = ce.CurveID + z.zr = Curves[z.curveID].NewZrFromBytes(ce.ElementBytes).zr + + return nil +} + +func (z *Zr) MarshalJSON() ([]byte, error) { + return json.Marshal(&curveElement{ + CurveID: z.curveID, + ElementBytes: z.Bytes(), + }) +} + +func (g *G1) UnmarshalJSON(raw []byte) error { + ce := &curveElement{} + err := json.Unmarshal(raw, ce) + if err != nil { + return err + } + + g.curveID = ce.CurveID + g1, err := Curves[g.curveID].NewG1FromBytes(ce.ElementBytes) + if err != nil { + return err + } + + g.g1 = g1.g1 + return nil +} + +func (g *G1) MarshalJSON() ([]byte, error) { + return json.Marshal(&curveElement{ + CurveID: g.curveID, + ElementBytes: g.Bytes(), + }) +} + +func (g *G2) UnmarshalJSON(raw []byte) error { + ce := &curveElement{} + err := json.Unmarshal(raw, ce) + if err != nil { + return err + } + + g.curveID = ce.CurveID + g2, err := Curves[g.curveID].NewG2FromBytes(ce.ElementBytes) + if err != nil { + return err + } + + g.g2 = g2.g2 + return nil +} + +func (g *G2) MarshalJSON() ([]byte, error) { + return json.Marshal(&curveElement{ + CurveID: g.curveID, + ElementBytes: g.Bytes(), + }) +} + +func (g *Gt) UnmarshalJSON(raw []byte) error { + ce := &curveElement{} + err := json.Unmarshal(raw, ce) + if err != nil { + return err + } + + g.curveID = ce.CurveID + gt, err := Curves[g.curveID].NewGtFromBytes(ce.ElementBytes) + if err != nil { + return err + } + + g.gt = gt.gt + return nil +} + +func (g *Gt) MarshalJSON() ([]byte, error) { + return json.Marshal(&curveElement{ + CurveID: g.curveID, + ElementBytes: g.Bytes(), + }) +} diff --git a/vendor/github.com/IBM/mathlib/math.go b/vendor/github.com/IBM/mathlib/math.go new file mode 100644 index 00000000000..61e24b9499f --- /dev/null +++ b/vendor/github.com/IBM/mathlib/math.go @@ -0,0 +1,347 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package math + +import ( + "bytes" + "encoding/binary" + "fmt" + "io" + + "github.com/IBM/mathlib/driver" + "github.com/IBM/mathlib/driver/amcl" + "github.com/IBM/mathlib/driver/gurvy" + "github.com/pkg/errors" +) + +type CurveID int + +const ( + FP256BN_AMCL CurveID = iota + BN254 + FP256BN_AMCL_MIRACL +) + +var Curves []*Curve = []*Curve{ + { + c: &amcl.Fp256bn{}, + GenG1: &G1{g1: (&amcl.Fp256bn{}).GenG1(), curveID: FP256BN_AMCL}, + GenG2: &G2{g2: (&amcl.Fp256bn{}).GenG2(), curveID: FP256BN_AMCL}, + GenGt: &Gt{gt: (&amcl.Fp256bn{}).GenGt(), curveID: FP256BN_AMCL}, + GroupOrder: &Zr{zr: (&amcl.Fp256bn{}).GroupOrder(), curveID: FP256BN_AMCL}, + FieldBytes: (&amcl.Fp256bn{}).FieldBytes(), + curveID: FP256BN_AMCL, + }, + { + c: &gurvy.Bn254{}, + GenG1: &G1{g1: (&gurvy.Bn254{}).GenG1(), curveID: BN254}, + GenG2: &G2{g2: (&gurvy.Bn254{}).GenG2(), curveID: BN254}, + GenGt: &Gt{gt: (&gurvy.Bn254{}).GenGt(), curveID: BN254}, + GroupOrder: &Zr{zr: (&gurvy.Bn254{}).GroupOrder(), curveID: BN254}, + FieldBytes: (&gurvy.Bn254{}).FieldBytes(), + curveID: BN254, + }, + { + c: &amcl.Fp256Miraclbn{}, + GenG1: &G1{g1: (&amcl.Fp256Miraclbn{}).GenG1(), curveID: FP256BN_AMCL_MIRACL}, + GenG2: &G2{g2: (&amcl.Fp256Miraclbn{}).GenG2(), curveID: FP256BN_AMCL_MIRACL}, + GenGt: &Gt{gt: (&amcl.Fp256Miraclbn{}).GenGt(), curveID: FP256BN_AMCL_MIRACL}, + GroupOrder: &Zr{zr: (&amcl.Fp256Miraclbn{}).GroupOrder(), curveID: FP256BN_AMCL_MIRACL}, + FieldBytes: (&amcl.Fp256Miraclbn{}).FieldBytes(), + curveID: FP256BN_AMCL_MIRACL, + }, +} + +/*********************************************************************/ + +type Zr struct { + zr driver.Zr + curveID CurveID +} + +func (z *Zr) Plus(a *Zr) *Zr { + return &Zr{zr: z.zr.Plus(a.zr), curveID: z.curveID} +} + +func (z *Zr) Mod(a *Zr) { + z.zr.Mod(a.zr) +} + +func (z *Zr) PowMod(a *Zr) *Zr { + return &Zr{zr: z.zr.PowMod(a.zr), curveID: z.curveID} +} + +func (z *Zr) InvModP(a *Zr) { + z.zr.InvModP(a.zr) +} + +func (z *Zr) Bytes() []byte { + return z.zr.Bytes() +} + +func (z *Zr) Equals(a *Zr) bool { + return z.zr.Equals(a.zr) +} + +func (z *Zr) Copy() *Zr { + return &Zr{zr: z.zr.Copy(), curveID: z.curveID} +} + +func (z *Zr) Clone(a *Zr) { + z.zr.Clone(a.zr) +} + +func (z *Zr) String() string { + return z.zr.String() +} + +var zerobytes = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +var onebytes = []byte{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} + +func (z *Zr) Int() (int64, error) { + b := z.Bytes() + if !bytes.Equal(zerobytes, b[:32-8]) && !bytes.Equal(onebytes, b[:32-8]) { + return 0, fmt.Errorf("out of range") + } + + return int64(binary.BigEndian.Uint64(b[32-8:])), nil +} + +/*********************************************************************/ + +type G1 struct { + g1 driver.G1 + curveID CurveID +} + +func (g *G1) Clone(a *G1) { + g.g1.Clone(a.g1) +} + +func (g *G1) Copy() *G1 { + return &G1{g1: g.g1.Copy(), curveID: g.curveID} +} + +func (g *G1) Add(a *G1) { + g.g1.Add(a.g1) +} + +func (g *G1) Mul(a *Zr) *G1 { + return &G1{g1: g.g1.Mul(a.zr), curveID: g.curveID} +} + +func (g *G1) Mul2(e *Zr, Q *G1, f *Zr) *G1 { + return &G1{g1: g.g1.Mul2(e.zr, Q.g1, f.zr), curveID: g.curveID} +} + +func (g *G1) Equals(a *G1) bool { + return g.g1.Equals(a.g1) +} + +func (g *G1) Bytes() []byte { + return g.g1.Bytes() +} + +func (g *G1) Sub(a *G1) { + g.g1.Sub(a.g1) +} + +func (g *G1) IsInfinity() bool { + return g.g1.IsInfinity() +} + +func (g *G1) String() string { + return g.g1.String() +} + +/*********************************************************************/ + +type G2 struct { + g2 driver.G2 + curveID CurveID +} + +func (g *G2) Clone(a *G2) { + g.g2.Clone(a.g2) +} + +func (g *G2) Copy() *G2 { + return &G2{g2: g.g2.Copy(), curveID: g.curveID} +} + +func (g *G2) Mul(a *Zr) *G2 { + return &G2{g2: g.g2.Mul(a.zr), curveID: g.curveID} +} + +func (g *G2) Add(a *G2) { + g.g2.Add(a.g2) +} + +func (g *G2) Sub(a *G2) { + g.g2.Sub(a.g2) +} + +func (g *G2) Affine() { + g.g2.Affine() +} + +func (g *G2) Bytes() []byte { + return g.g2.Bytes() +} + +func (g *G2) String() string { + return g.g2.String() +} + +func (g *G2) Equals(a *G2) bool { + return g.g2.Equals(a.g2) +} + +/*********************************************************************/ + +type Gt struct { + gt driver.Gt + curveID CurveID +} + +func (g *Gt) Equals(a *Gt) bool { + return g.gt.Equals(a.gt) +} + +func (g *Gt) Inverse() { + g.gt.Inverse() +} + +func (g *Gt) Mul(a *Gt) { + g.gt.Mul(a.gt) +} + +func (g *Gt) IsUnity() bool { + return g.gt.IsUnity() +} + +func (g *Gt) String() string { + return g.gt.ToString() +} + +func (g *Gt) Bytes() []byte { + return g.gt.Bytes() +} + +/*********************************************************************/ + +type Curve struct { + c driver.Curve + GenG1 *G1 + GenG2 *G2 + GenGt *Gt + GroupOrder *Zr + FieldBytes int + curveID CurveID +} + +func (c *Curve) Rand() (io.Reader, error) { + return c.c.Rand() +} + +func (c *Curve) NewRandomZr(rng io.Reader) *Zr { + return &Zr{zr: c.c.NewRandomZr(rng), curveID: c.curveID} +} + +func (c *Curve) NewZrFromBytes(b []byte) *Zr { + return &Zr{zr: c.c.NewZrFromBytes(b), curveID: c.curveID} +} + +func (c *Curve) NewG1FromBytes(b []byte) (p *G1, err error) { + defer func() { + if r := recover(); r != nil { + err = errors.Errorf("failure [%s]", r) + p = nil + } + }() + + p = &G1{g1: c.c.NewG1FromBytes(b), curveID: c.curveID} + return +} + +func (c *Curve) NewG2FromBytes(b []byte) (p *G2, err error) { + defer func() { + if r := recover(); r != nil { + err = errors.Errorf("failure [%s]", r) + p = nil + } + }() + + p = &G2{g2: c.c.NewG2FromBytes(b), curveID: c.curveID} + return +} + +func (c *Curve) NewGtFromBytes(b []byte) (p *Gt, err error) { + defer func() { + if r := recover(); r != nil { + err = errors.Errorf("failure [%s]", r) + p = nil + } + }() + + p = &Gt{gt: c.c.NewGtFromBytes(b), curveID: c.curveID} + return +} + +func (c *Curve) NewZrFromInt(i int64) *Zr { + return &Zr{zr: c.c.NewZrFromInt(i), curveID: c.curveID} +} + +// func (c *Curve) NewG1FromCoords(ix, iy *Zr) *G1 { +// return &G1{c.c.NewG1FromCoords(ix.zr, iy.zr)} +// } + +func (c *Curve) NewG2() *G2 { + return &G2{g2: c.c.NewG2(), curveID: c.curveID} +} + +func (c *Curve) NewG1() *G1 { + return &G1{g1: c.c.NewG1(), curveID: c.curveID} +} + +func (c *Curve) Pairing(a *G2, b *G1) *Gt { + return &Gt{gt: c.c.Pairing(a.g2, b.g1), curveID: c.curveID} +} + +func (c *Curve) Pairing2(p *G2, q *G1, r *G2, s *G1) *Gt { + return &Gt{gt: c.c.Pairing2(p.g2, r.g2, q.g1, s.g1), curveID: c.curveID} +} + +func (c *Curve) FExp(a *Gt) *Gt { + return &Gt{gt: c.c.FExp(a.gt), curveID: c.curveID} +} + +func (c *Curve) HashToZr(data []byte) *Zr { + return &Zr{zr: c.c.HashToZr(data), curveID: c.curveID} +} + +func (c *Curve) HashToG1(data []byte) *G1 { + return &G1{g1: c.c.HashToG1(data), curveID: c.curveID} +} + +func (c *Curve) ModSub(a, b, m *Zr) *Zr { + return &Zr{zr: c.c.ModSub(a.zr, b.zr, m.zr), curveID: c.curveID} +} + +func (c *Curve) ModAdd(a, b, m *Zr) *Zr { + return &Zr{zr: c.c.ModAdd(a.zr, b.zr, m.zr), curveID: c.curveID} +} + +func (c *Curve) ModMul(a1, b1, m *Zr) *Zr { + return &Zr{zr: c.c.ModMul(a1.zr, b1.zr, m.zr), curveID: c.curveID} +} + +func (c *Curve) ModNeg(a1, m *Zr) *Zr { + return &Zr{zr: c.c.ModNeg(a1.zr, m.zr), curveID: c.curveID} +} + +/*********************************************************************/ diff --git a/vendor/github.com/alecthomas/units/bytes.go b/vendor/github.com/alecthomas/units/bytes.go index eaadeb8005a..f740537f03f 100644 --- a/vendor/github.com/alecthomas/units/bytes.go +++ b/vendor/github.com/alecthomas/units/bytes.go @@ -27,6 +27,7 @@ var ( // ParseBase2Bytes supports both iB and B in base-2 multipliers. That is, KB // and KiB are both 1024. +// However "kB", which is the correct SI spelling of 1000 Bytes, is rejected. func ParseBase2Bytes(s string) (Base2Bytes, error) { n, err := ParseUnit(s, bytesUnitMap) if err != nil { @@ -39,6 +40,18 @@ func (b Base2Bytes) String() string { return ToString(int64(b), 1024, "iB", "B") } +// MarshalText implement encoding.TextMarshaler to process json/yaml. +func (b Base2Bytes) MarshalText() ([]byte, error) { + return []byte(b.String()), nil +} + +// UnmarshalText implement encoding.TextUnmarshaler to process json/yaml. +func (b *Base2Bytes) UnmarshalText(text []byte) error { + n, err := ParseBase2Bytes(string(text)) + *b = n + return err +} + var ( metricBytesUnitMap = MakeUnitMap("B", "B", 1000) ) @@ -68,12 +81,13 @@ func ParseMetricBytes(s string) (MetricBytes, error) { return MetricBytes(n), err } +// TODO: represents 1000B as uppercase "KB", while SI standard requires "kB". func (m MetricBytes) String() string { return ToString(int64(m), 1000, "B", "B") } // ParseStrictBytes supports both iB and B suffixes for base 2 and metric, -// respectively. That is, KiB represents 1024 and KB represents 1000. +// respectively. That is, KiB represents 1024 and kB, KB represent 1000. func ParseStrictBytes(s string) (int64, error) { n, err := ParseUnit(s, bytesUnitMap) if err != nil { diff --git a/vendor/github.com/alecthomas/units/go.mod b/vendor/github.com/alecthomas/units/go.mod index f5721732748..f77ddea73a9 100644 --- a/vendor/github.com/alecthomas/units/go.mod +++ b/vendor/github.com/alecthomas/units/go.mod @@ -1 +1,5 @@ module github.com/alecthomas/units + +go 1.15 + +require github.com/stretchr/testify v1.4.0 diff --git a/vendor/github.com/alecthomas/units/go.sum b/vendor/github.com/alecthomas/units/go.sum new file mode 100644 index 00000000000..8fdee5854f1 --- /dev/null +++ b/vendor/github.com/alecthomas/units/go.sum @@ -0,0 +1,11 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/alecthomas/units/si.go b/vendor/github.com/alecthomas/units/si.go index 8234a9d52cb..99b2fa4fcb0 100644 --- a/vendor/github.com/alecthomas/units/si.go +++ b/vendor/github.com/alecthomas/units/si.go @@ -14,13 +14,37 @@ const ( ) func MakeUnitMap(suffix, shortSuffix string, scale int64) map[string]float64 { - return map[string]float64{ - shortSuffix: 1, - "K" + suffix: float64(scale), + res := map[string]float64{ + shortSuffix: 1, + // see below for "k" / "K" "M" + suffix: float64(scale * scale), "G" + suffix: float64(scale * scale * scale), "T" + suffix: float64(scale * scale * scale * scale), "P" + suffix: float64(scale * scale * scale * scale * scale), "E" + suffix: float64(scale * scale * scale * scale * scale * scale), } + + // Standard SI prefixes use lowercase "k" for kilo = 1000. + // For compatibility, and to be fool-proof, we accept both "k" and "K" in metric mode. + // + // However, official binary prefixes are always capitalized - "KiB" - + // and we specifically never parse "kB" as 1024B because: + // + // (1) people pedantic enough to use lowercase according to SI unlikely to abuse "k" to mean 1024 :-) + // + // (2) Use of capital K for 1024 was an informal tradition predating IEC prefixes: + // "The binary meaning of the kilobyte for 1024 bytes typically uses the symbol KB, with an + // uppercase letter K." + // -- https://en.wikipedia.org/wiki/Kilobyte#Base_2_(1024_bytes) + // "Capitalization of the letter K became the de facto standard for binary notation, although this + // could not be extended to higher powers, and use of the lowercase k did persist.[13][14][15]" + // -- https://en.wikipedia.org/wiki/Binary_prefix#History + // See also the extensive https://en.wikipedia.org/wiki/Timeline_of_binary_prefixes. + if scale == 1024 { + res["K"+suffix] = float64(scale) + } else { + res["k"+suffix] = float64(scale) + res["K"+suffix] = float64(scale) + } + return res } diff --git a/vendor/github.com/consensys/gnark-crypto/LICENSE b/vendor/github.com/consensys/gnark-crypto/LICENSE new file mode 100644 index 00000000000..261eeb9e9f8 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/bn254.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/bn254.go new file mode 100644 index 00000000000..e27e9177a4b --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/bn254.go @@ -0,0 +1,126 @@ +package bn254 + +import ( + "math/big" + + "github.com/consensys/gnark-crypto/ecc" + "github.com/consensys/gnark-crypto/ecc/bn254/fp" + "github.com/consensys/gnark-crypto/ecc/bn254/fr" + "github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower" +) + +// E: y**2=x**3+3 +// Etwist: y**2 = x**3+3*(u+9)**-1 +// Tower: Fp->Fp2, u**2=-1 -> Fp12, v**6=9+u +// Generator (BN family): x=4965661367192848881 +// optimal Ate loop: 6x+2 +// trace of pi: x+1 +// Fp: p=21888242871839275222246405745257275088696311157297823662689037894645226208583 +// Fr: r=21888242871839275222246405745257275088548364400416034343698204186575808495617 + +// ID bn254 ID +const ID = ecc.BN254 + +// bCurveCoeff b coeff of the curve +var bCurveCoeff fp.Element + +// twist +var twist fptower.E2 + +// bTwistCurveCoeff b coeff of the twist (defined over Fp2) curve +var bTwistCurveCoeff fptower.E2 + +// twoInv 1/2 mod p (needed for DoubleStep in Miller loop) +var twoInv fp.Element + +// generators of the r-torsion group, resp. in ker(pi-id), ker(Tr) +var g1Gen G1Jac +var g2Gen G2Jac + +var g1GenAff G1Affine +var g2GenAff G2Affine + +// point at infinity +var g1Infinity G1Jac +var g2Infinity G2Jac + +// optimal Ate loop counter +var loopCounter [66]int8 + +// Parameters useful for the GLV scalar multiplication. The third roots define the +// endomorphisms phi1 and phi2 for and . lambda is such that lies above +// in the ring Z[phi]. More concretely it's the associated eigenvalue +// of phi1 (resp phi2) restricted to (resp ) +// cf https://www.cosic.esat.kuleuven.be/nessie/reports/phase2/GLV.pdf +var thirdRootOneG1 fp.Element +var thirdRootOneG2 fp.Element +var lambdaGLV big.Int + +// glvBasis stores R-linearly independant vectors (a,b), (c,d) +// in ker((u,v)->u+vlambda[r]), and their determinant +var glvBasis ecc.Lattice + +// psi o pi o psi**-1, where psi:E->E' is the degree 6 iso defined over Fp12 +var endo struct { + u fptower.E2 + v fptower.E2 +} + +// generator of the curve +var xGen big.Int + +func init() { + + bCurveCoeff.SetUint64(3) + twist.A0.SetUint64(9) + twist.A1.SetUint64(1) + bTwistCurveCoeff.Inverse(&twist).MulByElement(&bTwistCurveCoeff, &bCurveCoeff) + + twoInv.SetOne().Double(&twoInv).Inverse(&twoInv) + + g1Gen.X.SetString("1") + g1Gen.Y.SetString("2") + g1Gen.Z.SetString("1") + + g2Gen.X.SetString("10857046999023057135944570762232829481370756359578518086990519993285655852781", + "11559732032986387107991004021392285783925812861821192530917403151452391805634") + g2Gen.Y.SetString("8495653923123431417604973247489272438418190587263600148770280649306958101930", + "4082367875863433681332203403145435568316851327593401208105741076214120093531") + g2Gen.Z.SetString("1", + "0") + + g1GenAff.FromJacobian(&g1Gen) + g2GenAff.FromJacobian(&g2Gen) + + g1Infinity.X.SetOne() + g1Infinity.Y.SetOne() + g2Infinity.X.SetOne() + g2Infinity.Y.SetOne() + + thirdRootOneG1.SetString("2203960485148121921418603742825762020974279258880205651966") + thirdRootOneG2.Square(&thirdRootOneG1) + lambdaGLV.SetString("4407920970296243842393367215006156084916469457145843978461", 10) // (36*x**3+18*x**2+6*x+1) + _r := fr.Modulus() + ecc.PrecomputeLattice(_r, &lambdaGLV, &glvBasis) + + endo.u.A0.SetString("21575463638280843010398324269430826099269044274347216827212613867836435027261") + endo.u.A1.SetString("10307601595873709700152284273816112264069230130616436755625194854815875713954") + endo.v.A0.SetString("2821565182194536844548159561693502659359617185244120367078079554186484126554") + endo.v.A1.SetString("3505843767911556378687030309984248845540243509899259641013678093033130930403") + + // binary decomposition of 15132376222941642752 little endian + optimaAteLoop, _ := new(big.Int).SetString("29793968203157093288", 10) + ecc.NafDecomposition(optimaAteLoop, loopCounter[:]) + + xGen.SetString("4965661367192848881", 10) + +} + +// Generators return the generators of the r-torsion group, resp. in ker(pi-id), ker(Tr) +func Generators() (g1Jac G1Jac, g2Jac G2Jac, g1Aff G1Affine, g2Aff G2Affine) { + g1Aff = g1GenAff + g2Aff = g2GenAff + g1Jac = g1Gen + g2Jac = g2Gen + return +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/arith.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/arith.go new file mode 100644 index 00000000000..66fa667482a --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/arith.go @@ -0,0 +1,60 @@ +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package fp + +import ( + "math/bits" +) + +// madd0 hi = a*b + c (discards lo bits) +func madd0(a, b, c uint64) (hi uint64) { + var carry, lo uint64 + hi, lo = bits.Mul64(a, b) + _, carry = bits.Add64(lo, c, 0) + hi, _ = bits.Add64(hi, 0, carry) + return +} + +// madd1 hi, lo = a*b + c +func madd1(a, b, c uint64) (hi uint64, lo uint64) { + var carry uint64 + hi, lo = bits.Mul64(a, b) + lo, carry = bits.Add64(lo, c, 0) + hi, _ = bits.Add64(hi, 0, carry) + return +} + +// madd2 hi, lo = a*b + c + d +func madd2(a, b, c, d uint64) (hi uint64, lo uint64) { + var carry uint64 + hi, lo = bits.Mul64(a, b) + c, carry = bits.Add64(c, d, 0) + hi, _ = bits.Add64(hi, 0, carry) + lo, carry = bits.Add64(lo, c, 0) + hi, _ = bits.Add64(hi, 0, carry) + return +} + +func madd3(a, b, c, d, e uint64) (hi uint64, lo uint64) { + var carry uint64 + hi, lo = bits.Mul64(a, b) + c, carry = bits.Add64(c, d, 0) + hi, _ = bits.Add64(hi, 0, carry) + lo, carry = bits.Add64(lo, c, 0) + hi, _ = bits.Add64(hi, e, carry) + return +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/asm.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/asm.go new file mode 100644 index 00000000000..715bc7ac121 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/asm.go @@ -0,0 +1,23 @@ +// +build !noadx + +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package fp + +import "golang.org/x/sys/cpu" + +var supportAdx = cpu.X86.HasADX && cpu.X86.HasBMI2 diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/asm_noadx.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/asm_noadx.go new file mode 100644 index 00000000000..371bfeaeb3a --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/asm_noadx.go @@ -0,0 +1,24 @@ +// +build noadx + +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package fp + +// note: this is needed for test purposes, as dynamically changing supportAdx doesn't flag +// certain errors (like fatal error: missing stackmap) +// this ensures we test all asm path. +var supportAdx = false diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element.go new file mode 100644 index 00000000000..8123dbe14c6 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element.go @@ -0,0 +1,895 @@ +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +// Package fp contains field arithmetic operations for modulus 21888242871839275222246405745257275088696311157297823662689037894645226208583 +package fp + +// /!\ WARNING /!\ +// this code has not been audited and is provided as-is. In particular, +// there is no security guarantees such as constant time implementation +// or side-channel attack resistance +// /!\ WARNING /!\ + +import ( + "crypto/rand" + "encoding/binary" + "io" + "math/big" + "math/bits" + "strconv" + "sync" +) + +// Element represents a field element stored on 4 words (uint64) +// Element are assumed to be in Montgomery form in all methods +// field modulus q = +// +// 21888242871839275222246405745257275088696311157297823662689037894645226208583 +type Element [4]uint64 + +// Limbs number of 64 bits words needed to represent Element +const Limbs = 4 + +// Bits number bits needed to represent Element +const Bits = 254 + +// Bytes number bytes needed to represent Element +const Bytes = Limbs * 8 + +// field modulus stored as big.Int +var _modulus big.Int + +// Modulus returns q as a big.Int +// q = +// +// 21888242871839275222246405745257275088696311157297823662689037894645226208583 +func Modulus() *big.Int { + return new(big.Int).Set(&_modulus) +} + +// q (modulus) +var qElement = Element{ + 4332616871279656263, + 10917124144477883021, + 13281191951274694749, + 3486998266802970665, +} + +// rSquare +var rSquare = Element{ + 17522657719365597833, + 13107472804851548667, + 5164255478447964150, + 493319470278259999, +} + +var bigIntPool = sync.Pool{ + New: func() interface{} { + return new(big.Int) + }, +} + +func init() { + _modulus.SetString("21888242871839275222246405745257275088696311157297823662689037894645226208583", 10) +} + +// SetUint64 z = v, sets z LSB to v (non-Montgomery form) and convert z to Montgomery form +func (z *Element) SetUint64(v uint64) *Element { + *z = Element{v} + return z.Mul(z, &rSquare) // z.ToMont() +} + +// Set z = x +func (z *Element) Set(x *Element) *Element { + z[0] = x[0] + z[1] = x[1] + z[2] = x[2] + z[3] = x[3] + return z +} + +// SetInterface converts i1 from uint64, int, string, or Element, big.Int into Element +// panic if provided type is not supported +func (z *Element) SetInterface(i1 interface{}) *Element { + switch c1 := i1.(type) { + case Element: + return z.Set(&c1) + case *Element: + return z.Set(c1) + case uint64: + return z.SetUint64(c1) + case int: + return z.SetString(strconv.Itoa(c1)) + case string: + return z.SetString(c1) + case *big.Int: + return z.SetBigInt(c1) + case big.Int: + return z.SetBigInt(&c1) + case []byte: + return z.SetBytes(c1) + default: + panic("invalid type") + } +} + +// SetZero z = 0 +func (z *Element) SetZero() *Element { + z[0] = 0 + z[1] = 0 + z[2] = 0 + z[3] = 0 + return z +} + +// SetOne z = 1 (in Montgomery form) +func (z *Element) SetOne() *Element { + z[0] = 15230403791020821917 + z[1] = 754611498739239741 + z[2] = 7381016538464732716 + z[3] = 1011752739694698287 + return z +} + +// Div z = x*y^-1 mod q +func (z *Element) Div(x, y *Element) *Element { + var yInv Element + yInv.Inverse(y) + z.Mul(x, &yInv) + return z +} + +// Equal returns z == x +func (z *Element) Equal(x *Element) bool { + return (z[3] == x[3]) && (z[2] == x[2]) && (z[1] == x[1]) && (z[0] == x[0]) +} + +// IsZero returns z == 0 +func (z *Element) IsZero() bool { + return (z[3] | z[2] | z[1] | z[0]) == 0 +} + +// Cmp compares (lexicographic order) z and x and returns: +// +// -1 if z < x +// 0 if z == x +// +1 if z > x +// +func (z *Element) Cmp(x *Element) int { + _z := *z + _x := *x + _z.FromMont() + _x.FromMont() + if _z[3] > _x[3] { + return 1 + } else if _z[3] < _x[3] { + return -1 + } + if _z[2] > _x[2] { + return 1 + } else if _z[2] < _x[2] { + return -1 + } + if _z[1] > _x[1] { + return 1 + } else if _z[1] < _x[1] { + return -1 + } + if _z[0] > _x[0] { + return 1 + } else if _z[0] < _x[0] { + return -1 + } + return 0 +} + +// LexicographicallyLargest returns true if this element is strictly lexicographically +// larger than its negation, false otherwise +func (z *Element) LexicographicallyLargest() bool { + // adapted from github.com/zkcrypto/bls12_381 + // we check if the element is larger than (q-1) / 2 + // if z - (((q -1) / 2) + 1) have no underflow, then z > (q-1) / 2 + + _z := *z + _z.FromMont() + + var b uint64 + _, b = bits.Sub64(_z[0], 11389680472494603940, 0) + _, b = bits.Sub64(_z[1], 14681934109093717318, b) + _, b = bits.Sub64(_z[2], 15863968012492123182, b) + _, b = bits.Sub64(_z[3], 1743499133401485332, b) + + return b == 0 +} + +// SetRandom sets z to a random element < q +func (z *Element) SetRandom() (*Element, error) { + var bytes [32]byte + if _, err := io.ReadFull(rand.Reader, bytes[:]); err != nil { + return nil, err + } + z[0] = binary.BigEndian.Uint64(bytes[0:8]) + z[1] = binary.BigEndian.Uint64(bytes[8:16]) + z[2] = binary.BigEndian.Uint64(bytes[16:24]) + z[3] = binary.BigEndian.Uint64(bytes[24:32]) + z[3] %= 3486998266802970665 + + // if z > q --> z -= q + // note: this is NOT constant time + if !(z[3] < 3486998266802970665 || (z[3] == 3486998266802970665 && (z[2] < 13281191951274694749 || (z[2] == 13281191951274694749 && (z[1] < 10917124144477883021 || (z[1] == 10917124144477883021 && (z[0] < 4332616871279656263))))))) { + var b uint64 + z[0], b = bits.Sub64(z[0], 4332616871279656263, 0) + z[1], b = bits.Sub64(z[1], 10917124144477883021, b) + z[2], b = bits.Sub64(z[2], 13281191951274694749, b) + z[3], _ = bits.Sub64(z[3], 3486998266802970665, b) + } + + return z, nil +} + +// One returns 1 (in montgommery form) +func One() Element { + var one Element + one.SetOne() + return one +} + +// MulAssign is deprecated +// Deprecated: use Mul instead +func (z *Element) MulAssign(x *Element) *Element { + return z.Mul(z, x) +} + +// AddAssign is deprecated +// Deprecated: use Add instead +func (z *Element) AddAssign(x *Element) *Element { + return z.Add(z, x) +} + +// SubAssign is deprecated +// Deprecated: use Sub instead +func (z *Element) SubAssign(x *Element) *Element { + return z.Sub(z, x) +} + +// API with assembly impl + +// Mul z = x * y mod q +// see https://hackmd.io/@zkteam/modular_multiplication +func (z *Element) Mul(x, y *Element) *Element { + mul(z, x, y) + return z +} + +// Square z = x * x mod q +// see https://hackmd.io/@zkteam/modular_multiplication +func (z *Element) Square(x *Element) *Element { + mul(z, x, x) + return z +} + +// FromMont converts z in place (i.e. mutates) from Montgomery to regular representation +// sets and returns z = z * 1 +func (z *Element) FromMont() *Element { + fromMont(z) + return z +} + +// Add z = x + y mod q +func (z *Element) Add(x, y *Element) *Element { + add(z, x, y) + return z +} + +// Double z = x + x mod q, aka Lsh 1 +func (z *Element) Double(x *Element) *Element { + double(z, x) + return z +} + +// Sub z = x - y mod q +func (z *Element) Sub(x, y *Element) *Element { + sub(z, x, y) + return z +} + +// Neg z = q - x +func (z *Element) Neg(x *Element) *Element { + neg(z, x) + return z +} + +// Generic (no ADX instructions, no AMD64) versions of multiplication and squaring algorithms + +func _mulGeneric(z, x, y *Element) { + + var t [4]uint64 + var c [3]uint64 + { + // round 0 + v := x[0] + c[1], c[0] = bits.Mul64(v, y[0]) + m := c[0] * 9786893198990664585 + c[2] = madd0(m, 4332616871279656263, c[0]) + c[1], c[0] = madd1(v, y[1], c[1]) + c[2], t[0] = madd2(m, 10917124144477883021, c[2], c[0]) + c[1], c[0] = madd1(v, y[2], c[1]) + c[2], t[1] = madd2(m, 13281191951274694749, c[2], c[0]) + c[1], c[0] = madd1(v, y[3], c[1]) + t[3], t[2] = madd3(m, 3486998266802970665, c[0], c[2], c[1]) + } + { + // round 1 + v := x[1] + c[1], c[0] = madd1(v, y[0], t[0]) + m := c[0] * 9786893198990664585 + c[2] = madd0(m, 4332616871279656263, c[0]) + c[1], c[0] = madd2(v, y[1], c[1], t[1]) + c[2], t[0] = madd2(m, 10917124144477883021, c[2], c[0]) + c[1], c[0] = madd2(v, y[2], c[1], t[2]) + c[2], t[1] = madd2(m, 13281191951274694749, c[2], c[0]) + c[1], c[0] = madd2(v, y[3], c[1], t[3]) + t[3], t[2] = madd3(m, 3486998266802970665, c[0], c[2], c[1]) + } + { + // round 2 + v := x[2] + c[1], c[0] = madd1(v, y[0], t[0]) + m := c[0] * 9786893198990664585 + c[2] = madd0(m, 4332616871279656263, c[0]) + c[1], c[0] = madd2(v, y[1], c[1], t[1]) + c[2], t[0] = madd2(m, 10917124144477883021, c[2], c[0]) + c[1], c[0] = madd2(v, y[2], c[1], t[2]) + c[2], t[1] = madd2(m, 13281191951274694749, c[2], c[0]) + c[1], c[0] = madd2(v, y[3], c[1], t[3]) + t[3], t[2] = madd3(m, 3486998266802970665, c[0], c[2], c[1]) + } + { + // round 3 + v := x[3] + c[1], c[0] = madd1(v, y[0], t[0]) + m := c[0] * 9786893198990664585 + c[2] = madd0(m, 4332616871279656263, c[0]) + c[1], c[0] = madd2(v, y[1], c[1], t[1]) + c[2], z[0] = madd2(m, 10917124144477883021, c[2], c[0]) + c[1], c[0] = madd2(v, y[2], c[1], t[2]) + c[2], z[1] = madd2(m, 13281191951274694749, c[2], c[0]) + c[1], c[0] = madd2(v, y[3], c[1], t[3]) + z[3], z[2] = madd3(m, 3486998266802970665, c[0], c[2], c[1]) + } + + // if z > q --> z -= q + // note: this is NOT constant time + if !(z[3] < 3486998266802970665 || (z[3] == 3486998266802970665 && (z[2] < 13281191951274694749 || (z[2] == 13281191951274694749 && (z[1] < 10917124144477883021 || (z[1] == 10917124144477883021 && (z[0] < 4332616871279656263))))))) { + var b uint64 + z[0], b = bits.Sub64(z[0], 4332616871279656263, 0) + z[1], b = bits.Sub64(z[1], 10917124144477883021, b) + z[2], b = bits.Sub64(z[2], 13281191951274694749, b) + z[3], _ = bits.Sub64(z[3], 3486998266802970665, b) + } +} + +func _fromMontGeneric(z *Element) { + // the following lines implement z = z * 1 + // with a modified CIOS montgomery multiplication + { + // m = z[0]n'[0] mod W + m := z[0] * 9786893198990664585 + C := madd0(m, 4332616871279656263, z[0]) + C, z[0] = madd2(m, 10917124144477883021, z[1], C) + C, z[1] = madd2(m, 13281191951274694749, z[2], C) + C, z[2] = madd2(m, 3486998266802970665, z[3], C) + z[3] = C + } + { + // m = z[0]n'[0] mod W + m := z[0] * 9786893198990664585 + C := madd0(m, 4332616871279656263, z[0]) + C, z[0] = madd2(m, 10917124144477883021, z[1], C) + C, z[1] = madd2(m, 13281191951274694749, z[2], C) + C, z[2] = madd2(m, 3486998266802970665, z[3], C) + z[3] = C + } + { + // m = z[0]n'[0] mod W + m := z[0] * 9786893198990664585 + C := madd0(m, 4332616871279656263, z[0]) + C, z[0] = madd2(m, 10917124144477883021, z[1], C) + C, z[1] = madd2(m, 13281191951274694749, z[2], C) + C, z[2] = madd2(m, 3486998266802970665, z[3], C) + z[3] = C + } + { + // m = z[0]n'[0] mod W + m := z[0] * 9786893198990664585 + C := madd0(m, 4332616871279656263, z[0]) + C, z[0] = madd2(m, 10917124144477883021, z[1], C) + C, z[1] = madd2(m, 13281191951274694749, z[2], C) + C, z[2] = madd2(m, 3486998266802970665, z[3], C) + z[3] = C + } + + // if z > q --> z -= q + // note: this is NOT constant time + if !(z[3] < 3486998266802970665 || (z[3] == 3486998266802970665 && (z[2] < 13281191951274694749 || (z[2] == 13281191951274694749 && (z[1] < 10917124144477883021 || (z[1] == 10917124144477883021 && (z[0] < 4332616871279656263))))))) { + var b uint64 + z[0], b = bits.Sub64(z[0], 4332616871279656263, 0) + z[1], b = bits.Sub64(z[1], 10917124144477883021, b) + z[2], b = bits.Sub64(z[2], 13281191951274694749, b) + z[3], _ = bits.Sub64(z[3], 3486998266802970665, b) + } +} + +func _addGeneric(z, x, y *Element) { + var carry uint64 + + z[0], carry = bits.Add64(x[0], y[0], 0) + z[1], carry = bits.Add64(x[1], y[1], carry) + z[2], carry = bits.Add64(x[2], y[2], carry) + z[3], _ = bits.Add64(x[3], y[3], carry) + + // if z > q --> z -= q + // note: this is NOT constant time + if !(z[3] < 3486998266802970665 || (z[3] == 3486998266802970665 && (z[2] < 13281191951274694749 || (z[2] == 13281191951274694749 && (z[1] < 10917124144477883021 || (z[1] == 10917124144477883021 && (z[0] < 4332616871279656263))))))) { + var b uint64 + z[0], b = bits.Sub64(z[0], 4332616871279656263, 0) + z[1], b = bits.Sub64(z[1], 10917124144477883021, b) + z[2], b = bits.Sub64(z[2], 13281191951274694749, b) + z[3], _ = bits.Sub64(z[3], 3486998266802970665, b) + } +} + +func _doubleGeneric(z, x *Element) { + var carry uint64 + + z[0], carry = bits.Add64(x[0], x[0], 0) + z[1], carry = bits.Add64(x[1], x[1], carry) + z[2], carry = bits.Add64(x[2], x[2], carry) + z[3], _ = bits.Add64(x[3], x[3], carry) + + // if z > q --> z -= q + // note: this is NOT constant time + if !(z[3] < 3486998266802970665 || (z[3] == 3486998266802970665 && (z[2] < 13281191951274694749 || (z[2] == 13281191951274694749 && (z[1] < 10917124144477883021 || (z[1] == 10917124144477883021 && (z[0] < 4332616871279656263))))))) { + var b uint64 + z[0], b = bits.Sub64(z[0], 4332616871279656263, 0) + z[1], b = bits.Sub64(z[1], 10917124144477883021, b) + z[2], b = bits.Sub64(z[2], 13281191951274694749, b) + z[3], _ = bits.Sub64(z[3], 3486998266802970665, b) + } +} + +func _subGeneric(z, x, y *Element) { + var b uint64 + z[0], b = bits.Sub64(x[0], y[0], 0) + z[1], b = bits.Sub64(x[1], y[1], b) + z[2], b = bits.Sub64(x[2], y[2], b) + z[3], b = bits.Sub64(x[3], y[3], b) + if b != 0 { + var c uint64 + z[0], c = bits.Add64(z[0], 4332616871279656263, 0) + z[1], c = bits.Add64(z[1], 10917124144477883021, c) + z[2], c = bits.Add64(z[2], 13281191951274694749, c) + z[3], _ = bits.Add64(z[3], 3486998266802970665, c) + } +} + +func _negGeneric(z, x *Element) { + if x.IsZero() { + z.SetZero() + return + } + var borrow uint64 + z[0], borrow = bits.Sub64(4332616871279656263, x[0], 0) + z[1], borrow = bits.Sub64(10917124144477883021, x[1], borrow) + z[2], borrow = bits.Sub64(13281191951274694749, x[2], borrow) + z[3], _ = bits.Sub64(3486998266802970665, x[3], borrow) +} + +func _reduceGeneric(z *Element) { + + // if z > q --> z -= q + // note: this is NOT constant time + if !(z[3] < 3486998266802970665 || (z[3] == 3486998266802970665 && (z[2] < 13281191951274694749 || (z[2] == 13281191951274694749 && (z[1] < 10917124144477883021 || (z[1] == 10917124144477883021 && (z[0] < 4332616871279656263))))))) { + var b uint64 + z[0], b = bits.Sub64(z[0], 4332616871279656263, 0) + z[1], b = bits.Sub64(z[1], 10917124144477883021, b) + z[2], b = bits.Sub64(z[2], 13281191951274694749, b) + z[3], _ = bits.Sub64(z[3], 3486998266802970665, b) + } +} + +func mulByConstant(z *Element, c uint8) { + switch c { + case 0: + z.SetZero() + return + case 1: + return + case 2: + z.Double(z) + return + case 3: + _z := *z + z.Double(z).Add(z, &_z) + case 5: + _z := *z + z.Double(z).Double(z).Add(z, &_z) + default: + panic("not implemented") + } +} + +// Exp z = x^exponent mod q +func (z *Element) Exp(x Element, exponent *big.Int) *Element { + var bZero big.Int + if exponent.Cmp(&bZero) == 0 { + return z.SetOne() + } + + z.Set(&x) + + for i := exponent.BitLen() - 2; i >= 0; i-- { + z.Square(z) + if exponent.Bit(i) == 1 { + z.Mul(z, &x) + } + } + + return z +} + +// ToMont converts z to Montgomery form +// sets and returns z = z * r^2 +func (z *Element) ToMont() *Element { + return z.Mul(z, &rSquare) +} + +// ToRegular returns z in regular form (doesn't mutate z) +func (z Element) ToRegular() Element { + return *z.FromMont() +} + +// String returns the string form of an Element in Montgomery form +func (z *Element) String() string { + vv := bigIntPool.Get().(*big.Int) + defer bigIntPool.Put(vv) + return z.ToBigIntRegular(vv).String() +} + +// ToBigInt returns z as a big.Int in Montgomery form +func (z *Element) ToBigInt(res *big.Int) *big.Int { + var b [Limbs * 8]byte + binary.BigEndian.PutUint64(b[24:32], z[0]) + binary.BigEndian.PutUint64(b[16:24], z[1]) + binary.BigEndian.PutUint64(b[8:16], z[2]) + binary.BigEndian.PutUint64(b[0:8], z[3]) + + return res.SetBytes(b[:]) +} + +// ToBigIntRegular returns z as a big.Int in regular form +func (z Element) ToBigIntRegular(res *big.Int) *big.Int { + z.FromMont() + return z.ToBigInt(res) +} + +// Bytes returns the regular (non montgomery) value +// of z as a big-endian byte array. +func (z *Element) Bytes() (res [Limbs * 8]byte) { + _z := z.ToRegular() + binary.BigEndian.PutUint64(res[24:32], _z[0]) + binary.BigEndian.PutUint64(res[16:24], _z[1]) + binary.BigEndian.PutUint64(res[8:16], _z[2]) + binary.BigEndian.PutUint64(res[0:8], _z[3]) + + return +} + +// SetBytes interprets e as the bytes of a big-endian unsigned integer, +// sets z to that value (in Montgomery form), and returns z. +func (z *Element) SetBytes(e []byte) *Element { + // get a big int from our pool + vv := bigIntPool.Get().(*big.Int) + vv.SetBytes(e) + + // set big int + z.SetBigInt(vv) + + // put temporary object back in pool + bigIntPool.Put(vv) + + return z +} + +// SetBigInt sets z to v (regular form) and returns z in Montgomery form +func (z *Element) SetBigInt(v *big.Int) *Element { + z.SetZero() + + var zero big.Int + + // fast path + c := v.Cmp(&_modulus) + if c == 0 { + // v == 0 + return z + } else if c != 1 && v.Cmp(&zero) != -1 { + // 0 < v < q + return z.setBigInt(v) + } + + // get temporary big int from the pool + vv := bigIntPool.Get().(*big.Int) + + // copy input + modular reduction + vv.Set(v) + vv.Mod(v, &_modulus) + + // set big int byte value + z.setBigInt(vv) + + // release object into pool + bigIntPool.Put(vv) + return z +} + +// setBigInt assumes 0 <= v < q +func (z *Element) setBigInt(v *big.Int) *Element { + vBits := v.Bits() + + if bits.UintSize == 64 { + for i := 0; i < len(vBits); i++ { + z[i] = uint64(vBits[i]) + } + } else { + for i := 0; i < len(vBits); i++ { + if i%2 == 0 { + z[i/2] = uint64(vBits[i]) + } else { + z[i/2] |= uint64(vBits[i]) << 32 + } + } + } + + return z.ToMont() +} + +// SetString creates a big.Int with s (in base 10) and calls SetBigInt on z +func (z *Element) SetString(s string) *Element { + // get temporary big int from the pool + vv := bigIntPool.Get().(*big.Int) + + if _, ok := vv.SetString(s, 10); !ok { + panic("Element.SetString failed -> can't parse number in base10 into a big.Int") + } + z.SetBigInt(vv) + + // release object into pool + bigIntPool.Put(vv) + + return z +} + +var ( + _bLegendreExponentElement *big.Int + _bSqrtExponentElement *big.Int +) + +func init() { + _bLegendreExponentElement, _ = new(big.Int).SetString("183227397098d014dc2822db40c0ac2ecbc0b548b438e5469e10460b6c3e7ea3", 16) + const sqrtExponentElement = "c19139cb84c680a6e14116da060561765e05aa45a1c72a34f082305b61f3f52" + _bSqrtExponentElement, _ = new(big.Int).SetString(sqrtExponentElement, 16) +} + +// Legendre returns the Legendre symbol of z (either +1, -1, or 0.) +func (z *Element) Legendre() int { + var l Element + // z^((q-1)/2) + l.Exp(*z, _bLegendreExponentElement) + + if l.IsZero() { + return 0 + } + + // if l == 1 + if (l[3] == 1011752739694698287) && (l[2] == 7381016538464732716) && (l[1] == 754611498739239741) && (l[0] == 15230403791020821917) { + return 1 + } + return -1 +} + +// Sqrt z = √x mod q +// if the square root doesn't exist (x is not a square mod q) +// Sqrt leaves z unchanged and returns nil +func (z *Element) Sqrt(x *Element) *Element { + // q ≡ 3 (mod 4) + // using z ≡ ± x^((p+1)/4) (mod q) + var y, square Element + y.Exp(*x, _bSqrtExponentElement) + // as we didn't compute the legendre symbol, ensure we found y such that y * y = x + square.Square(&y) + if square.Equal(x) { + return z.Set(&y) + } + return nil +} + +// Inverse z = x^-1 mod q +// Algorithm 16 in "Efficient Software-Implementation of Finite Fields with Applications to Cryptography" +// if x == 0, sets and returns z = x +func (z *Element) Inverse(x *Element) *Element { + if x.IsZero() { + return z.Set(x) + } + + // initialize u = q + var u = Element{ + 4332616871279656263, + 10917124144477883021, + 13281191951274694749, + 3486998266802970665, + } + + // initialize s = r^2 + var s = Element{ + 17522657719365597833, + 13107472804851548667, + 5164255478447964150, + 493319470278259999, + } + + // r = 0 + r := Element{} + + v := *x + + var carry, borrow, t, t2 uint64 + var bigger bool + + for { + for v[0]&1 == 0 { + + // v = v >> 1 + t2 = v[3] << 63 + v[3] >>= 1 + t = t2 + t2 = v[2] << 63 + v[2] = (v[2] >> 1) | t + t = t2 + t2 = v[1] << 63 + v[1] = (v[1] >> 1) | t + t = t2 + v[0] = (v[0] >> 1) | t + + if s[0]&1 == 1 { + + // s = s + q + s[0], carry = bits.Add64(s[0], 4332616871279656263, 0) + s[1], carry = bits.Add64(s[1], 10917124144477883021, carry) + s[2], carry = bits.Add64(s[2], 13281191951274694749, carry) + s[3], _ = bits.Add64(s[3], 3486998266802970665, carry) + + } + + // s = s >> 1 + t2 = s[3] << 63 + s[3] >>= 1 + t = t2 + t2 = s[2] << 63 + s[2] = (s[2] >> 1) | t + t = t2 + t2 = s[1] << 63 + s[1] = (s[1] >> 1) | t + t = t2 + s[0] = (s[0] >> 1) | t + + } + for u[0]&1 == 0 { + + // u = u >> 1 + t2 = u[3] << 63 + u[3] >>= 1 + t = t2 + t2 = u[2] << 63 + u[2] = (u[2] >> 1) | t + t = t2 + t2 = u[1] << 63 + u[1] = (u[1] >> 1) | t + t = t2 + u[0] = (u[0] >> 1) | t + + if r[0]&1 == 1 { + + // r = r + q + r[0], carry = bits.Add64(r[0], 4332616871279656263, 0) + r[1], carry = bits.Add64(r[1], 10917124144477883021, carry) + r[2], carry = bits.Add64(r[2], 13281191951274694749, carry) + r[3], _ = bits.Add64(r[3], 3486998266802970665, carry) + + } + + // r = r >> 1 + t2 = r[3] << 63 + r[3] >>= 1 + t = t2 + t2 = r[2] << 63 + r[2] = (r[2] >> 1) | t + t = t2 + t2 = r[1] << 63 + r[1] = (r[1] >> 1) | t + t = t2 + r[0] = (r[0] >> 1) | t + + } + + // v >= u + bigger = !(v[3] < u[3] || (v[3] == u[3] && (v[2] < u[2] || (v[2] == u[2] && (v[1] < u[1] || (v[1] == u[1] && (v[0] < u[0]))))))) + + if bigger { + + // v = v - u + v[0], borrow = bits.Sub64(v[0], u[0], 0) + v[1], borrow = bits.Sub64(v[1], u[1], borrow) + v[2], borrow = bits.Sub64(v[2], u[2], borrow) + v[3], _ = bits.Sub64(v[3], u[3], borrow) + + // s = s - r + s[0], borrow = bits.Sub64(s[0], r[0], 0) + s[1], borrow = bits.Sub64(s[1], r[1], borrow) + s[2], borrow = bits.Sub64(s[2], r[2], borrow) + s[3], borrow = bits.Sub64(s[3], r[3], borrow) + + if borrow == 1 { + + // s = s + q + s[0], carry = bits.Add64(s[0], 4332616871279656263, 0) + s[1], carry = bits.Add64(s[1], 10917124144477883021, carry) + s[2], carry = bits.Add64(s[2], 13281191951274694749, carry) + s[3], _ = bits.Add64(s[3], 3486998266802970665, carry) + + } + } else { + + // u = u - v + u[0], borrow = bits.Sub64(u[0], v[0], 0) + u[1], borrow = bits.Sub64(u[1], v[1], borrow) + u[2], borrow = bits.Sub64(u[2], v[2], borrow) + u[3], _ = bits.Sub64(u[3], v[3], borrow) + + // r = r - s + r[0], borrow = bits.Sub64(r[0], s[0], 0) + r[1], borrow = bits.Sub64(r[1], s[1], borrow) + r[2], borrow = bits.Sub64(r[2], s[2], borrow) + r[3], borrow = bits.Sub64(r[3], s[3], borrow) + + if borrow == 1 { + + // r = r + q + r[0], carry = bits.Add64(r[0], 4332616871279656263, 0) + r[1], carry = bits.Add64(r[1], 10917124144477883021, carry) + r[2], carry = bits.Add64(r[2], 13281191951274694749, carry) + r[3], _ = bits.Add64(r[3], 3486998266802970665, carry) + + } + } + if (u[0] == 1) && (u[3]|u[2]|u[1]) == 0 { + return z.Set(&r) + } + if (v[0] == 1) && (v[3]|v[2]|v[1]) == 0 { + return z.Set(&s) + } + } + +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element_mul_adx_amd64.s b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element_mul_adx_amd64.s new file mode 100644 index 00000000000..2465dbb936b --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element_mul_adx_amd64.s @@ -0,0 +1,466 @@ +// +build amd64_adx + +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +#include "textflag.h" +#include "funcdata.h" + +// modulus q +DATA q<>+0(SB)/8, $0x3c208c16d87cfd47 +DATA q<>+8(SB)/8, $0x97816a916871ca8d +DATA q<>+16(SB)/8, $0xb85045b68181585d +DATA q<>+24(SB)/8, $0x30644e72e131a029 +GLOBL q<>(SB), (RODATA+NOPTR), $32 + +// qInv0 q'[0] +DATA qInv0<>(SB)/8, $0x87d20782e4866389 +GLOBL qInv0<>(SB), (RODATA+NOPTR), $8 + +#define REDUCE(ra0, ra1, ra2, ra3, rb0, rb1, rb2, rb3) \ + MOVQ ra0, rb0; \ + SUBQ q<>(SB), ra0; \ + MOVQ ra1, rb1; \ + SBBQ q<>+8(SB), ra1; \ + MOVQ ra2, rb2; \ + SBBQ q<>+16(SB), ra2; \ + MOVQ ra3, rb3; \ + SBBQ q<>+24(SB), ra3; \ + CMOVQCS rb0, ra0; \ + CMOVQCS rb1, ra1; \ + CMOVQCS rb2, ra2; \ + CMOVQCS rb3, ra3; \ + +// mul(res, x, y *Element) +TEXT ·mul(SB), NOSPLIT, $0-24 + + // the algorithm is described here + // https://hackmd.io/@zkteam/modular_multiplication + // however, to benefit from the ADCX and ADOX carry chains + // we split the inner loops in 2: + // for i=0 to N-1 + // for j=0 to N-1 + // (A,t[j]) := t[j] + x[j]*y[i] + A + // m := t[0]*q'[0] mod W + // C,_ := t[0] + m*q[0] + // for j=1 to N-1 + // (C,t[j-1]) := t[j] + m*q[j] + C + // t[N-1] = C + A + + MOVQ x+8(FP), SI + + // x[0] -> DI + // x[1] -> R8 + // x[2] -> R9 + // x[3] -> R10 + MOVQ 0(SI), DI + MOVQ 8(SI), R8 + MOVQ 16(SI), R9 + MOVQ 24(SI), R10 + MOVQ y+16(FP), R11 + + // A -> BP + // t[0] -> R14 + // t[1] -> R15 + // t[2] -> CX + // t[3] -> BX + // clear the flags + XORQ AX, AX + MOVQ 0(R11), DX + + // (A,t[0]) := x[0]*y[0] + A + MULXQ DI, R14, R15 + + // (A,t[1]) := x[1]*y[0] + A + MULXQ R8, AX, CX + ADOXQ AX, R15 + + // (A,t[2]) := x[2]*y[0] + A + MULXQ R9, AX, BX + ADOXQ AX, CX + + // (A,t[3]) := x[3]*y[0] + A + MULXQ R10, AX, BP + ADOXQ AX, BX + + // A += carries from ADCXQ and ADOXQ + MOVQ $0, AX + ADOXQ AX, BP + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + + // clear the flags + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, R12 + ADCXQ R14, AX + MOVQ R12, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + + // t[3] = C + A + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ BP, BX + + // clear the flags + XORQ AX, AX + MOVQ 8(R11), DX + + // (A,t[0]) := t[0] + x[0]*y[1] + A + MULXQ DI, AX, BP + ADOXQ AX, R14 + + // (A,t[1]) := t[1] + x[1]*y[1] + A + ADCXQ BP, R15 + MULXQ R8, AX, BP + ADOXQ AX, R15 + + // (A,t[2]) := t[2] + x[2]*y[1] + A + ADCXQ BP, CX + MULXQ R9, AX, BP + ADOXQ AX, CX + + // (A,t[3]) := t[3] + x[3]*y[1] + A + ADCXQ BP, BX + MULXQ R10, AX, BP + ADOXQ AX, BX + + // A += carries from ADCXQ and ADOXQ + MOVQ $0, AX + ADCXQ AX, BP + ADOXQ AX, BP + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + + // clear the flags + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, R12 + ADCXQ R14, AX + MOVQ R12, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + + // t[3] = C + A + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ BP, BX + + // clear the flags + XORQ AX, AX + MOVQ 16(R11), DX + + // (A,t[0]) := t[0] + x[0]*y[2] + A + MULXQ DI, AX, BP + ADOXQ AX, R14 + + // (A,t[1]) := t[1] + x[1]*y[2] + A + ADCXQ BP, R15 + MULXQ R8, AX, BP + ADOXQ AX, R15 + + // (A,t[2]) := t[2] + x[2]*y[2] + A + ADCXQ BP, CX + MULXQ R9, AX, BP + ADOXQ AX, CX + + // (A,t[3]) := t[3] + x[3]*y[2] + A + ADCXQ BP, BX + MULXQ R10, AX, BP + ADOXQ AX, BX + + // A += carries from ADCXQ and ADOXQ + MOVQ $0, AX + ADCXQ AX, BP + ADOXQ AX, BP + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + + // clear the flags + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, R12 + ADCXQ R14, AX + MOVQ R12, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + + // t[3] = C + A + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ BP, BX + + // clear the flags + XORQ AX, AX + MOVQ 24(R11), DX + + // (A,t[0]) := t[0] + x[0]*y[3] + A + MULXQ DI, AX, BP + ADOXQ AX, R14 + + // (A,t[1]) := t[1] + x[1]*y[3] + A + ADCXQ BP, R15 + MULXQ R8, AX, BP + ADOXQ AX, R15 + + // (A,t[2]) := t[2] + x[2]*y[3] + A + ADCXQ BP, CX + MULXQ R9, AX, BP + ADOXQ AX, CX + + // (A,t[3]) := t[3] + x[3]*y[3] + A + ADCXQ BP, BX + MULXQ R10, AX, BP + ADOXQ AX, BX + + // A += carries from ADCXQ and ADOXQ + MOVQ $0, AX + ADCXQ AX, BP + ADOXQ AX, BP + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + + // clear the flags + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, R12 + ADCXQ R14, AX + MOVQ R12, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + + // t[3] = C + A + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ BP, BX + + // reduce element(R14,R15,CX,BX) using temp registers (R13,SI,R12,R11) + REDUCE(R14,R15,CX,BX,R13,SI,R12,R11) + + MOVQ res+0(FP), AX + MOVQ R14, 0(AX) + MOVQ R15, 8(AX) + MOVQ CX, 16(AX) + MOVQ BX, 24(AX) + RET + +TEXT ·fromMont(SB), NOSPLIT, $0-8 + + // the algorithm is described here + // https://hackmd.io/@zkteam/modular_multiplication + // when y = 1 we have: + // for i=0 to N-1 + // t[i] = x[i] + // for i=0 to N-1 + // m := t[0]*q'[0] mod W + // C,_ := t[0] + m*q[0] + // for j=1 to N-1 + // (C,t[j-1]) := t[j] + m*q[j] + C + // t[N-1] = C + MOVQ res+0(FP), DX + MOVQ 0(DX), R14 + MOVQ 8(DX), R15 + MOVQ 16(DX), CX + MOVQ 24(DX), BX + XORQ DX, DX + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, BP + ADCXQ R14, AX + MOVQ BP, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ AX, BX + XORQ DX, DX + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, BP + ADCXQ R14, AX + MOVQ BP, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ AX, BX + XORQ DX, DX + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, BP + ADCXQ R14, AX + MOVQ BP, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ AX, BX + XORQ DX, DX + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, BP + ADCXQ R14, AX + MOVQ BP, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ AX, BX + + // reduce element(R14,R15,CX,BX) using temp registers (SI,DI,R8,R9) + REDUCE(R14,R15,CX,BX,SI,DI,R8,R9) + + MOVQ res+0(FP), AX + MOVQ R14, 0(AX) + MOVQ R15, 8(AX) + MOVQ CX, 16(AX) + MOVQ BX, 24(AX) + RET diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element_mul_amd64.s b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element_mul_amd64.s new file mode 100644 index 00000000000..bd64044052f --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element_mul_amd64.s @@ -0,0 +1,488 @@ +// +build !amd64_adx + +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +#include "textflag.h" +#include "funcdata.h" + +// modulus q +DATA q<>+0(SB)/8, $0x3c208c16d87cfd47 +DATA q<>+8(SB)/8, $0x97816a916871ca8d +DATA q<>+16(SB)/8, $0xb85045b68181585d +DATA q<>+24(SB)/8, $0x30644e72e131a029 +GLOBL q<>(SB), (RODATA+NOPTR), $32 + +// qInv0 q'[0] +DATA qInv0<>(SB)/8, $0x87d20782e4866389 +GLOBL qInv0<>(SB), (RODATA+NOPTR), $8 + +#define REDUCE(ra0, ra1, ra2, ra3, rb0, rb1, rb2, rb3) \ + MOVQ ra0, rb0; \ + SUBQ q<>(SB), ra0; \ + MOVQ ra1, rb1; \ + SBBQ q<>+8(SB), ra1; \ + MOVQ ra2, rb2; \ + SBBQ q<>+16(SB), ra2; \ + MOVQ ra3, rb3; \ + SBBQ q<>+24(SB), ra3; \ + CMOVQCS rb0, ra0; \ + CMOVQCS rb1, ra1; \ + CMOVQCS rb2, ra2; \ + CMOVQCS rb3, ra3; \ + +// mul(res, x, y *Element) +TEXT ·mul(SB), $24-24 + + // the algorithm is described here + // https://hackmd.io/@zkteam/modular_multiplication + // however, to benefit from the ADCX and ADOX carry chains + // we split the inner loops in 2: + // for i=0 to N-1 + // for j=0 to N-1 + // (A,t[j]) := t[j] + x[j]*y[i] + A + // m := t[0]*q'[0] mod W + // C,_ := t[0] + m*q[0] + // for j=1 to N-1 + // (C,t[j-1]) := t[j] + m*q[j] + C + // t[N-1] = C + A + + NO_LOCAL_POINTERS + CMPB ·supportAdx(SB), $1 + JNE l1 + MOVQ x+8(FP), SI + + // x[0] -> DI + // x[1] -> R8 + // x[2] -> R9 + // x[3] -> R10 + MOVQ 0(SI), DI + MOVQ 8(SI), R8 + MOVQ 16(SI), R9 + MOVQ 24(SI), R10 + MOVQ y+16(FP), R11 + + // A -> BP + // t[0] -> R14 + // t[1] -> R15 + // t[2] -> CX + // t[3] -> BX + // clear the flags + XORQ AX, AX + MOVQ 0(R11), DX + + // (A,t[0]) := x[0]*y[0] + A + MULXQ DI, R14, R15 + + // (A,t[1]) := x[1]*y[0] + A + MULXQ R8, AX, CX + ADOXQ AX, R15 + + // (A,t[2]) := x[2]*y[0] + A + MULXQ R9, AX, BX + ADOXQ AX, CX + + // (A,t[3]) := x[3]*y[0] + A + MULXQ R10, AX, BP + ADOXQ AX, BX + + // A += carries from ADCXQ and ADOXQ + MOVQ $0, AX + ADOXQ AX, BP + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + + // clear the flags + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, R12 + ADCXQ R14, AX + MOVQ R12, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + + // t[3] = C + A + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ BP, BX + + // clear the flags + XORQ AX, AX + MOVQ 8(R11), DX + + // (A,t[0]) := t[0] + x[0]*y[1] + A + MULXQ DI, AX, BP + ADOXQ AX, R14 + + // (A,t[1]) := t[1] + x[1]*y[1] + A + ADCXQ BP, R15 + MULXQ R8, AX, BP + ADOXQ AX, R15 + + // (A,t[2]) := t[2] + x[2]*y[1] + A + ADCXQ BP, CX + MULXQ R9, AX, BP + ADOXQ AX, CX + + // (A,t[3]) := t[3] + x[3]*y[1] + A + ADCXQ BP, BX + MULXQ R10, AX, BP + ADOXQ AX, BX + + // A += carries from ADCXQ and ADOXQ + MOVQ $0, AX + ADCXQ AX, BP + ADOXQ AX, BP + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + + // clear the flags + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, R12 + ADCXQ R14, AX + MOVQ R12, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + + // t[3] = C + A + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ BP, BX + + // clear the flags + XORQ AX, AX + MOVQ 16(R11), DX + + // (A,t[0]) := t[0] + x[0]*y[2] + A + MULXQ DI, AX, BP + ADOXQ AX, R14 + + // (A,t[1]) := t[1] + x[1]*y[2] + A + ADCXQ BP, R15 + MULXQ R8, AX, BP + ADOXQ AX, R15 + + // (A,t[2]) := t[2] + x[2]*y[2] + A + ADCXQ BP, CX + MULXQ R9, AX, BP + ADOXQ AX, CX + + // (A,t[3]) := t[3] + x[3]*y[2] + A + ADCXQ BP, BX + MULXQ R10, AX, BP + ADOXQ AX, BX + + // A += carries from ADCXQ and ADOXQ + MOVQ $0, AX + ADCXQ AX, BP + ADOXQ AX, BP + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + + // clear the flags + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, R12 + ADCXQ R14, AX + MOVQ R12, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + + // t[3] = C + A + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ BP, BX + + // clear the flags + XORQ AX, AX + MOVQ 24(R11), DX + + // (A,t[0]) := t[0] + x[0]*y[3] + A + MULXQ DI, AX, BP + ADOXQ AX, R14 + + // (A,t[1]) := t[1] + x[1]*y[3] + A + ADCXQ BP, R15 + MULXQ R8, AX, BP + ADOXQ AX, R15 + + // (A,t[2]) := t[2] + x[2]*y[3] + A + ADCXQ BP, CX + MULXQ R9, AX, BP + ADOXQ AX, CX + + // (A,t[3]) := t[3] + x[3]*y[3] + A + ADCXQ BP, BX + MULXQ R10, AX, BP + ADOXQ AX, BX + + // A += carries from ADCXQ and ADOXQ + MOVQ $0, AX + ADCXQ AX, BP + ADOXQ AX, BP + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + + // clear the flags + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, R12 + ADCXQ R14, AX + MOVQ R12, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + + // t[3] = C + A + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ BP, BX + + // reduce element(R14,R15,CX,BX) using temp registers (R13,SI,R12,R11) + REDUCE(R14,R15,CX,BX,R13,SI,R12,R11) + + MOVQ res+0(FP), AX + MOVQ R14, 0(AX) + MOVQ R15, 8(AX) + MOVQ CX, 16(AX) + MOVQ BX, 24(AX) + RET + +l1: + MOVQ res+0(FP), AX + MOVQ AX, (SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·_mulGeneric(SB) + RET + +TEXT ·fromMont(SB), $8-8 + NO_LOCAL_POINTERS + + // the algorithm is described here + // https://hackmd.io/@zkteam/modular_multiplication + // when y = 1 we have: + // for i=0 to N-1 + // t[i] = x[i] + // for i=0 to N-1 + // m := t[0]*q'[0] mod W + // C,_ := t[0] + m*q[0] + // for j=1 to N-1 + // (C,t[j-1]) := t[j] + m*q[j] + C + // t[N-1] = C + CMPB ·supportAdx(SB), $1 + JNE l2 + MOVQ res+0(FP), DX + MOVQ 0(DX), R14 + MOVQ 8(DX), R15 + MOVQ 16(DX), CX + MOVQ 24(DX), BX + XORQ DX, DX + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, BP + ADCXQ R14, AX + MOVQ BP, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ AX, BX + XORQ DX, DX + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, BP + ADCXQ R14, AX + MOVQ BP, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ AX, BX + XORQ DX, DX + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, BP + ADCXQ R14, AX + MOVQ BP, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ AX, BX + XORQ DX, DX + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, BP + ADCXQ R14, AX + MOVQ BP, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ AX, BX + + // reduce element(R14,R15,CX,BX) using temp registers (SI,DI,R8,R9) + REDUCE(R14,R15,CX,BX,SI,DI,R8,R9) + + MOVQ res+0(FP), AX + MOVQ R14, 0(AX) + MOVQ R15, 8(AX) + MOVQ CX, 16(AX) + MOVQ BX, 24(AX) + RET + +l2: + MOVQ res+0(FP), AX + MOVQ AX, (SP) + CALL ·_fromMontGeneric(SB) + RET diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element_ops_amd64.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element_ops_amd64.go new file mode 100644 index 00000000000..71b26855b49 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element_ops_amd64.go @@ -0,0 +1,44 @@ +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package fp + +//go:noescape +func MulBy3(x *Element) + +//go:noescape +func MulBy5(x *Element) + +//go:noescape +func add(res, x, y *Element) + +//go:noescape +func sub(res, x, y *Element) + +//go:noescape +func neg(res, x *Element) + +//go:noescape +func double(res, x *Element) + +//go:noescape +func mul(res, x, y *Element) + +//go:noescape +func fromMont(res *Element) + +//go:noescape +func reduce(res *Element) diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element_ops_amd64.s b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element_ops_amd64.s new file mode 100644 index 00000000000..833c807ece8 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element_ops_amd64.s @@ -0,0 +1,235 @@ +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +#include "textflag.h" +#include "funcdata.h" + +// modulus q +DATA q<>+0(SB)/8, $0x3c208c16d87cfd47 +DATA q<>+8(SB)/8, $0x97816a916871ca8d +DATA q<>+16(SB)/8, $0xb85045b68181585d +DATA q<>+24(SB)/8, $0x30644e72e131a029 +GLOBL q<>(SB), (RODATA+NOPTR), $32 + +// qInv0 q'[0] +DATA qInv0<>(SB)/8, $0x87d20782e4866389 +GLOBL qInv0<>(SB), (RODATA+NOPTR), $8 + +#define REDUCE(ra0, ra1, ra2, ra3, rb0, rb1, rb2, rb3) \ + MOVQ ra0, rb0; \ + SUBQ q<>(SB), ra0; \ + MOVQ ra1, rb1; \ + SBBQ q<>+8(SB), ra1; \ + MOVQ ra2, rb2; \ + SBBQ q<>+16(SB), ra2; \ + MOVQ ra3, rb3; \ + SBBQ q<>+24(SB), ra3; \ + CMOVQCS rb0, ra0; \ + CMOVQCS rb1, ra1; \ + CMOVQCS rb2, ra2; \ + CMOVQCS rb3, ra3; \ + +// add(res, x, y *Element) +TEXT ·add(SB), NOSPLIT, $0-24 + MOVQ x+8(FP), AX + MOVQ 0(AX), CX + MOVQ 8(AX), BX + MOVQ 16(AX), SI + MOVQ 24(AX), DI + MOVQ y+16(FP), DX + ADDQ 0(DX), CX + ADCQ 8(DX), BX + ADCQ 16(DX), SI + ADCQ 24(DX), DI + + // reduce element(CX,BX,SI,DI) using temp registers (R8,R9,R10,R11) + REDUCE(CX,BX,SI,DI,R8,R9,R10,R11) + + MOVQ res+0(FP), R12 + MOVQ CX, 0(R12) + MOVQ BX, 8(R12) + MOVQ SI, 16(R12) + MOVQ DI, 24(R12) + RET + +// sub(res, x, y *Element) +TEXT ·sub(SB), NOSPLIT, $0-24 + XORQ DI, DI + MOVQ x+8(FP), SI + MOVQ 0(SI), AX + MOVQ 8(SI), DX + MOVQ 16(SI), CX + MOVQ 24(SI), BX + MOVQ y+16(FP), SI + SUBQ 0(SI), AX + SBBQ 8(SI), DX + SBBQ 16(SI), CX + SBBQ 24(SI), BX + MOVQ $0x3c208c16d87cfd47, R8 + MOVQ $0x97816a916871ca8d, R9 + MOVQ $0xb85045b68181585d, R10 + MOVQ $0x30644e72e131a029, R11 + CMOVQCC DI, R8 + CMOVQCC DI, R9 + CMOVQCC DI, R10 + CMOVQCC DI, R11 + ADDQ R8, AX + ADCQ R9, DX + ADCQ R10, CX + ADCQ R11, BX + MOVQ res+0(FP), R12 + MOVQ AX, 0(R12) + MOVQ DX, 8(R12) + MOVQ CX, 16(R12) + MOVQ BX, 24(R12) + RET + +// double(res, x *Element) +TEXT ·double(SB), NOSPLIT, $0-16 + MOVQ x+8(FP), AX + MOVQ 0(AX), DX + MOVQ 8(AX), CX + MOVQ 16(AX), BX + MOVQ 24(AX), SI + ADDQ DX, DX + ADCQ CX, CX + ADCQ BX, BX + ADCQ SI, SI + + // reduce element(DX,CX,BX,SI) using temp registers (DI,R8,R9,R10) + REDUCE(DX,CX,BX,SI,DI,R8,R9,R10) + + MOVQ res+0(FP), R11 + MOVQ DX, 0(R11) + MOVQ CX, 8(R11) + MOVQ BX, 16(R11) + MOVQ SI, 24(R11) + RET + +// neg(res, x *Element) +TEXT ·neg(SB), NOSPLIT, $0-16 + MOVQ res+0(FP), DI + MOVQ x+8(FP), AX + MOVQ 0(AX), DX + MOVQ 8(AX), CX + MOVQ 16(AX), BX + MOVQ 24(AX), SI + MOVQ DX, AX + ORQ CX, AX + ORQ BX, AX + ORQ SI, AX + TESTQ AX, AX + JEQ l1 + MOVQ $0x3c208c16d87cfd47, R8 + SUBQ DX, R8 + MOVQ R8, 0(DI) + MOVQ $0x97816a916871ca8d, R8 + SBBQ CX, R8 + MOVQ R8, 8(DI) + MOVQ $0xb85045b68181585d, R8 + SBBQ BX, R8 + MOVQ R8, 16(DI) + MOVQ $0x30644e72e131a029, R8 + SBBQ SI, R8 + MOVQ R8, 24(DI) + RET + +l1: + MOVQ AX, 0(DI) + MOVQ AX, 8(DI) + MOVQ AX, 16(DI) + MOVQ AX, 24(DI) + RET + +TEXT ·reduce(SB), NOSPLIT, $0-8 + MOVQ res+0(FP), AX + MOVQ 0(AX), DX + MOVQ 8(AX), CX + MOVQ 16(AX), BX + MOVQ 24(AX), SI + + // reduce element(DX,CX,BX,SI) using temp registers (DI,R8,R9,R10) + REDUCE(DX,CX,BX,SI,DI,R8,R9,R10) + + MOVQ DX, 0(AX) + MOVQ CX, 8(AX) + MOVQ BX, 16(AX) + MOVQ SI, 24(AX) + RET + +// MulBy3(x *Element) +TEXT ·MulBy3(SB), NOSPLIT, $0-8 + MOVQ x+0(FP), AX + MOVQ 0(AX), DX + MOVQ 8(AX), CX + MOVQ 16(AX), BX + MOVQ 24(AX), SI + ADDQ DX, DX + ADCQ CX, CX + ADCQ BX, BX + ADCQ SI, SI + + // reduce element(DX,CX,BX,SI) using temp registers (DI,R8,R9,R10) + REDUCE(DX,CX,BX,SI,DI,R8,R9,R10) + + ADDQ 0(AX), DX + ADCQ 8(AX), CX + ADCQ 16(AX), BX + ADCQ 24(AX), SI + + // reduce element(DX,CX,BX,SI) using temp registers (R11,R12,R13,R14) + REDUCE(DX,CX,BX,SI,R11,R12,R13,R14) + + MOVQ DX, 0(AX) + MOVQ CX, 8(AX) + MOVQ BX, 16(AX) + MOVQ SI, 24(AX) + RET + +// MulBy5(x *Element) +TEXT ·MulBy5(SB), NOSPLIT, $0-8 + MOVQ x+0(FP), AX + MOVQ 0(AX), DX + MOVQ 8(AX), CX + MOVQ 16(AX), BX + MOVQ 24(AX), SI + ADDQ DX, DX + ADCQ CX, CX + ADCQ BX, BX + ADCQ SI, SI + + // reduce element(DX,CX,BX,SI) using temp registers (DI,R8,R9,R10) + REDUCE(DX,CX,BX,SI,DI,R8,R9,R10) + + ADDQ DX, DX + ADCQ CX, CX + ADCQ BX, BX + ADCQ SI, SI + + // reduce element(DX,CX,BX,SI) using temp registers (R11,R12,R13,R14) + REDUCE(DX,CX,BX,SI,R11,R12,R13,R14) + + ADDQ 0(AX), DX + ADCQ 8(AX), CX + ADCQ 16(AX), BX + ADCQ 24(AX), SI + + // reduce element(DX,CX,BX,SI) using temp registers (R15,DI,R8,R9) + REDUCE(DX,CX,BX,SI,R15,DI,R8,R9) + + MOVQ DX, 0(AX) + MOVQ CX, 8(AX) + MOVQ BX, 16(AX) + MOVQ SI, 24(AX) + RET diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element_ops_noasm.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element_ops_noasm.go new file mode 100644 index 00000000000..e6ced1bf566 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fp/element_ops_noasm.go @@ -0,0 +1,65 @@ +// +build !amd64 + +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package fp + +// /!\ WARNING /!\ +// this code has not been audited and is provided as-is. In particular, +// there is no security guarantees such as constant time implementation +// or side-channel attack resistance +// /!\ WARNING /!\ + +// MulBy3 x *= 3 +func MulBy3(x *Element) { + mulByConstant(x, 3) +} + +// MulBy5 x *= 5 +func MulBy5(x *Element) { + mulByConstant(x, 5) +} + +func mul(z, x, y *Element) { + _mulGeneric(z, x, y) +} + +// FromMont converts z in place (i.e. mutates) from Montgomery to regular representation +// sets and returns z = z * 1 +func fromMont(z *Element) { + _fromMontGeneric(z) +} + +func add(z, x, y *Element) { + _addGeneric(z, x, y) +} + +func double(z, x *Element) { + _doubleGeneric(z, x) +} + +func sub(z, x, y *Element) { + _subGeneric(z, x, y) +} + +func neg(z, x *Element) { + _negGeneric(z, x) +} + +func reduce(z *Element) { + _reduceGeneric(z) +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/arith.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/arith.go new file mode 100644 index 00000000000..83c9fd9ef91 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/arith.go @@ -0,0 +1,60 @@ +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package fr + +import ( + "math/bits" +) + +// madd0 hi = a*b + c (discards lo bits) +func madd0(a, b, c uint64) (hi uint64) { + var carry, lo uint64 + hi, lo = bits.Mul64(a, b) + _, carry = bits.Add64(lo, c, 0) + hi, _ = bits.Add64(hi, 0, carry) + return +} + +// madd1 hi, lo = a*b + c +func madd1(a, b, c uint64) (hi uint64, lo uint64) { + var carry uint64 + hi, lo = bits.Mul64(a, b) + lo, carry = bits.Add64(lo, c, 0) + hi, _ = bits.Add64(hi, 0, carry) + return +} + +// madd2 hi, lo = a*b + c + d +func madd2(a, b, c, d uint64) (hi uint64, lo uint64) { + var carry uint64 + hi, lo = bits.Mul64(a, b) + c, carry = bits.Add64(c, d, 0) + hi, _ = bits.Add64(hi, 0, carry) + lo, carry = bits.Add64(lo, c, 0) + hi, _ = bits.Add64(hi, 0, carry) + return +} + +func madd3(a, b, c, d, e uint64) (hi uint64, lo uint64) { + var carry uint64 + hi, lo = bits.Mul64(a, b) + c, carry = bits.Add64(c, d, 0) + hi, _ = bits.Add64(hi, 0, carry) + lo, carry = bits.Add64(lo, c, 0) + hi, _ = bits.Add64(hi, e, carry) + return +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/asm.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/asm.go new file mode 100644 index 00000000000..f859dd8731d --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/asm.go @@ -0,0 +1,23 @@ +// +build !noadx + +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package fr + +import "golang.org/x/sys/cpu" + +var supportAdx = cpu.X86.HasADX && cpu.X86.HasBMI2 diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/asm_noadx.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/asm_noadx.go new file mode 100644 index 00000000000..ab9b869b5b4 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/asm_noadx.go @@ -0,0 +1,24 @@ +// +build noadx + +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package fr + +// note: this is needed for test purposes, as dynamically changing supportAdx doesn't flag +// certain errors (like fatal error: missing stackmap) +// this ensures we test all asm path. +var supportAdx = false diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element.go new file mode 100644 index 00000000000..3759baa5848 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element.go @@ -0,0 +1,947 @@ +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +// Package fr contains field arithmetic operations for modulus 21888242871839275222246405745257275088548364400416034343698204186575808495617 +package fr + +// /!\ WARNING /!\ +// this code has not been audited and is provided as-is. In particular, +// there is no security guarantees such as constant time implementation +// or side-channel attack resistance +// /!\ WARNING /!\ + +import ( + "crypto/rand" + "encoding/binary" + "io" + "math/big" + "math/bits" + "strconv" + "sync" +) + +// Element represents a field element stored on 4 words (uint64) +// Element are assumed to be in Montgomery form in all methods +// field modulus q = +// +// 21888242871839275222246405745257275088548364400416034343698204186575808495617 +type Element [4]uint64 + +// Limbs number of 64 bits words needed to represent Element +const Limbs = 4 + +// Bits number bits needed to represent Element +const Bits = 254 + +// Bytes number bytes needed to represent Element +const Bytes = Limbs * 8 + +// field modulus stored as big.Int +var _modulus big.Int + +// Modulus returns q as a big.Int +// q = +// +// 21888242871839275222246405745257275088548364400416034343698204186575808495617 +func Modulus() *big.Int { + return new(big.Int).Set(&_modulus) +} + +// q (modulus) +var qElement = Element{ + 4891460686036598785, + 2896914383306846353, + 13281191951274694749, + 3486998266802970665, +} + +// rSquare +var rSquare = Element{ + 1997599621687373223, + 6052339484930628067, + 10108755138030829701, + 150537098327114917, +} + +var bigIntPool = sync.Pool{ + New: func() interface{} { + return new(big.Int) + }, +} + +func init() { + _modulus.SetString("21888242871839275222246405745257275088548364400416034343698204186575808495617", 10) +} + +// SetUint64 z = v, sets z LSB to v (non-Montgomery form) and convert z to Montgomery form +func (z *Element) SetUint64(v uint64) *Element { + *z = Element{v} + return z.Mul(z, &rSquare) // z.ToMont() +} + +// Set z = x +func (z *Element) Set(x *Element) *Element { + z[0] = x[0] + z[1] = x[1] + z[2] = x[2] + z[3] = x[3] + return z +} + +// SetInterface converts i1 from uint64, int, string, or Element, big.Int into Element +// panic if provided type is not supported +func (z *Element) SetInterface(i1 interface{}) *Element { + switch c1 := i1.(type) { + case Element: + return z.Set(&c1) + case *Element: + return z.Set(c1) + case uint64: + return z.SetUint64(c1) + case int: + return z.SetString(strconv.Itoa(c1)) + case string: + return z.SetString(c1) + case *big.Int: + return z.SetBigInt(c1) + case big.Int: + return z.SetBigInt(&c1) + case []byte: + return z.SetBytes(c1) + default: + panic("invalid type") + } +} + +// SetZero z = 0 +func (z *Element) SetZero() *Element { + z[0] = 0 + z[1] = 0 + z[2] = 0 + z[3] = 0 + return z +} + +// SetOne z = 1 (in Montgomery form) +func (z *Element) SetOne() *Element { + z[0] = 12436184717236109307 + z[1] = 3962172157175319849 + z[2] = 7381016538464732718 + z[3] = 1011752739694698287 + return z +} + +// Div z = x*y^-1 mod q +func (z *Element) Div(x, y *Element) *Element { + var yInv Element + yInv.Inverse(y) + z.Mul(x, &yInv) + return z +} + +// Equal returns z == x +func (z *Element) Equal(x *Element) bool { + return (z[3] == x[3]) && (z[2] == x[2]) && (z[1] == x[1]) && (z[0] == x[0]) +} + +// IsZero returns z == 0 +func (z *Element) IsZero() bool { + return (z[3] | z[2] | z[1] | z[0]) == 0 +} + +// Cmp compares (lexicographic order) z and x and returns: +// +// -1 if z < x +// 0 if z == x +// +1 if z > x +// +func (z *Element) Cmp(x *Element) int { + _z := *z + _x := *x + _z.FromMont() + _x.FromMont() + if _z[3] > _x[3] { + return 1 + } else if _z[3] < _x[3] { + return -1 + } + if _z[2] > _x[2] { + return 1 + } else if _z[2] < _x[2] { + return -1 + } + if _z[1] > _x[1] { + return 1 + } else if _z[1] < _x[1] { + return -1 + } + if _z[0] > _x[0] { + return 1 + } else if _z[0] < _x[0] { + return -1 + } + return 0 +} + +// LexicographicallyLargest returns true if this element is strictly lexicographically +// larger than its negation, false otherwise +func (z *Element) LexicographicallyLargest() bool { + // adapted from github.com/zkcrypto/bls12_381 + // we check if the element is larger than (q-1) / 2 + // if z - (((q -1) / 2) + 1) have no underflow, then z > (q-1) / 2 + + _z := *z + _z.FromMont() + + var b uint64 + _, b = bits.Sub64(_z[0], 11669102379873075201, 0) + _, b = bits.Sub64(_z[1], 10671829228508198984, b) + _, b = bits.Sub64(_z[2], 15863968012492123182, b) + _, b = bits.Sub64(_z[3], 1743499133401485332, b) + + return b == 0 +} + +// SetRandom sets z to a random element < q +func (z *Element) SetRandom() (*Element, error) { + var bytes [32]byte + if _, err := io.ReadFull(rand.Reader, bytes[:]); err != nil { + return nil, err + } + z[0] = binary.BigEndian.Uint64(bytes[0:8]) + z[1] = binary.BigEndian.Uint64(bytes[8:16]) + z[2] = binary.BigEndian.Uint64(bytes[16:24]) + z[3] = binary.BigEndian.Uint64(bytes[24:32]) + z[3] %= 3486998266802970665 + + // if z > q --> z -= q + // note: this is NOT constant time + if !(z[3] < 3486998266802970665 || (z[3] == 3486998266802970665 && (z[2] < 13281191951274694749 || (z[2] == 13281191951274694749 && (z[1] < 2896914383306846353 || (z[1] == 2896914383306846353 && (z[0] < 4891460686036598785))))))) { + var b uint64 + z[0], b = bits.Sub64(z[0], 4891460686036598785, 0) + z[1], b = bits.Sub64(z[1], 2896914383306846353, b) + z[2], b = bits.Sub64(z[2], 13281191951274694749, b) + z[3], _ = bits.Sub64(z[3], 3486998266802970665, b) + } + + return z, nil +} + +// One returns 1 (in montgommery form) +func One() Element { + var one Element + one.SetOne() + return one +} + +// MulAssign is deprecated +// Deprecated: use Mul instead +func (z *Element) MulAssign(x *Element) *Element { + return z.Mul(z, x) +} + +// AddAssign is deprecated +// Deprecated: use Add instead +func (z *Element) AddAssign(x *Element) *Element { + return z.Add(z, x) +} + +// SubAssign is deprecated +// Deprecated: use Sub instead +func (z *Element) SubAssign(x *Element) *Element { + return z.Sub(z, x) +} + +// API with assembly impl + +// Mul z = x * y mod q +// see https://hackmd.io/@zkteam/modular_multiplication +func (z *Element) Mul(x, y *Element) *Element { + mul(z, x, y) + return z +} + +// Square z = x * x mod q +// see https://hackmd.io/@zkteam/modular_multiplication +func (z *Element) Square(x *Element) *Element { + mul(z, x, x) + return z +} + +// FromMont converts z in place (i.e. mutates) from Montgomery to regular representation +// sets and returns z = z * 1 +func (z *Element) FromMont() *Element { + fromMont(z) + return z +} + +// Add z = x + y mod q +func (z *Element) Add(x, y *Element) *Element { + add(z, x, y) + return z +} + +// Double z = x + x mod q, aka Lsh 1 +func (z *Element) Double(x *Element) *Element { + double(z, x) + return z +} + +// Sub z = x - y mod q +func (z *Element) Sub(x, y *Element) *Element { + sub(z, x, y) + return z +} + +// Neg z = q - x +func (z *Element) Neg(x *Element) *Element { + neg(z, x) + return z +} + +// Generic (no ADX instructions, no AMD64) versions of multiplication and squaring algorithms + +func _mulGeneric(z, x, y *Element) { + + var t [4]uint64 + var c [3]uint64 + { + // round 0 + v := x[0] + c[1], c[0] = bits.Mul64(v, y[0]) + m := c[0] * 14042775128853446655 + c[2] = madd0(m, 4891460686036598785, c[0]) + c[1], c[0] = madd1(v, y[1], c[1]) + c[2], t[0] = madd2(m, 2896914383306846353, c[2], c[0]) + c[1], c[0] = madd1(v, y[2], c[1]) + c[2], t[1] = madd2(m, 13281191951274694749, c[2], c[0]) + c[1], c[0] = madd1(v, y[3], c[1]) + t[3], t[2] = madd3(m, 3486998266802970665, c[0], c[2], c[1]) + } + { + // round 1 + v := x[1] + c[1], c[0] = madd1(v, y[0], t[0]) + m := c[0] * 14042775128853446655 + c[2] = madd0(m, 4891460686036598785, c[0]) + c[1], c[0] = madd2(v, y[1], c[1], t[1]) + c[2], t[0] = madd2(m, 2896914383306846353, c[2], c[0]) + c[1], c[0] = madd2(v, y[2], c[1], t[2]) + c[2], t[1] = madd2(m, 13281191951274694749, c[2], c[0]) + c[1], c[0] = madd2(v, y[3], c[1], t[3]) + t[3], t[2] = madd3(m, 3486998266802970665, c[0], c[2], c[1]) + } + { + // round 2 + v := x[2] + c[1], c[0] = madd1(v, y[0], t[0]) + m := c[0] * 14042775128853446655 + c[2] = madd0(m, 4891460686036598785, c[0]) + c[1], c[0] = madd2(v, y[1], c[1], t[1]) + c[2], t[0] = madd2(m, 2896914383306846353, c[2], c[0]) + c[1], c[0] = madd2(v, y[2], c[1], t[2]) + c[2], t[1] = madd2(m, 13281191951274694749, c[2], c[0]) + c[1], c[0] = madd2(v, y[3], c[1], t[3]) + t[3], t[2] = madd3(m, 3486998266802970665, c[0], c[2], c[1]) + } + { + // round 3 + v := x[3] + c[1], c[0] = madd1(v, y[0], t[0]) + m := c[0] * 14042775128853446655 + c[2] = madd0(m, 4891460686036598785, c[0]) + c[1], c[0] = madd2(v, y[1], c[1], t[1]) + c[2], z[0] = madd2(m, 2896914383306846353, c[2], c[0]) + c[1], c[0] = madd2(v, y[2], c[1], t[2]) + c[2], z[1] = madd2(m, 13281191951274694749, c[2], c[0]) + c[1], c[0] = madd2(v, y[3], c[1], t[3]) + z[3], z[2] = madd3(m, 3486998266802970665, c[0], c[2], c[1]) + } + + // if z > q --> z -= q + // note: this is NOT constant time + if !(z[3] < 3486998266802970665 || (z[3] == 3486998266802970665 && (z[2] < 13281191951274694749 || (z[2] == 13281191951274694749 && (z[1] < 2896914383306846353 || (z[1] == 2896914383306846353 && (z[0] < 4891460686036598785))))))) { + var b uint64 + z[0], b = bits.Sub64(z[0], 4891460686036598785, 0) + z[1], b = bits.Sub64(z[1], 2896914383306846353, b) + z[2], b = bits.Sub64(z[2], 13281191951274694749, b) + z[3], _ = bits.Sub64(z[3], 3486998266802970665, b) + } +} + +func _fromMontGeneric(z *Element) { + // the following lines implement z = z * 1 + // with a modified CIOS montgomery multiplication + { + // m = z[0]n'[0] mod W + m := z[0] * 14042775128853446655 + C := madd0(m, 4891460686036598785, z[0]) + C, z[0] = madd2(m, 2896914383306846353, z[1], C) + C, z[1] = madd2(m, 13281191951274694749, z[2], C) + C, z[2] = madd2(m, 3486998266802970665, z[3], C) + z[3] = C + } + { + // m = z[0]n'[0] mod W + m := z[0] * 14042775128853446655 + C := madd0(m, 4891460686036598785, z[0]) + C, z[0] = madd2(m, 2896914383306846353, z[1], C) + C, z[1] = madd2(m, 13281191951274694749, z[2], C) + C, z[2] = madd2(m, 3486998266802970665, z[3], C) + z[3] = C + } + { + // m = z[0]n'[0] mod W + m := z[0] * 14042775128853446655 + C := madd0(m, 4891460686036598785, z[0]) + C, z[0] = madd2(m, 2896914383306846353, z[1], C) + C, z[1] = madd2(m, 13281191951274694749, z[2], C) + C, z[2] = madd2(m, 3486998266802970665, z[3], C) + z[3] = C + } + { + // m = z[0]n'[0] mod W + m := z[0] * 14042775128853446655 + C := madd0(m, 4891460686036598785, z[0]) + C, z[0] = madd2(m, 2896914383306846353, z[1], C) + C, z[1] = madd2(m, 13281191951274694749, z[2], C) + C, z[2] = madd2(m, 3486998266802970665, z[3], C) + z[3] = C + } + + // if z > q --> z -= q + // note: this is NOT constant time + if !(z[3] < 3486998266802970665 || (z[3] == 3486998266802970665 && (z[2] < 13281191951274694749 || (z[2] == 13281191951274694749 && (z[1] < 2896914383306846353 || (z[1] == 2896914383306846353 && (z[0] < 4891460686036598785))))))) { + var b uint64 + z[0], b = bits.Sub64(z[0], 4891460686036598785, 0) + z[1], b = bits.Sub64(z[1], 2896914383306846353, b) + z[2], b = bits.Sub64(z[2], 13281191951274694749, b) + z[3], _ = bits.Sub64(z[3], 3486998266802970665, b) + } +} + +func _addGeneric(z, x, y *Element) { + var carry uint64 + + z[0], carry = bits.Add64(x[0], y[0], 0) + z[1], carry = bits.Add64(x[1], y[1], carry) + z[2], carry = bits.Add64(x[2], y[2], carry) + z[3], _ = bits.Add64(x[3], y[3], carry) + + // if z > q --> z -= q + // note: this is NOT constant time + if !(z[3] < 3486998266802970665 || (z[3] == 3486998266802970665 && (z[2] < 13281191951274694749 || (z[2] == 13281191951274694749 && (z[1] < 2896914383306846353 || (z[1] == 2896914383306846353 && (z[0] < 4891460686036598785))))))) { + var b uint64 + z[0], b = bits.Sub64(z[0], 4891460686036598785, 0) + z[1], b = bits.Sub64(z[1], 2896914383306846353, b) + z[2], b = bits.Sub64(z[2], 13281191951274694749, b) + z[3], _ = bits.Sub64(z[3], 3486998266802970665, b) + } +} + +func _doubleGeneric(z, x *Element) { + var carry uint64 + + z[0], carry = bits.Add64(x[0], x[0], 0) + z[1], carry = bits.Add64(x[1], x[1], carry) + z[2], carry = bits.Add64(x[2], x[2], carry) + z[3], _ = bits.Add64(x[3], x[3], carry) + + // if z > q --> z -= q + // note: this is NOT constant time + if !(z[3] < 3486998266802970665 || (z[3] == 3486998266802970665 && (z[2] < 13281191951274694749 || (z[2] == 13281191951274694749 && (z[1] < 2896914383306846353 || (z[1] == 2896914383306846353 && (z[0] < 4891460686036598785))))))) { + var b uint64 + z[0], b = bits.Sub64(z[0], 4891460686036598785, 0) + z[1], b = bits.Sub64(z[1], 2896914383306846353, b) + z[2], b = bits.Sub64(z[2], 13281191951274694749, b) + z[3], _ = bits.Sub64(z[3], 3486998266802970665, b) + } +} + +func _subGeneric(z, x, y *Element) { + var b uint64 + z[0], b = bits.Sub64(x[0], y[0], 0) + z[1], b = bits.Sub64(x[1], y[1], b) + z[2], b = bits.Sub64(x[2], y[2], b) + z[3], b = bits.Sub64(x[3], y[3], b) + if b != 0 { + var c uint64 + z[0], c = bits.Add64(z[0], 4891460686036598785, 0) + z[1], c = bits.Add64(z[1], 2896914383306846353, c) + z[2], c = bits.Add64(z[2], 13281191951274694749, c) + z[3], _ = bits.Add64(z[3], 3486998266802970665, c) + } +} + +func _negGeneric(z, x *Element) { + if x.IsZero() { + z.SetZero() + return + } + var borrow uint64 + z[0], borrow = bits.Sub64(4891460686036598785, x[0], 0) + z[1], borrow = bits.Sub64(2896914383306846353, x[1], borrow) + z[2], borrow = bits.Sub64(13281191951274694749, x[2], borrow) + z[3], _ = bits.Sub64(3486998266802970665, x[3], borrow) +} + +func _reduceGeneric(z *Element) { + + // if z > q --> z -= q + // note: this is NOT constant time + if !(z[3] < 3486998266802970665 || (z[3] == 3486998266802970665 && (z[2] < 13281191951274694749 || (z[2] == 13281191951274694749 && (z[1] < 2896914383306846353 || (z[1] == 2896914383306846353 && (z[0] < 4891460686036598785))))))) { + var b uint64 + z[0], b = bits.Sub64(z[0], 4891460686036598785, 0) + z[1], b = bits.Sub64(z[1], 2896914383306846353, b) + z[2], b = bits.Sub64(z[2], 13281191951274694749, b) + z[3], _ = bits.Sub64(z[3], 3486998266802970665, b) + } +} + +func mulByConstant(z *Element, c uint8) { + switch c { + case 0: + z.SetZero() + return + case 1: + return + case 2: + z.Double(z) + return + case 3: + _z := *z + z.Double(z).Add(z, &_z) + case 5: + _z := *z + z.Double(z).Double(z).Add(z, &_z) + default: + panic("not implemented") + } +} + +// Exp z = x^exponent mod q +func (z *Element) Exp(x Element, exponent *big.Int) *Element { + var bZero big.Int + if exponent.Cmp(&bZero) == 0 { + return z.SetOne() + } + + z.Set(&x) + + for i := exponent.BitLen() - 2; i >= 0; i-- { + z.Square(z) + if exponent.Bit(i) == 1 { + z.Mul(z, &x) + } + } + + return z +} + +// ToMont converts z to Montgomery form +// sets and returns z = z * r^2 +func (z *Element) ToMont() *Element { + return z.Mul(z, &rSquare) +} + +// ToRegular returns z in regular form (doesn't mutate z) +func (z Element) ToRegular() Element { + return *z.FromMont() +} + +// String returns the string form of an Element in Montgomery form +func (z *Element) String() string { + vv := bigIntPool.Get().(*big.Int) + defer bigIntPool.Put(vv) + return z.ToBigIntRegular(vv).String() +} + +// ToBigInt returns z as a big.Int in Montgomery form +func (z *Element) ToBigInt(res *big.Int) *big.Int { + var b [Limbs * 8]byte + binary.BigEndian.PutUint64(b[24:32], z[0]) + binary.BigEndian.PutUint64(b[16:24], z[1]) + binary.BigEndian.PutUint64(b[8:16], z[2]) + binary.BigEndian.PutUint64(b[0:8], z[3]) + + return res.SetBytes(b[:]) +} + +// ToBigIntRegular returns z as a big.Int in regular form +func (z Element) ToBigIntRegular(res *big.Int) *big.Int { + z.FromMont() + return z.ToBigInt(res) +} + +// Bytes returns the regular (non montgomery) value +// of z as a big-endian byte array. +func (z *Element) Bytes() (res [Limbs * 8]byte) { + _z := z.ToRegular() + binary.BigEndian.PutUint64(res[24:32], _z[0]) + binary.BigEndian.PutUint64(res[16:24], _z[1]) + binary.BigEndian.PutUint64(res[8:16], _z[2]) + binary.BigEndian.PutUint64(res[0:8], _z[3]) + + return +} + +// SetBytes interprets e as the bytes of a big-endian unsigned integer, +// sets z to that value (in Montgomery form), and returns z. +func (z *Element) SetBytes(e []byte) *Element { + // get a big int from our pool + vv := bigIntPool.Get().(*big.Int) + vv.SetBytes(e) + + // set big int + z.SetBigInt(vv) + + // put temporary object back in pool + bigIntPool.Put(vv) + + return z +} + +// SetBigInt sets z to v (regular form) and returns z in Montgomery form +func (z *Element) SetBigInt(v *big.Int) *Element { + z.SetZero() + + var zero big.Int + + // fast path + c := v.Cmp(&_modulus) + if c == 0 { + // v == 0 + return z + } else if c != 1 && v.Cmp(&zero) != -1 { + // 0 < v < q + return z.setBigInt(v) + } + + // get temporary big int from the pool + vv := bigIntPool.Get().(*big.Int) + + // copy input + modular reduction + vv.Set(v) + vv.Mod(v, &_modulus) + + // set big int byte value + z.setBigInt(vv) + + // release object into pool + bigIntPool.Put(vv) + return z +} + +// setBigInt assumes 0 <= v < q +func (z *Element) setBigInt(v *big.Int) *Element { + vBits := v.Bits() + + if bits.UintSize == 64 { + for i := 0; i < len(vBits); i++ { + z[i] = uint64(vBits[i]) + } + } else { + for i := 0; i < len(vBits); i++ { + if i%2 == 0 { + z[i/2] = uint64(vBits[i]) + } else { + z[i/2] |= uint64(vBits[i]) << 32 + } + } + } + + return z.ToMont() +} + +// SetString creates a big.Int with s (in base 10) and calls SetBigInt on z +func (z *Element) SetString(s string) *Element { + // get temporary big int from the pool + vv := bigIntPool.Get().(*big.Int) + + if _, ok := vv.SetString(s, 10); !ok { + panic("Element.SetString failed -> can't parse number in base10 into a big.Int") + } + z.SetBigInt(vv) + + // release object into pool + bigIntPool.Put(vv) + + return z +} + +var ( + _bLegendreExponentElement *big.Int + _bSqrtExponentElement *big.Int +) + +func init() { + _bLegendreExponentElement, _ = new(big.Int).SetString("183227397098d014dc2822db40c0ac2e9419f4243cdcb848a1f0fac9f8000000", 16) + const sqrtExponentElement = "183227397098d014dc2822db40c0ac2e9419f4243cdcb848a1f0fac9f" + _bSqrtExponentElement, _ = new(big.Int).SetString(sqrtExponentElement, 16) +} + +// Legendre returns the Legendre symbol of z (either +1, -1, or 0.) +func (z *Element) Legendre() int { + var l Element + // z^((q-1)/2) + l.Exp(*z, _bLegendreExponentElement) + + if l.IsZero() { + return 0 + } + + // if l == 1 + if (l[3] == 1011752739694698287) && (l[2] == 7381016538464732718) && (l[1] == 3962172157175319849) && (l[0] == 12436184717236109307) { + return 1 + } + return -1 +} + +// Sqrt z = √x mod q +// if the square root doesn't exist (x is not a square mod q) +// Sqrt leaves z unchanged and returns nil +func (z *Element) Sqrt(x *Element) *Element { + // q ≡ 1 (mod 4) + // see modSqrtTonelliShanks in math/big/int.go + // using https://www.maa.org/sites/default/files/pdf/upload_library/22/Polya/07468342.di020786.02p0470a.pdf + + var y, b, t, w Element + // w = x^((s-1)/2)) + w.Exp(*x, _bSqrtExponentElement) + + // y = x^((s+1)/2)) = w * x + y.Mul(x, &w) + + // b = x^s = w * w * x = y * x + b.Mul(&w, &y) + + // g = nonResidue ^ s + var g = Element{ + 7164790868263648668, + 11685701338293206998, + 6216421865291908056, + 1756667274303109607, + } + r := uint64(28) + + // compute legendre symbol + // t = x^((q-1)/2) = r-1 squaring of x^s + t = b + for i := uint64(0); i < r-1; i++ { + t.Square(&t) + } + if t.IsZero() { + return z.SetZero() + } + if !((t[3] == 1011752739694698287) && (t[2] == 7381016538464732718) && (t[1] == 3962172157175319849) && (t[0] == 12436184717236109307)) { + // t != 1, we don't have a square root + return nil + } + for { + var m uint64 + t = b + + // for t != 1 + for !((t[3] == 1011752739694698287) && (t[2] == 7381016538464732718) && (t[1] == 3962172157175319849) && (t[0] == 12436184717236109307)) { + t.Square(&t) + m++ + } + + if m == 0 { + return z.Set(&y) + } + // t = g^(2^(r-m-1)) mod q + ge := int(r - m - 1) + t = g + for ge > 0 { + t.Square(&t) + ge-- + } + + g.Square(&t) + y.Mul(&y, &t) + b.Mul(&b, &g) + r = m + } +} + +// Inverse z = x^-1 mod q +// Algorithm 16 in "Efficient Software-Implementation of Finite Fields with Applications to Cryptography" +// if x == 0, sets and returns z = x +func (z *Element) Inverse(x *Element) *Element { + if x.IsZero() { + return z.Set(x) + } + + // initialize u = q + var u = Element{ + 4891460686036598785, + 2896914383306846353, + 13281191951274694749, + 3486998266802970665, + } + + // initialize s = r^2 + var s = Element{ + 1997599621687373223, + 6052339484930628067, + 10108755138030829701, + 150537098327114917, + } + + // r = 0 + r := Element{} + + v := *x + + var carry, borrow, t, t2 uint64 + var bigger bool + + for { + for v[0]&1 == 0 { + + // v = v >> 1 + t2 = v[3] << 63 + v[3] >>= 1 + t = t2 + t2 = v[2] << 63 + v[2] = (v[2] >> 1) | t + t = t2 + t2 = v[1] << 63 + v[1] = (v[1] >> 1) | t + t = t2 + v[0] = (v[0] >> 1) | t + + if s[0]&1 == 1 { + + // s = s + q + s[0], carry = bits.Add64(s[0], 4891460686036598785, 0) + s[1], carry = bits.Add64(s[1], 2896914383306846353, carry) + s[2], carry = bits.Add64(s[2], 13281191951274694749, carry) + s[3], _ = bits.Add64(s[3], 3486998266802970665, carry) + + } + + // s = s >> 1 + t2 = s[3] << 63 + s[3] >>= 1 + t = t2 + t2 = s[2] << 63 + s[2] = (s[2] >> 1) | t + t = t2 + t2 = s[1] << 63 + s[1] = (s[1] >> 1) | t + t = t2 + s[0] = (s[0] >> 1) | t + + } + for u[0]&1 == 0 { + + // u = u >> 1 + t2 = u[3] << 63 + u[3] >>= 1 + t = t2 + t2 = u[2] << 63 + u[2] = (u[2] >> 1) | t + t = t2 + t2 = u[1] << 63 + u[1] = (u[1] >> 1) | t + t = t2 + u[0] = (u[0] >> 1) | t + + if r[0]&1 == 1 { + + // r = r + q + r[0], carry = bits.Add64(r[0], 4891460686036598785, 0) + r[1], carry = bits.Add64(r[1], 2896914383306846353, carry) + r[2], carry = bits.Add64(r[2], 13281191951274694749, carry) + r[3], _ = bits.Add64(r[3], 3486998266802970665, carry) + + } + + // r = r >> 1 + t2 = r[3] << 63 + r[3] >>= 1 + t = t2 + t2 = r[2] << 63 + r[2] = (r[2] >> 1) | t + t = t2 + t2 = r[1] << 63 + r[1] = (r[1] >> 1) | t + t = t2 + r[0] = (r[0] >> 1) | t + + } + + // v >= u + bigger = !(v[3] < u[3] || (v[3] == u[3] && (v[2] < u[2] || (v[2] == u[2] && (v[1] < u[1] || (v[1] == u[1] && (v[0] < u[0]))))))) + + if bigger { + + // v = v - u + v[0], borrow = bits.Sub64(v[0], u[0], 0) + v[1], borrow = bits.Sub64(v[1], u[1], borrow) + v[2], borrow = bits.Sub64(v[2], u[2], borrow) + v[3], _ = bits.Sub64(v[3], u[3], borrow) + + // s = s - r + s[0], borrow = bits.Sub64(s[0], r[0], 0) + s[1], borrow = bits.Sub64(s[1], r[1], borrow) + s[2], borrow = bits.Sub64(s[2], r[2], borrow) + s[3], borrow = bits.Sub64(s[3], r[3], borrow) + + if borrow == 1 { + + // s = s + q + s[0], carry = bits.Add64(s[0], 4891460686036598785, 0) + s[1], carry = bits.Add64(s[1], 2896914383306846353, carry) + s[2], carry = bits.Add64(s[2], 13281191951274694749, carry) + s[3], _ = bits.Add64(s[3], 3486998266802970665, carry) + + } + } else { + + // u = u - v + u[0], borrow = bits.Sub64(u[0], v[0], 0) + u[1], borrow = bits.Sub64(u[1], v[1], borrow) + u[2], borrow = bits.Sub64(u[2], v[2], borrow) + u[3], _ = bits.Sub64(u[3], v[3], borrow) + + // r = r - s + r[0], borrow = bits.Sub64(r[0], s[0], 0) + r[1], borrow = bits.Sub64(r[1], s[1], borrow) + r[2], borrow = bits.Sub64(r[2], s[2], borrow) + r[3], borrow = bits.Sub64(r[3], s[3], borrow) + + if borrow == 1 { + + // r = r + q + r[0], carry = bits.Add64(r[0], 4891460686036598785, 0) + r[1], carry = bits.Add64(r[1], 2896914383306846353, carry) + r[2], carry = bits.Add64(r[2], 13281191951274694749, carry) + r[3], _ = bits.Add64(r[3], 3486998266802970665, carry) + + } + } + if (u[0] == 1) && (u[3]|u[2]|u[1]) == 0 { + return z.Set(&r) + } + if (v[0] == 1) && (v[3]|v[2]|v[1]) == 0 { + return z.Set(&s) + } + } + +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element_mul_adx_amd64.s b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element_mul_adx_amd64.s new file mode 100644 index 00000000000..494e7bfd7e2 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element_mul_adx_amd64.s @@ -0,0 +1,466 @@ +// +build amd64_adx + +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +#include "textflag.h" +#include "funcdata.h" + +// modulus q +DATA q<>+0(SB)/8, $0x43e1f593f0000001 +DATA q<>+8(SB)/8, $0x2833e84879b97091 +DATA q<>+16(SB)/8, $0xb85045b68181585d +DATA q<>+24(SB)/8, $0x30644e72e131a029 +GLOBL q<>(SB), (RODATA+NOPTR), $32 + +// qInv0 q'[0] +DATA qInv0<>(SB)/8, $0xc2e1f593efffffff +GLOBL qInv0<>(SB), (RODATA+NOPTR), $8 + +#define REDUCE(ra0, ra1, ra2, ra3, rb0, rb1, rb2, rb3) \ + MOVQ ra0, rb0; \ + SUBQ q<>(SB), ra0; \ + MOVQ ra1, rb1; \ + SBBQ q<>+8(SB), ra1; \ + MOVQ ra2, rb2; \ + SBBQ q<>+16(SB), ra2; \ + MOVQ ra3, rb3; \ + SBBQ q<>+24(SB), ra3; \ + CMOVQCS rb0, ra0; \ + CMOVQCS rb1, ra1; \ + CMOVQCS rb2, ra2; \ + CMOVQCS rb3, ra3; \ + +// mul(res, x, y *Element) +TEXT ·mul(SB), NOSPLIT, $0-24 + + // the algorithm is described here + // https://hackmd.io/@zkteam/modular_multiplication + // however, to benefit from the ADCX and ADOX carry chains + // we split the inner loops in 2: + // for i=0 to N-1 + // for j=0 to N-1 + // (A,t[j]) := t[j] + x[j]*y[i] + A + // m := t[0]*q'[0] mod W + // C,_ := t[0] + m*q[0] + // for j=1 to N-1 + // (C,t[j-1]) := t[j] + m*q[j] + C + // t[N-1] = C + A + + MOVQ x+8(FP), SI + + // x[0] -> DI + // x[1] -> R8 + // x[2] -> R9 + // x[3] -> R10 + MOVQ 0(SI), DI + MOVQ 8(SI), R8 + MOVQ 16(SI), R9 + MOVQ 24(SI), R10 + MOVQ y+16(FP), R11 + + // A -> BP + // t[0] -> R14 + // t[1] -> R15 + // t[2] -> CX + // t[3] -> BX + // clear the flags + XORQ AX, AX + MOVQ 0(R11), DX + + // (A,t[0]) := x[0]*y[0] + A + MULXQ DI, R14, R15 + + // (A,t[1]) := x[1]*y[0] + A + MULXQ R8, AX, CX + ADOXQ AX, R15 + + // (A,t[2]) := x[2]*y[0] + A + MULXQ R9, AX, BX + ADOXQ AX, CX + + // (A,t[3]) := x[3]*y[0] + A + MULXQ R10, AX, BP + ADOXQ AX, BX + + // A += carries from ADCXQ and ADOXQ + MOVQ $0, AX + ADOXQ AX, BP + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + + // clear the flags + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, R12 + ADCXQ R14, AX + MOVQ R12, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + + // t[3] = C + A + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ BP, BX + + // clear the flags + XORQ AX, AX + MOVQ 8(R11), DX + + // (A,t[0]) := t[0] + x[0]*y[1] + A + MULXQ DI, AX, BP + ADOXQ AX, R14 + + // (A,t[1]) := t[1] + x[1]*y[1] + A + ADCXQ BP, R15 + MULXQ R8, AX, BP + ADOXQ AX, R15 + + // (A,t[2]) := t[2] + x[2]*y[1] + A + ADCXQ BP, CX + MULXQ R9, AX, BP + ADOXQ AX, CX + + // (A,t[3]) := t[3] + x[3]*y[1] + A + ADCXQ BP, BX + MULXQ R10, AX, BP + ADOXQ AX, BX + + // A += carries from ADCXQ and ADOXQ + MOVQ $0, AX + ADCXQ AX, BP + ADOXQ AX, BP + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + + // clear the flags + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, R12 + ADCXQ R14, AX + MOVQ R12, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + + // t[3] = C + A + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ BP, BX + + // clear the flags + XORQ AX, AX + MOVQ 16(R11), DX + + // (A,t[0]) := t[0] + x[0]*y[2] + A + MULXQ DI, AX, BP + ADOXQ AX, R14 + + // (A,t[1]) := t[1] + x[1]*y[2] + A + ADCXQ BP, R15 + MULXQ R8, AX, BP + ADOXQ AX, R15 + + // (A,t[2]) := t[2] + x[2]*y[2] + A + ADCXQ BP, CX + MULXQ R9, AX, BP + ADOXQ AX, CX + + // (A,t[3]) := t[3] + x[3]*y[2] + A + ADCXQ BP, BX + MULXQ R10, AX, BP + ADOXQ AX, BX + + // A += carries from ADCXQ and ADOXQ + MOVQ $0, AX + ADCXQ AX, BP + ADOXQ AX, BP + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + + // clear the flags + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, R12 + ADCXQ R14, AX + MOVQ R12, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + + // t[3] = C + A + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ BP, BX + + // clear the flags + XORQ AX, AX + MOVQ 24(R11), DX + + // (A,t[0]) := t[0] + x[0]*y[3] + A + MULXQ DI, AX, BP + ADOXQ AX, R14 + + // (A,t[1]) := t[1] + x[1]*y[3] + A + ADCXQ BP, R15 + MULXQ R8, AX, BP + ADOXQ AX, R15 + + // (A,t[2]) := t[2] + x[2]*y[3] + A + ADCXQ BP, CX + MULXQ R9, AX, BP + ADOXQ AX, CX + + // (A,t[3]) := t[3] + x[3]*y[3] + A + ADCXQ BP, BX + MULXQ R10, AX, BP + ADOXQ AX, BX + + // A += carries from ADCXQ and ADOXQ + MOVQ $0, AX + ADCXQ AX, BP + ADOXQ AX, BP + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + + // clear the flags + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, R12 + ADCXQ R14, AX + MOVQ R12, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + + // t[3] = C + A + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ BP, BX + + // reduce element(R14,R15,CX,BX) using temp registers (R13,SI,R12,R11) + REDUCE(R14,R15,CX,BX,R13,SI,R12,R11) + + MOVQ res+0(FP), AX + MOVQ R14, 0(AX) + MOVQ R15, 8(AX) + MOVQ CX, 16(AX) + MOVQ BX, 24(AX) + RET + +TEXT ·fromMont(SB), NOSPLIT, $0-8 + + // the algorithm is described here + // https://hackmd.io/@zkteam/modular_multiplication + // when y = 1 we have: + // for i=0 to N-1 + // t[i] = x[i] + // for i=0 to N-1 + // m := t[0]*q'[0] mod W + // C,_ := t[0] + m*q[0] + // for j=1 to N-1 + // (C,t[j-1]) := t[j] + m*q[j] + C + // t[N-1] = C + MOVQ res+0(FP), DX + MOVQ 0(DX), R14 + MOVQ 8(DX), R15 + MOVQ 16(DX), CX + MOVQ 24(DX), BX + XORQ DX, DX + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, BP + ADCXQ R14, AX + MOVQ BP, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ AX, BX + XORQ DX, DX + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, BP + ADCXQ R14, AX + MOVQ BP, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ AX, BX + XORQ DX, DX + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, BP + ADCXQ R14, AX + MOVQ BP, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ AX, BX + XORQ DX, DX + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, BP + ADCXQ R14, AX + MOVQ BP, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ AX, BX + + // reduce element(R14,R15,CX,BX) using temp registers (SI,DI,R8,R9) + REDUCE(R14,R15,CX,BX,SI,DI,R8,R9) + + MOVQ res+0(FP), AX + MOVQ R14, 0(AX) + MOVQ R15, 8(AX) + MOVQ CX, 16(AX) + MOVQ BX, 24(AX) + RET diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element_mul_amd64.s b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element_mul_amd64.s new file mode 100644 index 00000000000..38b3b6cf629 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element_mul_amd64.s @@ -0,0 +1,488 @@ +// +build !amd64_adx + +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +#include "textflag.h" +#include "funcdata.h" + +// modulus q +DATA q<>+0(SB)/8, $0x43e1f593f0000001 +DATA q<>+8(SB)/8, $0x2833e84879b97091 +DATA q<>+16(SB)/8, $0xb85045b68181585d +DATA q<>+24(SB)/8, $0x30644e72e131a029 +GLOBL q<>(SB), (RODATA+NOPTR), $32 + +// qInv0 q'[0] +DATA qInv0<>(SB)/8, $0xc2e1f593efffffff +GLOBL qInv0<>(SB), (RODATA+NOPTR), $8 + +#define REDUCE(ra0, ra1, ra2, ra3, rb0, rb1, rb2, rb3) \ + MOVQ ra0, rb0; \ + SUBQ q<>(SB), ra0; \ + MOVQ ra1, rb1; \ + SBBQ q<>+8(SB), ra1; \ + MOVQ ra2, rb2; \ + SBBQ q<>+16(SB), ra2; \ + MOVQ ra3, rb3; \ + SBBQ q<>+24(SB), ra3; \ + CMOVQCS rb0, ra0; \ + CMOVQCS rb1, ra1; \ + CMOVQCS rb2, ra2; \ + CMOVQCS rb3, ra3; \ + +// mul(res, x, y *Element) +TEXT ·mul(SB), $24-24 + + // the algorithm is described here + // https://hackmd.io/@zkteam/modular_multiplication + // however, to benefit from the ADCX and ADOX carry chains + // we split the inner loops in 2: + // for i=0 to N-1 + // for j=0 to N-1 + // (A,t[j]) := t[j] + x[j]*y[i] + A + // m := t[0]*q'[0] mod W + // C,_ := t[0] + m*q[0] + // for j=1 to N-1 + // (C,t[j-1]) := t[j] + m*q[j] + C + // t[N-1] = C + A + + NO_LOCAL_POINTERS + CMPB ·supportAdx(SB), $1 + JNE l1 + MOVQ x+8(FP), SI + + // x[0] -> DI + // x[1] -> R8 + // x[2] -> R9 + // x[3] -> R10 + MOVQ 0(SI), DI + MOVQ 8(SI), R8 + MOVQ 16(SI), R9 + MOVQ 24(SI), R10 + MOVQ y+16(FP), R11 + + // A -> BP + // t[0] -> R14 + // t[1] -> R15 + // t[2] -> CX + // t[3] -> BX + // clear the flags + XORQ AX, AX + MOVQ 0(R11), DX + + // (A,t[0]) := x[0]*y[0] + A + MULXQ DI, R14, R15 + + // (A,t[1]) := x[1]*y[0] + A + MULXQ R8, AX, CX + ADOXQ AX, R15 + + // (A,t[2]) := x[2]*y[0] + A + MULXQ R9, AX, BX + ADOXQ AX, CX + + // (A,t[3]) := x[3]*y[0] + A + MULXQ R10, AX, BP + ADOXQ AX, BX + + // A += carries from ADCXQ and ADOXQ + MOVQ $0, AX + ADOXQ AX, BP + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + + // clear the flags + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, R12 + ADCXQ R14, AX + MOVQ R12, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + + // t[3] = C + A + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ BP, BX + + // clear the flags + XORQ AX, AX + MOVQ 8(R11), DX + + // (A,t[0]) := t[0] + x[0]*y[1] + A + MULXQ DI, AX, BP + ADOXQ AX, R14 + + // (A,t[1]) := t[1] + x[1]*y[1] + A + ADCXQ BP, R15 + MULXQ R8, AX, BP + ADOXQ AX, R15 + + // (A,t[2]) := t[2] + x[2]*y[1] + A + ADCXQ BP, CX + MULXQ R9, AX, BP + ADOXQ AX, CX + + // (A,t[3]) := t[3] + x[3]*y[1] + A + ADCXQ BP, BX + MULXQ R10, AX, BP + ADOXQ AX, BX + + // A += carries from ADCXQ and ADOXQ + MOVQ $0, AX + ADCXQ AX, BP + ADOXQ AX, BP + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + + // clear the flags + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, R12 + ADCXQ R14, AX + MOVQ R12, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + + // t[3] = C + A + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ BP, BX + + // clear the flags + XORQ AX, AX + MOVQ 16(R11), DX + + // (A,t[0]) := t[0] + x[0]*y[2] + A + MULXQ DI, AX, BP + ADOXQ AX, R14 + + // (A,t[1]) := t[1] + x[1]*y[2] + A + ADCXQ BP, R15 + MULXQ R8, AX, BP + ADOXQ AX, R15 + + // (A,t[2]) := t[2] + x[2]*y[2] + A + ADCXQ BP, CX + MULXQ R9, AX, BP + ADOXQ AX, CX + + // (A,t[3]) := t[3] + x[3]*y[2] + A + ADCXQ BP, BX + MULXQ R10, AX, BP + ADOXQ AX, BX + + // A += carries from ADCXQ and ADOXQ + MOVQ $0, AX + ADCXQ AX, BP + ADOXQ AX, BP + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + + // clear the flags + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, R12 + ADCXQ R14, AX + MOVQ R12, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + + // t[3] = C + A + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ BP, BX + + // clear the flags + XORQ AX, AX + MOVQ 24(R11), DX + + // (A,t[0]) := t[0] + x[0]*y[3] + A + MULXQ DI, AX, BP + ADOXQ AX, R14 + + // (A,t[1]) := t[1] + x[1]*y[3] + A + ADCXQ BP, R15 + MULXQ R8, AX, BP + ADOXQ AX, R15 + + // (A,t[2]) := t[2] + x[2]*y[3] + A + ADCXQ BP, CX + MULXQ R9, AX, BP + ADOXQ AX, CX + + // (A,t[3]) := t[3] + x[3]*y[3] + A + ADCXQ BP, BX + MULXQ R10, AX, BP + ADOXQ AX, BX + + // A += carries from ADCXQ and ADOXQ + MOVQ $0, AX + ADCXQ AX, BP + ADOXQ AX, BP + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + + // clear the flags + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, R12 + ADCXQ R14, AX + MOVQ R12, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + + // t[3] = C + A + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ BP, BX + + // reduce element(R14,R15,CX,BX) using temp registers (R13,SI,R12,R11) + REDUCE(R14,R15,CX,BX,R13,SI,R12,R11) + + MOVQ res+0(FP), AX + MOVQ R14, 0(AX) + MOVQ R15, 8(AX) + MOVQ CX, 16(AX) + MOVQ BX, 24(AX) + RET + +l1: + MOVQ res+0(FP), AX + MOVQ AX, (SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·_mulGeneric(SB) + RET + +TEXT ·fromMont(SB), $8-8 + NO_LOCAL_POINTERS + + // the algorithm is described here + // https://hackmd.io/@zkteam/modular_multiplication + // when y = 1 we have: + // for i=0 to N-1 + // t[i] = x[i] + // for i=0 to N-1 + // m := t[0]*q'[0] mod W + // C,_ := t[0] + m*q[0] + // for j=1 to N-1 + // (C,t[j-1]) := t[j] + m*q[j] + C + // t[N-1] = C + CMPB ·supportAdx(SB), $1 + JNE l2 + MOVQ res+0(FP), DX + MOVQ 0(DX), R14 + MOVQ 8(DX), R15 + MOVQ 16(DX), CX + MOVQ 24(DX), BX + XORQ DX, DX + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, BP + ADCXQ R14, AX + MOVQ BP, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ AX, BX + XORQ DX, DX + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, BP + ADCXQ R14, AX + MOVQ BP, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ AX, BX + XORQ DX, DX + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, BP + ADCXQ R14, AX + MOVQ BP, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ AX, BX + XORQ DX, DX + + // m := t[0]*q'[0] mod W + MOVQ qInv0<>(SB), DX + IMULQ R14, DX + XORQ AX, AX + + // C,_ := t[0] + m*q[0] + MULXQ q<>+0(SB), AX, BP + ADCXQ R14, AX + MOVQ BP, R14 + + // (C,t[0]) := t[1] + m*q[1] + C + ADCXQ R15, R14 + MULXQ q<>+8(SB), AX, R15 + ADOXQ AX, R14 + + // (C,t[1]) := t[2] + m*q[2] + C + ADCXQ CX, R15 + MULXQ q<>+16(SB), AX, CX + ADOXQ AX, R15 + + // (C,t[2]) := t[3] + m*q[3] + C + ADCXQ BX, CX + MULXQ q<>+24(SB), AX, BX + ADOXQ AX, CX + MOVQ $0, AX + ADCXQ AX, BX + ADOXQ AX, BX + + // reduce element(R14,R15,CX,BX) using temp registers (SI,DI,R8,R9) + REDUCE(R14,R15,CX,BX,SI,DI,R8,R9) + + MOVQ res+0(FP), AX + MOVQ R14, 0(AX) + MOVQ R15, 8(AX) + MOVQ CX, 16(AX) + MOVQ BX, 24(AX) + RET + +l2: + MOVQ res+0(FP), AX + MOVQ AX, (SP) + CALL ·_fromMontGeneric(SB) + RET diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element_ops_amd64.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element_ops_amd64.go new file mode 100644 index 00000000000..f0d8316e528 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element_ops_amd64.go @@ -0,0 +1,44 @@ +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package fr + +//go:noescape +func MulBy3(x *Element) + +//go:noescape +func MulBy5(x *Element) + +//go:noescape +func add(res, x, y *Element) + +//go:noescape +func sub(res, x, y *Element) + +//go:noescape +func neg(res, x *Element) + +//go:noescape +func double(res, x *Element) + +//go:noescape +func mul(res, x, y *Element) + +//go:noescape +func fromMont(res *Element) + +//go:noescape +func reduce(res *Element) diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element_ops_amd64.s b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element_ops_amd64.s new file mode 100644 index 00000000000..83133a8f5eb --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element_ops_amd64.s @@ -0,0 +1,235 @@ +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +#include "textflag.h" +#include "funcdata.h" + +// modulus q +DATA q<>+0(SB)/8, $0x43e1f593f0000001 +DATA q<>+8(SB)/8, $0x2833e84879b97091 +DATA q<>+16(SB)/8, $0xb85045b68181585d +DATA q<>+24(SB)/8, $0x30644e72e131a029 +GLOBL q<>(SB), (RODATA+NOPTR), $32 + +// qInv0 q'[0] +DATA qInv0<>(SB)/8, $0xc2e1f593efffffff +GLOBL qInv0<>(SB), (RODATA+NOPTR), $8 + +#define REDUCE(ra0, ra1, ra2, ra3, rb0, rb1, rb2, rb3) \ + MOVQ ra0, rb0; \ + SUBQ q<>(SB), ra0; \ + MOVQ ra1, rb1; \ + SBBQ q<>+8(SB), ra1; \ + MOVQ ra2, rb2; \ + SBBQ q<>+16(SB), ra2; \ + MOVQ ra3, rb3; \ + SBBQ q<>+24(SB), ra3; \ + CMOVQCS rb0, ra0; \ + CMOVQCS rb1, ra1; \ + CMOVQCS rb2, ra2; \ + CMOVQCS rb3, ra3; \ + +// add(res, x, y *Element) +TEXT ·add(SB), NOSPLIT, $0-24 + MOVQ x+8(FP), AX + MOVQ 0(AX), CX + MOVQ 8(AX), BX + MOVQ 16(AX), SI + MOVQ 24(AX), DI + MOVQ y+16(FP), DX + ADDQ 0(DX), CX + ADCQ 8(DX), BX + ADCQ 16(DX), SI + ADCQ 24(DX), DI + + // reduce element(CX,BX,SI,DI) using temp registers (R8,R9,R10,R11) + REDUCE(CX,BX,SI,DI,R8,R9,R10,R11) + + MOVQ res+0(FP), R12 + MOVQ CX, 0(R12) + MOVQ BX, 8(R12) + MOVQ SI, 16(R12) + MOVQ DI, 24(R12) + RET + +// sub(res, x, y *Element) +TEXT ·sub(SB), NOSPLIT, $0-24 + XORQ DI, DI + MOVQ x+8(FP), SI + MOVQ 0(SI), AX + MOVQ 8(SI), DX + MOVQ 16(SI), CX + MOVQ 24(SI), BX + MOVQ y+16(FP), SI + SUBQ 0(SI), AX + SBBQ 8(SI), DX + SBBQ 16(SI), CX + SBBQ 24(SI), BX + MOVQ $0x43e1f593f0000001, R8 + MOVQ $0x2833e84879b97091, R9 + MOVQ $0xb85045b68181585d, R10 + MOVQ $0x30644e72e131a029, R11 + CMOVQCC DI, R8 + CMOVQCC DI, R9 + CMOVQCC DI, R10 + CMOVQCC DI, R11 + ADDQ R8, AX + ADCQ R9, DX + ADCQ R10, CX + ADCQ R11, BX + MOVQ res+0(FP), R12 + MOVQ AX, 0(R12) + MOVQ DX, 8(R12) + MOVQ CX, 16(R12) + MOVQ BX, 24(R12) + RET + +// double(res, x *Element) +TEXT ·double(SB), NOSPLIT, $0-16 + MOVQ x+8(FP), AX + MOVQ 0(AX), DX + MOVQ 8(AX), CX + MOVQ 16(AX), BX + MOVQ 24(AX), SI + ADDQ DX, DX + ADCQ CX, CX + ADCQ BX, BX + ADCQ SI, SI + + // reduce element(DX,CX,BX,SI) using temp registers (DI,R8,R9,R10) + REDUCE(DX,CX,BX,SI,DI,R8,R9,R10) + + MOVQ res+0(FP), R11 + MOVQ DX, 0(R11) + MOVQ CX, 8(R11) + MOVQ BX, 16(R11) + MOVQ SI, 24(R11) + RET + +// neg(res, x *Element) +TEXT ·neg(SB), NOSPLIT, $0-16 + MOVQ res+0(FP), DI + MOVQ x+8(FP), AX + MOVQ 0(AX), DX + MOVQ 8(AX), CX + MOVQ 16(AX), BX + MOVQ 24(AX), SI + MOVQ DX, AX + ORQ CX, AX + ORQ BX, AX + ORQ SI, AX + TESTQ AX, AX + JEQ l1 + MOVQ $0x43e1f593f0000001, R8 + SUBQ DX, R8 + MOVQ R8, 0(DI) + MOVQ $0x2833e84879b97091, R8 + SBBQ CX, R8 + MOVQ R8, 8(DI) + MOVQ $0xb85045b68181585d, R8 + SBBQ BX, R8 + MOVQ R8, 16(DI) + MOVQ $0x30644e72e131a029, R8 + SBBQ SI, R8 + MOVQ R8, 24(DI) + RET + +l1: + MOVQ AX, 0(DI) + MOVQ AX, 8(DI) + MOVQ AX, 16(DI) + MOVQ AX, 24(DI) + RET + +TEXT ·reduce(SB), NOSPLIT, $0-8 + MOVQ res+0(FP), AX + MOVQ 0(AX), DX + MOVQ 8(AX), CX + MOVQ 16(AX), BX + MOVQ 24(AX), SI + + // reduce element(DX,CX,BX,SI) using temp registers (DI,R8,R9,R10) + REDUCE(DX,CX,BX,SI,DI,R8,R9,R10) + + MOVQ DX, 0(AX) + MOVQ CX, 8(AX) + MOVQ BX, 16(AX) + MOVQ SI, 24(AX) + RET + +// MulBy3(x *Element) +TEXT ·MulBy3(SB), NOSPLIT, $0-8 + MOVQ x+0(FP), AX + MOVQ 0(AX), DX + MOVQ 8(AX), CX + MOVQ 16(AX), BX + MOVQ 24(AX), SI + ADDQ DX, DX + ADCQ CX, CX + ADCQ BX, BX + ADCQ SI, SI + + // reduce element(DX,CX,BX,SI) using temp registers (DI,R8,R9,R10) + REDUCE(DX,CX,BX,SI,DI,R8,R9,R10) + + ADDQ 0(AX), DX + ADCQ 8(AX), CX + ADCQ 16(AX), BX + ADCQ 24(AX), SI + + // reduce element(DX,CX,BX,SI) using temp registers (R11,R12,R13,R14) + REDUCE(DX,CX,BX,SI,R11,R12,R13,R14) + + MOVQ DX, 0(AX) + MOVQ CX, 8(AX) + MOVQ BX, 16(AX) + MOVQ SI, 24(AX) + RET + +// MulBy5(x *Element) +TEXT ·MulBy5(SB), NOSPLIT, $0-8 + MOVQ x+0(FP), AX + MOVQ 0(AX), DX + MOVQ 8(AX), CX + MOVQ 16(AX), BX + MOVQ 24(AX), SI + ADDQ DX, DX + ADCQ CX, CX + ADCQ BX, BX + ADCQ SI, SI + + // reduce element(DX,CX,BX,SI) using temp registers (DI,R8,R9,R10) + REDUCE(DX,CX,BX,SI,DI,R8,R9,R10) + + ADDQ DX, DX + ADCQ CX, CX + ADCQ BX, BX + ADCQ SI, SI + + // reduce element(DX,CX,BX,SI) using temp registers (R11,R12,R13,R14) + REDUCE(DX,CX,BX,SI,R11,R12,R13,R14) + + ADDQ 0(AX), DX + ADCQ 8(AX), CX + ADCQ 16(AX), BX + ADCQ 24(AX), SI + + // reduce element(DX,CX,BX,SI) using temp registers (R15,DI,R8,R9) + REDUCE(DX,CX,BX,SI,R15,DI,R8,R9) + + MOVQ DX, 0(AX) + MOVQ CX, 8(AX) + MOVQ BX, 16(AX) + MOVQ SI, 24(AX) + RET diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element_ops_noasm.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element_ops_noasm.go new file mode 100644 index 00000000000..e7daa4d40ee --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/fr/element_ops_noasm.go @@ -0,0 +1,65 @@ +// +build !amd64 + +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package fr + +// /!\ WARNING /!\ +// this code has not been audited and is provided as-is. In particular, +// there is no security guarantees such as constant time implementation +// or side-channel attack resistance +// /!\ WARNING /!\ + +// MulBy3 x *= 3 +func MulBy3(x *Element) { + mulByConstant(x, 3) +} + +// MulBy5 x *= 5 +func MulBy5(x *Element) { + mulByConstant(x, 5) +} + +func mul(z, x, y *Element) { + _mulGeneric(z, x, y) +} + +// FromMont converts z in place (i.e. mutates) from Montgomery to regular representation +// sets and returns z = z * 1 +func fromMont(z *Element) { + _fromMontGeneric(z) +} + +func add(z, x, y *Element) { + _addGeneric(z, x, y) +} + +func double(z, x *Element) { + _doubleGeneric(z, x) +} + +func sub(z, x, y *Element) { + _subGeneric(z, x, y) +} + +func neg(z, x *Element) { + _negGeneric(z, x) +} + +func reduce(z *Element) { + _reduceGeneric(z) +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/g1.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/g1.go new file mode 100644 index 00000000000..787bdc0411e --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/g1.go @@ -0,0 +1,911 @@ +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package bn254 + +import ( + "math/big" + + "github.com/consensys/gnark-crypto/ecc" + "github.com/consensys/gnark-crypto/ecc/bn254/fp" + "github.com/consensys/gnark-crypto/ecc/bn254/fr" + "github.com/consensys/gnark-crypto/internal/parallel" +) + +// G1Affine point in affine coordinates +type G1Affine struct { + X, Y fp.Element +} + +// G1Jac is a point with fp.Element coordinates +type G1Jac struct { + X, Y, Z fp.Element +} + +// g1JacExtended parameterized jacobian coordinates (x=X/ZZ, y=Y/ZZZ, ZZ**3=ZZZ**2) +type g1JacExtended struct { + X, Y, ZZ, ZZZ fp.Element +} + +// ------------------------------------------------------------------------------------------------- +// Affine + +// Set sets p to the provided point +func (p *G1Affine) Set(a *G1Affine) *G1Affine { + p.X, p.Y = a.X, a.Y + return p +} + +// ScalarMultiplication computes and returns p = a*s +func (p *G1Affine) ScalarMultiplication(a *G1Affine, s *big.Int) *G1Affine { + var _p G1Jac + _p.FromAffine(a) + _p.mulGLV(&_p, s) + p.FromJacobian(&_p) + return p +} + +// Equal tests if two points (in Affine coordinates) are equal +func (p *G1Affine) Equal(a *G1Affine) bool { + return p.X.Equal(&a.X) && p.Y.Equal(&a.Y) +} + +// Neg computes -G +func (p *G1Affine) Neg(a *G1Affine) *G1Affine { + p.X = a.X + p.Y.Neg(&a.Y) + return p +} + +// FromJacobian rescale a point in Jacobian coord in z=1 plane +func (p *G1Affine) FromJacobian(p1 *G1Jac) *G1Affine { + + var a, b fp.Element + + if p1.Z.IsZero() { + p.X.SetZero() + p.Y.SetZero() + return p + } + + a.Inverse(&p1.Z) + b.Square(&a) + p.X.Mul(&p1.X, &b) + p.Y.Mul(&p1.Y, &b).Mul(&p.Y, &a) + + return p +} + +func (p *G1Affine) String() string { + var x, y fp.Element + x.Set(&p.X) + y.Set(&p.Y) + return "E([" + x.String() + "," + y.String() + "])," +} + +// IsInfinity checks if the point is infinity (in affine, it's encoded as (0,0)) +func (p *G1Affine) IsInfinity() bool { + return p.X.IsZero() && p.Y.IsZero() +} + +// IsOnCurve returns true if p in on the curve +func (p *G1Affine) IsOnCurve() bool { + var point G1Jac + point.FromAffine(p) + return point.IsOnCurve() // call this function to handle infinity point +} + +// IsInSubGroup returns true if p is in the correct subgroup, false otherwise +func (p *G1Affine) IsInSubGroup() bool { + var _p G1Jac + _p.FromAffine(p) + return _p.IsOnCurve() && _p.IsInSubGroup() +} + +// ------------------------------------------------------------------------------------------------- +// Jacobian + +// Set sets p to the provided point +func (p *G1Jac) Set(a *G1Jac) *G1Jac { + p.X, p.Y, p.Z = a.X, a.Y, a.Z + return p +} + +// Equal tests if two points (in Jacobian coordinates) are equal +func (p *G1Jac) Equal(a *G1Jac) bool { + + if p.Z.IsZero() && a.Z.IsZero() { + return true + } + _p := G1Affine{} + _p.FromJacobian(p) + + _a := G1Affine{} + _a.FromJacobian(a) + + return _p.X.Equal(&_a.X) && _p.Y.Equal(&_a.Y) +} + +// Neg computes -G +func (p *G1Jac) Neg(a *G1Jac) *G1Jac { + *p = *a + p.Y.Neg(&a.Y) + return p +} + +// SubAssign substracts two points on the curve +func (p *G1Jac) SubAssign(a *G1Jac) *G1Jac { + var tmp G1Jac + tmp.Set(a) + tmp.Y.Neg(&tmp.Y) + p.AddAssign(&tmp) + return p +} + +// AddAssign point addition in montgomery form +// https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#addition-add-2007-bl +func (p *G1Jac) AddAssign(a *G1Jac) *G1Jac { + + // p is infinity, return a + if p.Z.IsZero() { + p.Set(a) + return p + } + + // a is infinity, return p + if a.Z.IsZero() { + return p + } + + var Z1Z1, Z2Z2, U1, U2, S1, S2, H, I, J, r, V fp.Element + Z1Z1.Square(&a.Z) + Z2Z2.Square(&p.Z) + U1.Mul(&a.X, &Z2Z2) + U2.Mul(&p.X, &Z1Z1) + S1.Mul(&a.Y, &p.Z). + Mul(&S1, &Z2Z2) + S2.Mul(&p.Y, &a.Z). + Mul(&S2, &Z1Z1) + + // if p == a, we double instead + if U1.Equal(&U2) && S1.Equal(&S2) { + return p.DoubleAssign() + } + + H.Sub(&U2, &U1) + I.Double(&H). + Square(&I) + J.Mul(&H, &I) + r.Sub(&S2, &S1).Double(&r) + V.Mul(&U1, &I) + p.X.Square(&r). + Sub(&p.X, &J). + Sub(&p.X, &V). + Sub(&p.X, &V) + p.Y.Sub(&V, &p.X). + Mul(&p.Y, &r) + S1.Mul(&S1, &J).Double(&S1) + p.Y.Sub(&p.Y, &S1) + p.Z.Add(&p.Z, &a.Z) + p.Z.Square(&p.Z). + Sub(&p.Z, &Z1Z1). + Sub(&p.Z, &Z2Z2). + Mul(&p.Z, &H) + + return p +} + +// AddMixed point addition +// http://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#addition-madd-2007-bl +func (p *G1Jac) AddMixed(a *G1Affine) *G1Jac { + + //if a is infinity return p + if a.X.IsZero() && a.Y.IsZero() { + return p + } + // p is infinity, return a + if p.Z.IsZero() { + p.X = a.X + p.Y = a.Y + p.Z.SetOne() + return p + } + + var Z1Z1, U2, S2, H, HH, I, J, r, V fp.Element + Z1Z1.Square(&p.Z) + U2.Mul(&a.X, &Z1Z1) + S2.Mul(&a.Y, &p.Z). + Mul(&S2, &Z1Z1) + + // if p == a, we double instead + if U2.Equal(&p.X) && S2.Equal(&p.Y) { + return p.DoubleAssign() + } + + H.Sub(&U2, &p.X) + HH.Square(&H) + I.Double(&HH).Double(&I) + J.Mul(&H, &I) + r.Sub(&S2, &p.Y).Double(&r) + V.Mul(&p.X, &I) + p.X.Square(&r). + Sub(&p.X, &J). + Sub(&p.X, &V). + Sub(&p.X, &V) + J.Mul(&J, &p.Y).Double(&J) + p.Y.Sub(&V, &p.X). + Mul(&p.Y, &r) + p.Y.Sub(&p.Y, &J) + p.Z.Add(&p.Z, &H) + p.Z.Square(&p.Z). + Sub(&p.Z, &Z1Z1). + Sub(&p.Z, &HH) + + return p +} + +// Double doubles a point in Jacobian coordinates +// https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2007-bl +func (p *G1Jac) Double(q *G1Jac) *G1Jac { + p.Set(q) + p.DoubleAssign() + return p +} + +// DoubleAssign doubles a point in Jacobian coordinates +// https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2007-bl +func (p *G1Jac) DoubleAssign() *G1Jac { + + var XX, YY, YYYY, ZZ, S, M, T fp.Element + + XX.Square(&p.X) + YY.Square(&p.Y) + YYYY.Square(&YY) + ZZ.Square(&p.Z) + S.Add(&p.X, &YY) + S.Square(&S). + Sub(&S, &XX). + Sub(&S, &YYYY). + Double(&S) + M.Double(&XX).Add(&M, &XX) + p.Z.Add(&p.Z, &p.Y). + Square(&p.Z). + Sub(&p.Z, &YY). + Sub(&p.Z, &ZZ) + T.Square(&M) + p.X = T + T.Double(&S) + p.X.Sub(&p.X, &T) + p.Y.Sub(&S, &p.X). + Mul(&p.Y, &M) + YYYY.Double(&YYYY).Double(&YYYY).Double(&YYYY) + p.Y.Sub(&p.Y, &YYYY) + + return p +} + +// ScalarMultiplication computes and returns p = a*s +// see https://www.iacr.org/archive/crypto2001/21390189.pdf +func (p *G1Jac) ScalarMultiplication(a *G1Jac, s *big.Int) *G1Jac { + return p.mulGLV(a, s) +} + +func (p *G1Jac) String() string { + if p.Z.IsZero() { + return "O" + } + _p := G1Affine{} + _p.FromJacobian(p) + return "E([" + _p.X.String() + "," + _p.Y.String() + "])," +} + +// FromAffine sets p = Q, p in Jacboian, Q in affine +func (p *G1Jac) FromAffine(Q *G1Affine) *G1Jac { + if Q.X.IsZero() && Q.Y.IsZero() { + p.Z.SetZero() + p.X.SetOne() + p.Y.SetOne() + return p + } + p.Z.SetOne() + p.X.Set(&Q.X) + p.Y.Set(&Q.Y) + return p +} + +// IsOnCurve returns true if p in on the curve +func (p *G1Jac) IsOnCurve() bool { + var left, right, tmp fp.Element + left.Square(&p.Y) + right.Square(&p.X).Mul(&right, &p.X) + tmp.Square(&p.Z). + Square(&tmp). + Mul(&tmp, &p.Z). + Mul(&tmp, &p.Z). + Mul(&tmp, &bCurveCoeff) + right.Add(&right, &tmp) + return left.Equal(&right) +} + +// IsInSubGroup returns true if p is on the r-torsion, false otherwise. +// For bn curves, the r-torsion in E(Fp) is the full group, so we just check that +// the point is on the curve. +func (p *G1Jac) IsInSubGroup() bool { + + return p.IsOnCurve() + +} + +// mulWindowed 2-bits windowed exponentiation +func (p *G1Jac) mulWindowed(a *G1Jac, s *big.Int) *G1Jac { + + var res G1Jac + var ops [3]G1Jac + + res.Set(&g1Infinity) + ops[0].Set(a) + ops[1].Double(&ops[0]) + ops[2].Set(&ops[0]).AddAssign(&ops[1]) + + b := s.Bytes() + for i := range b { + w := b[i] + mask := byte(0xc0) + for j := 0; j < 4; j++ { + res.DoubleAssign().DoubleAssign() + c := (w & mask) >> (6 - 2*j) + if c != 0 { + res.AddAssign(&ops[c-1]) + } + mask = mask >> 2 + } + } + p.Set(&res) + + return p + +} + +// phi assigns p to phi(a) where phi: (x,y)->(ux,y), and returns p +func (p *G1Jac) phi(a *G1Jac) *G1Jac { + p.Set(a) + p.X.Mul(&p.X, &thirdRootOneG1) + return p +} + +// mulGLV performs scalar multiplication using GLV +// see https://www.iacr.org/archive/crypto2001/21390189.pdf +func (p *G1Jac) mulGLV(a *G1Jac, s *big.Int) *G1Jac { + + var table [15]G1Jac + var zero big.Int + var res G1Jac + var k1, k2 fr.Element + + res.Set(&g1Infinity) + + // table[b3b2b1b0-1] = b3b2*phi(a) + b1b0*a + table[0].Set(a) + table[3].phi(a) + + // split the scalar, modifies +-a, phi(a) accordingly + k := ecc.SplitScalar(s, &glvBasis) + + if k[0].Cmp(&zero) == -1 { + k[0].Neg(&k[0]) + table[0].Neg(&table[0]) + } + if k[1].Cmp(&zero) == -1 { + k[1].Neg(&k[1]) + table[3].Neg(&table[3]) + } + + // precompute table (2 bits sliding window) + // table[b3b2b1b0-1] = b3b2*phi(a) + b1b0*a if b3b2b1b0 != 0 + table[1].Double(&table[0]) + table[2].Set(&table[1]).AddAssign(&table[0]) + table[4].Set(&table[3]).AddAssign(&table[0]) + table[5].Set(&table[3]).AddAssign(&table[1]) + table[6].Set(&table[3]).AddAssign(&table[2]) + table[7].Double(&table[3]) + table[8].Set(&table[7]).AddAssign(&table[0]) + table[9].Set(&table[7]).AddAssign(&table[1]) + table[10].Set(&table[7]).AddAssign(&table[2]) + table[11].Set(&table[7]).AddAssign(&table[3]) + table[12].Set(&table[11]).AddAssign(&table[0]) + table[13].Set(&table[11]).AddAssign(&table[1]) + table[14].Set(&table[11]).AddAssign(&table[2]) + + // bounds on the lattice base vectors guarantee that k1, k2 are len(r)/2 bits long max + k1.SetBigInt(&k[0]).FromMont() + k2.SetBigInt(&k[1]).FromMont() + + // loop starts from len(k1)/2 due to the bounds + for i := len(k1)/2 - 1; i >= 0; i-- { + mask := uint64(3) << 62 + for j := 0; j < 32; j++ { + res.Double(&res).Double(&res) + b1 := (k1[i] & mask) >> (62 - 2*j) + b2 := (k2[i] & mask) >> (62 - 2*j) + if b1|b2 != 0 { + s := (b2<<2 | b1) + res.AddAssign(&table[s-1]) + } + mask = mask >> 2 + } + } + + p.Set(&res) + return p +} + +// ------------------------------------------------------------------------------------------------- +// Jacobian extended + +// Set sets p to the provided point +func (p *g1JacExtended) Set(a *g1JacExtended) *g1JacExtended { + p.X, p.Y, p.ZZ, p.ZZZ = a.X, a.Y, a.ZZ, a.ZZZ + return p +} + +// setInfinity sets p to O +func (p *g1JacExtended) setInfinity() *g1JacExtended { + p.X.SetOne() + p.Y.SetOne() + p.ZZ = fp.Element{} + p.ZZZ = fp.Element{} + return p +} + +// fromJacExtended sets Q in affine coords +func (p *G1Affine) fromJacExtended(Q *g1JacExtended) *G1Affine { + if Q.ZZ.IsZero() { + p.X = fp.Element{} + p.Y = fp.Element{} + return p + } + p.X.Inverse(&Q.ZZ).Mul(&p.X, &Q.X) + p.Y.Inverse(&Q.ZZZ).Mul(&p.Y, &Q.Y) + return p +} + +// fromJacExtended sets Q in Jacobian coords +func (p *G1Jac) fromJacExtended(Q *g1JacExtended) *G1Jac { + if Q.ZZ.IsZero() { + p.Set(&g1Infinity) + return p + } + p.X.Mul(&Q.ZZ, &Q.X).Mul(&p.X, &Q.ZZ) + p.Y.Mul(&Q.ZZZ, &Q.Y).Mul(&p.Y, &Q.ZZZ) + p.Z.Set(&Q.ZZZ) + return p +} + +// unsafeFromJacExtended sets p in jacobian coords, but don't check for infinity +func (p *G1Jac) unsafeFromJacExtended(Q *g1JacExtended) *G1Jac { + p.X.Square(&Q.ZZ).Mul(&p.X, &Q.X) + p.Y.Square(&Q.ZZZ).Mul(&p.Y, &Q.Y) + p.Z = Q.ZZZ + return p +} + +// add point in ZZ coords +// https://www.hyperelliptic.org/EFD/g1p/auto-shortw-xyzz.html#addition-add-2008-s +func (p *g1JacExtended) add(q *g1JacExtended) *g1JacExtended { + //if q is infinity return p + if q.ZZ.IsZero() { + return p + } + // p is infinity, return q + if p.ZZ.IsZero() { + p.Set(q) + return p + } + + var A, B, X1ZZ2, X2ZZ1, Y1ZZZ2, Y2ZZZ1 fp.Element + + // p2: q, p1: p + X2ZZ1.Mul(&q.X, &p.ZZ) + X1ZZ2.Mul(&p.X, &q.ZZ) + A.Sub(&X2ZZ1, &X1ZZ2) + Y2ZZZ1.Mul(&q.Y, &p.ZZZ) + Y1ZZZ2.Mul(&p.Y, &q.ZZZ) + B.Sub(&Y2ZZZ1, &Y1ZZZ2) + + if A.IsZero() { + if B.IsZero() { + return p.double(q) + + } + p.ZZ = fp.Element{} + p.ZZZ = fp.Element{} + return p + } + + var U1, U2, S1, S2, P, R, PP, PPP, Q, V fp.Element + U1.Mul(&p.X, &q.ZZ) + U2.Mul(&q.X, &p.ZZ) + S1.Mul(&p.Y, &q.ZZZ) + S2.Mul(&q.Y, &p.ZZZ) + P.Sub(&U2, &U1) + R.Sub(&S2, &S1) + PP.Square(&P) + PPP.Mul(&P, &PP) + Q.Mul(&U1, &PP) + V.Mul(&S1, &PPP) + + p.X.Square(&R). + Sub(&p.X, &PPP). + Sub(&p.X, &Q). + Sub(&p.X, &Q) + p.Y.Sub(&Q, &p.X). + Mul(&p.Y, &R). + Sub(&p.Y, &V) + p.ZZ.Mul(&p.ZZ, &q.ZZ). + Mul(&p.ZZ, &PP) + p.ZZZ.Mul(&p.ZZZ, &q.ZZZ). + Mul(&p.ZZZ, &PPP) + + return p +} + +// double point in ZZ coords +// http://www.hyperelliptic.org/EFD/g1p/auto-shortw-xyzz.html#doubling-dbl-2008-s-1 +func (p *g1JacExtended) double(q *g1JacExtended) *g1JacExtended { + var U, V, W, S, XX, M fp.Element + + U.Double(&q.Y) + V.Square(&U) + W.Mul(&U, &V) + S.Mul(&q.X, &V) + XX.Square(&q.X) + M.Double(&XX). + Add(&M, &XX) // -> + a, but a=0 here + U.Mul(&W, &q.Y) + + p.X.Square(&M). + Sub(&p.X, &S). + Sub(&p.X, &S) + p.Y.Sub(&S, &p.X). + Mul(&p.Y, &M). + Sub(&p.Y, &U) + p.ZZ.Mul(&V, &q.ZZ) + p.ZZZ.Mul(&W, &q.ZZZ) + + return p +} + +// subMixed same as addMixed, but will negate a.Y +// http://www.hyperelliptic.org/EFD/g1p/auto-shortw-xyzz.html#addition-madd-2008-s +func (p *g1JacExtended) subMixed(a *G1Affine) *g1JacExtended { + + //if a is infinity return p + if a.X.IsZero() && a.Y.IsZero() { + return p + } + // p is infinity, return a + if p.ZZ.IsZero() { + p.X = a.X + p.Y.Neg(&a.Y) + p.ZZ.SetOne() + p.ZZZ.SetOne() + return p + } + + var P, R fp.Element + + // p2: a, p1: p + P.Mul(&a.X, &p.ZZ) + P.Sub(&P, &p.X) + + R.Mul(&a.Y, &p.ZZZ) + R.Neg(&R) + R.Sub(&R, &p.Y) + + if P.IsZero() { + if R.IsZero() { + return p.doubleNegMixed(a) + + } + p.ZZ = fp.Element{} + p.ZZZ = fp.Element{} + return p + } + + var PP, PPP, Q, Q2, RR, X3, Y3 fp.Element + + PP.Square(&P) + PPP.Mul(&P, &PP) + Q.Mul(&p.X, &PP) + RR.Square(&R) + X3.Sub(&RR, &PPP) + Q2.Double(&Q) + p.X.Sub(&X3, &Q2) + Y3.Sub(&Q, &p.X).Mul(&Y3, &R) + R.Mul(&p.Y, &PPP) + p.Y.Sub(&Y3, &R) + p.ZZ.Mul(&p.ZZ, &PP) + p.ZZZ.Mul(&p.ZZZ, &PPP) + + return p + +} + +// addMixed +// http://www.hyperelliptic.org/EFD/g1p/auto-shortw-xyzz.html#addition-madd-2008-s +func (p *g1JacExtended) addMixed(a *G1Affine) *g1JacExtended { + + //if a is infinity return p + if a.X.IsZero() && a.Y.IsZero() { + return p + } + // p is infinity, return a + if p.ZZ.IsZero() { + p.X = a.X + p.Y = a.Y + p.ZZ.SetOne() + p.ZZZ.SetOne() + return p + } + + var P, R fp.Element + + // p2: a, p1: p + P.Mul(&a.X, &p.ZZ) + P.Sub(&P, &p.X) + + R.Mul(&a.Y, &p.ZZZ) + R.Sub(&R, &p.Y) + + if P.IsZero() { + if R.IsZero() { + return p.doubleMixed(a) + + } + p.ZZ = fp.Element{} + p.ZZZ = fp.Element{} + return p + } + + var PP, PPP, Q, Q2, RR, X3, Y3 fp.Element + + PP.Square(&P) + PPP.Mul(&P, &PP) + Q.Mul(&p.X, &PP) + RR.Square(&R) + X3.Sub(&RR, &PPP) + Q2.Double(&Q) + p.X.Sub(&X3, &Q2) + Y3.Sub(&Q, &p.X).Mul(&Y3, &R) + R.Mul(&p.Y, &PPP) + p.Y.Sub(&Y3, &R) + p.ZZ.Mul(&p.ZZ, &PP) + p.ZZZ.Mul(&p.ZZZ, &PPP) + + return p + +} + +// doubleNegMixed same as double, but will negate q.Y +func (p *g1JacExtended) doubleNegMixed(q *G1Affine) *g1JacExtended { + + var U, V, W, S, XX, M, S2, L fp.Element + + U.Double(&q.Y) + U.Neg(&U) + V.Square(&U) + W.Mul(&U, &V) + S.Mul(&q.X, &V) + XX.Square(&q.X) + M.Double(&XX). + Add(&M, &XX) // -> + a, but a=0 here + S2.Double(&S) + L.Mul(&W, &q.Y) + + p.X.Square(&M). + Sub(&p.X, &S2) + p.Y.Sub(&S, &p.X). + Mul(&p.Y, &M). + Add(&p.Y, &L) + p.ZZ.Set(&V) + p.ZZZ.Set(&W) + + return p +} + +// doubleMixed point in ZZ coords +// http://www.hyperelliptic.org/EFD/g1p/auto-shortw-xyzz.html#doubling-dbl-2008-s-1 +func (p *g1JacExtended) doubleMixed(q *G1Affine) *g1JacExtended { + + var U, V, W, S, XX, M, S2, L fp.Element + + U.Double(&q.Y) + V.Square(&U) + W.Mul(&U, &V) + S.Mul(&q.X, &V) + XX.Square(&q.X) + M.Double(&XX). + Add(&M, &XX) // -> + a, but a=0 here + S2.Double(&S) + L.Mul(&W, &q.Y) + + p.X.Square(&M). + Sub(&p.X, &S2) + p.Y.Sub(&S, &p.X). + Mul(&p.Y, &M). + Sub(&p.Y, &L) + p.ZZ.Set(&V) + p.ZZZ.Set(&W) + + return p +} + +// BatchJacobianToAffineG1Affine converts points in Jacobian coordinates to Affine coordinates +// performing a single field inversion (Montgomery batch inversion trick) +// result must be allocated with len(result) == len(points) +func BatchJacobianToAffineG1Affine(points []G1Jac, result []G1Affine) { + zeroes := make([]bool, len(points)) + accumulator := fp.One() + + // batch invert all points[].Z coordinates with Montgomery batch inversion trick + // (stores points[].Z^-1 in result[i].X to avoid allocating a slice of fr.Elements) + for i := 0; i < len(points); i++ { + if points[i].Z.IsZero() { + zeroes[i] = true + continue + } + result[i].X = accumulator + accumulator.Mul(&accumulator, &points[i].Z) + } + + var accInverse fp.Element + accInverse.Inverse(&accumulator) + + for i := len(points) - 1; i >= 0; i-- { + if zeroes[i] { + // do nothing, X and Y are zeroes in affine. + continue + } + result[i].X.Mul(&result[i].X, &accInverse) + accInverse.Mul(&accInverse, &points[i].Z) + } + + // batch convert to affine. + parallel.Execute(len(points), func(start, end int) { + for i := start; i < end; i++ { + if zeroes[i] { + // do nothing, X and Y are zeroes in affine. + continue + } + var a, b fp.Element + a = result[i].X + b.Square(&a) + result[i].X.Mul(&points[i].X, &b) + result[i].Y.Mul(&points[i].Y, &b). + Mul(&result[i].Y, &a) + } + }) + +} + +// BatchScalarMultiplicationG1 multiplies the same base (generator) by all scalars +// and return resulting points in affine coordinates +// uses a simple windowed-NAF like exponentiation algorithm +func BatchScalarMultiplicationG1(base *G1Affine, scalars []fr.Element) []G1Affine { + + // approximate cost in group ops is + // cost = 2^{c-1} + n(scalar.nbBits+nbChunks) + + nbPoints := uint64(len(scalars)) + min := ^uint64(0) + bestC := 0 + for c := 2; c < 18; c++ { + cost := uint64(1 << (c - 1)) + nbChunks := uint64(fr.Limbs * 64 / c) + if (fr.Limbs*64)%c != 0 { + nbChunks++ + } + cost += nbPoints * ((fr.Limbs * 64) + nbChunks) + if cost < min { + min = cost + bestC = c + } + } + c := uint64(bestC) // window size + nbChunks := int(fr.Limbs * 64 / c) + if (fr.Limbs*64)%c != 0 { + nbChunks++ + } + mask := uint64((1 << c) - 1) // low c bits are 1 + msbWindow := uint64(1 << (c - 1)) + + // precompute all powers of base for our window + // note here that if performance is critical, we can implement as in the msmX methods + // this allocation to be on the stack + baseTable := make([]G1Jac, (1 << (c - 1))) + baseTable[0].Set(&g1Infinity) + baseTable[0].AddMixed(base) + for i := 1; i < len(baseTable); i++ { + baseTable[i] = baseTable[i-1] + baseTable[i].AddMixed(base) + } + + pScalars := partitionScalars(scalars, c) + + // compute offset and word selector / shift to select the right bits of our windows + selectors := make([]selector, nbChunks) + for chunk := 0; chunk < nbChunks; chunk++ { + jc := uint64(uint64(chunk) * c) + d := selector{} + d.index = jc / 64 + d.shift = jc - (d.index * 64) + d.mask = mask << d.shift + d.multiWordSelect = (64%c) != 0 && d.shift > (64-c) && d.index < (fr.Limbs-1) + if d.multiWordSelect { + nbBitsHigh := d.shift - uint64(64-c) + d.maskHigh = (1 << nbBitsHigh) - 1 + d.shiftHigh = (c - nbBitsHigh) + } + selectors[chunk] = d + } + // convert our base exp table into affine to use AddMixed + baseTableAff := make([]G1Affine, (1 << (c - 1))) + BatchJacobianToAffineG1Affine(baseTable, baseTableAff) + toReturn := make([]G1Jac, len(scalars)) + + // for each digit, take value in the base table, double it c time, voila. + parallel.Execute(len(pScalars), func(start, end int) { + var p G1Jac + for i := start; i < end; i++ { + p.Set(&g1Infinity) + for chunk := nbChunks - 1; chunk >= 0; chunk-- { + s := selectors[chunk] + if chunk != nbChunks-1 { + for j := uint64(0); j < c; j++ { + p.DoubleAssign() + } + } + + bits := (pScalars[i][s.index] & s.mask) >> s.shift + if s.multiWordSelect { + bits += (pScalars[i][s.index+1] & s.maskHigh) << s.shiftHigh + } + + if bits == 0 { + continue + } + + // if msbWindow bit is set, we need to substract + if bits&msbWindow == 0 { + // add + p.AddMixed(&baseTableAff[bits-1]) + } else { + // sub + t := baseTableAff[bits & ^msbWindow] + t.Neg(&t) + p.AddMixed(&t) + } + } + + // set our result point + toReturn[i] = p + + } + }) + toReturnAff := make([]G1Affine, len(scalars)) + BatchJacobianToAffineG1Affine(toReturn, toReturnAff) + return toReturnAff +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/g2.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/g2.go new file mode 100644 index 00000000000..a037b715136 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/g2.go @@ -0,0 +1,953 @@ +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package bn254 + +import ( + "math/big" + + "github.com/consensys/gnark-crypto/ecc" + "github.com/consensys/gnark-crypto/ecc/bn254/fr" + "github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower" + "github.com/consensys/gnark-crypto/internal/parallel" +) + +// G2Affine point in affine coordinates +type G2Affine struct { + X, Y fptower.E2 +} + +// G2Jac is a point with fptower.E2 coordinates +type G2Jac struct { + X, Y, Z fptower.E2 +} + +// g2JacExtended parameterized jacobian coordinates (x=X/ZZ, y=Y/ZZZ, ZZ**3=ZZZ**2) +type g2JacExtended struct { + X, Y, ZZ, ZZZ fptower.E2 +} + +// g2Proj point in projective coordinates +type g2Proj struct { + x, y, z fptower.E2 +} + +// ------------------------------------------------------------------------------------------------- +// Affine + +// Set sets p to the provided point +func (p *G2Affine) Set(a *G2Affine) *G2Affine { + p.X, p.Y = a.X, a.Y + return p +} + +// ScalarMultiplication computes and returns p = a*s +func (p *G2Affine) ScalarMultiplication(a *G2Affine, s *big.Int) *G2Affine { + var _p G2Jac + _p.FromAffine(a) + _p.mulGLV(&_p, s) + p.FromJacobian(&_p) + return p +} + +// Equal tests if two points (in Affine coordinates) are equal +func (p *G2Affine) Equal(a *G2Affine) bool { + return p.X.Equal(&a.X) && p.Y.Equal(&a.Y) +} + +// Neg computes -G +func (p *G2Affine) Neg(a *G2Affine) *G2Affine { + p.X = a.X + p.Y.Neg(&a.Y) + return p +} + +// FromJacobian rescale a point in Jacobian coord in z=1 plane +func (p *G2Affine) FromJacobian(p1 *G2Jac) *G2Affine { + + var a, b fptower.E2 + + if p1.Z.IsZero() { + p.X.SetZero() + p.Y.SetZero() + return p + } + + a.Inverse(&p1.Z) + b.Square(&a) + p.X.Mul(&p1.X, &b) + p.Y.Mul(&p1.Y, &b).Mul(&p.Y, &a) + + return p +} + +func (p *G2Affine) String() string { + var x, y fptower.E2 + x.Set(&p.X) + y.Set(&p.Y) + return "E([" + x.String() + "," + y.String() + "])," +} + +// IsInfinity checks if the point is infinity (in affine, it's encoded as (0,0)) +func (p *G2Affine) IsInfinity() bool { + return p.X.IsZero() && p.Y.IsZero() +} + +// IsOnCurve returns true if p in on the curve +func (p *G2Affine) IsOnCurve() bool { + var point G2Jac + point.FromAffine(p) + return point.IsOnCurve() // call this function to handle infinity point +} + +// IsInSubGroup returns true if p is in the correct subgroup, false otherwise +func (p *G2Affine) IsInSubGroup() bool { + var _p G2Jac + _p.FromAffine(p) + return _p.IsOnCurve() && _p.IsInSubGroup() +} + +// ------------------------------------------------------------------------------------------------- +// Jacobian + +// Set sets p to the provided point +func (p *G2Jac) Set(a *G2Jac) *G2Jac { + p.X, p.Y, p.Z = a.X, a.Y, a.Z + return p +} + +// Equal tests if two points (in Jacobian coordinates) are equal +func (p *G2Jac) Equal(a *G2Jac) bool { + + if p.Z.IsZero() && a.Z.IsZero() { + return true + } + _p := G2Affine{} + _p.FromJacobian(p) + + _a := G2Affine{} + _a.FromJacobian(a) + + return _p.X.Equal(&_a.X) && _p.Y.Equal(&_a.Y) +} + +// Neg computes -G +func (p *G2Jac) Neg(a *G2Jac) *G2Jac { + *p = *a + p.Y.Neg(&a.Y) + return p +} + +// SubAssign substracts two points on the curve +func (p *G2Jac) SubAssign(a *G2Jac) *G2Jac { + var tmp G2Jac + tmp.Set(a) + tmp.Y.Neg(&tmp.Y) + p.AddAssign(&tmp) + return p +} + +// AddAssign point addition in montgomery form +// https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#addition-add-2007-bl +func (p *G2Jac) AddAssign(a *G2Jac) *G2Jac { + + // p is infinity, return a + if p.Z.IsZero() { + p.Set(a) + return p + } + + // a is infinity, return p + if a.Z.IsZero() { + return p + } + + var Z1Z1, Z2Z2, U1, U2, S1, S2, H, I, J, r, V fptower.E2 + Z1Z1.Square(&a.Z) + Z2Z2.Square(&p.Z) + U1.Mul(&a.X, &Z2Z2) + U2.Mul(&p.X, &Z1Z1) + S1.Mul(&a.Y, &p.Z). + Mul(&S1, &Z2Z2) + S2.Mul(&p.Y, &a.Z). + Mul(&S2, &Z1Z1) + + // if p == a, we double instead + if U1.Equal(&U2) && S1.Equal(&S2) { + return p.DoubleAssign() + } + + H.Sub(&U2, &U1) + I.Double(&H). + Square(&I) + J.Mul(&H, &I) + r.Sub(&S2, &S1).Double(&r) + V.Mul(&U1, &I) + p.X.Square(&r). + Sub(&p.X, &J). + Sub(&p.X, &V). + Sub(&p.X, &V) + p.Y.Sub(&V, &p.X). + Mul(&p.Y, &r) + S1.Mul(&S1, &J).Double(&S1) + p.Y.Sub(&p.Y, &S1) + p.Z.Add(&p.Z, &a.Z) + p.Z.Square(&p.Z). + Sub(&p.Z, &Z1Z1). + Sub(&p.Z, &Z2Z2). + Mul(&p.Z, &H) + + return p +} + +// AddMixed point addition +// http://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#addition-madd-2007-bl +func (p *G2Jac) AddMixed(a *G2Affine) *G2Jac { + + //if a is infinity return p + if a.X.IsZero() && a.Y.IsZero() { + return p + } + // p is infinity, return a + if p.Z.IsZero() { + p.X = a.X + p.Y = a.Y + p.Z.SetOne() + return p + } + + var Z1Z1, U2, S2, H, HH, I, J, r, V fptower.E2 + Z1Z1.Square(&p.Z) + U2.Mul(&a.X, &Z1Z1) + S2.Mul(&a.Y, &p.Z). + Mul(&S2, &Z1Z1) + + // if p == a, we double instead + if U2.Equal(&p.X) && S2.Equal(&p.Y) { + return p.DoubleAssign() + } + + H.Sub(&U2, &p.X) + HH.Square(&H) + I.Double(&HH).Double(&I) + J.Mul(&H, &I) + r.Sub(&S2, &p.Y).Double(&r) + V.Mul(&p.X, &I) + p.X.Square(&r). + Sub(&p.X, &J). + Sub(&p.X, &V). + Sub(&p.X, &V) + J.Mul(&J, &p.Y).Double(&J) + p.Y.Sub(&V, &p.X). + Mul(&p.Y, &r) + p.Y.Sub(&p.Y, &J) + p.Z.Add(&p.Z, &H) + p.Z.Square(&p.Z). + Sub(&p.Z, &Z1Z1). + Sub(&p.Z, &HH) + + return p +} + +// Double doubles a point in Jacobian coordinates +// https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2007-bl +func (p *G2Jac) Double(q *G2Jac) *G2Jac { + p.Set(q) + p.DoubleAssign() + return p +} + +// DoubleAssign doubles a point in Jacobian coordinates +// https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2007-bl +func (p *G2Jac) DoubleAssign() *G2Jac { + + var XX, YY, YYYY, ZZ, S, M, T fptower.E2 + + XX.Square(&p.X) + YY.Square(&p.Y) + YYYY.Square(&YY) + ZZ.Square(&p.Z) + S.Add(&p.X, &YY) + S.Square(&S). + Sub(&S, &XX). + Sub(&S, &YYYY). + Double(&S) + M.Double(&XX).Add(&M, &XX) + p.Z.Add(&p.Z, &p.Y). + Square(&p.Z). + Sub(&p.Z, &YY). + Sub(&p.Z, &ZZ) + T.Square(&M) + p.X = T + T.Double(&S) + p.X.Sub(&p.X, &T) + p.Y.Sub(&S, &p.X). + Mul(&p.Y, &M) + YYYY.Double(&YYYY).Double(&YYYY).Double(&YYYY) + p.Y.Sub(&p.Y, &YYYY) + + return p +} + +// ScalarMultiplication computes and returns p = a*s +// see https://www.iacr.org/archive/crypto2001/21390189.pdf +func (p *G2Jac) ScalarMultiplication(a *G2Jac, s *big.Int) *G2Jac { + return p.mulGLV(a, s) +} + +func (p *G2Jac) String() string { + if p.Z.IsZero() { + return "O" + } + _p := G2Affine{} + _p.FromJacobian(p) + return "E([" + _p.X.String() + "," + _p.Y.String() + "])," +} + +// FromAffine sets p = Q, p in Jacboian, Q in affine +func (p *G2Jac) FromAffine(Q *G2Affine) *G2Jac { + if Q.X.IsZero() && Q.Y.IsZero() { + p.Z.SetZero() + p.X.SetOne() + p.Y.SetOne() + return p + } + p.Z.SetOne() + p.X.Set(&Q.X) + p.Y.Set(&Q.Y) + return p +} + +// IsOnCurve returns true if p in on the curve +func (p *G2Jac) IsOnCurve() bool { + var left, right, tmp fptower.E2 + left.Square(&p.Y) + right.Square(&p.X).Mul(&right, &p.X) + tmp.Square(&p.Z). + Square(&tmp). + Mul(&tmp, &p.Z). + Mul(&tmp, &p.Z). + Mul(&tmp, &bTwistCurveCoeff) + right.Add(&right, &tmp) + return left.Equal(&right) +} + +// IsInSubGroup returns true if p is on the r-torsion, false otherwise. +// Z[r,0]+Z[-lambdaG2Affine, 1] is the kernel +// of (u,v)->u+lambdaG2Affinev mod r. Expressing r, lambdaG2Affine as +// polynomials in x, a short vector of this Zmodule is +// (4x+2), (-12x**2+4*x). So we check that (4x+2)p+(-12x**2+4*x)phi(p) +// is the infinity. +func (p *G2Jac) IsInSubGroup() bool { + + var res, xphip, phip G2Jac + phip.phi(p) + xphip.ScalarMultiplication(&phip, &xGen) // x*phi(p) + res.Double(&xphip).AddAssign(&xphip) // 3x*phi(p) + res.AddAssign(&phip).SubAssign(p) // 3x*phi(p)+phi(p)-p + res.Double(&res).ScalarMultiplication(&res, &xGen) // 6x**2*phi(p)+2x*phi(p)-2x*p + res.SubAssign(p).Double(&res) // 12x**2*phi(p)+4x*phi(p)-4x*p-2p + + return res.IsOnCurve() && res.Z.IsZero() + +} + +// mulWindowed 2-bits windowed exponentiation +func (p *G2Jac) mulWindowed(a *G2Jac, s *big.Int) *G2Jac { + + var res G2Jac + var ops [3]G2Jac + + res.Set(&g2Infinity) + ops[0].Set(a) + ops[1].Double(&ops[0]) + ops[2].Set(&ops[0]).AddAssign(&ops[1]) + + b := s.Bytes() + for i := range b { + w := b[i] + mask := byte(0xc0) + for j := 0; j < 4; j++ { + res.DoubleAssign().DoubleAssign() + c := (w & mask) >> (6 - 2*j) + if c != 0 { + res.AddAssign(&ops[c-1]) + } + mask = mask >> 2 + } + } + p.Set(&res) + + return p + +} + +// psi(p) = u o frob o u**-1 where u:E'->E iso from the twist to E +func (p *G2Jac) psi(a *G2Jac) *G2Jac { + p.Set(a) + p.X.Conjugate(&p.X).Mul(&p.X, &endo.u) + p.Y.Conjugate(&p.Y).Mul(&p.Y, &endo.v) + p.Z.Conjugate(&p.Z) + return p +} + +// phi assigns p to phi(a) where phi: (x,y)->(ux,y), and returns p +func (p *G2Jac) phi(a *G2Jac) *G2Jac { + p.Set(a) + p.X.MulByElement(&p.X, &thirdRootOneG2) + return p +} + +// mulGLV performs scalar multiplication using GLV +// see https://www.iacr.org/archive/crypto2001/21390189.pdf +func (p *G2Jac) mulGLV(a *G2Jac, s *big.Int) *G2Jac { + + var table [15]G2Jac + var zero big.Int + var res G2Jac + var k1, k2 fr.Element + + res.Set(&g2Infinity) + + // table[b3b2b1b0-1] = b3b2*phi(a) + b1b0*a + table[0].Set(a) + table[3].phi(a) + + // split the scalar, modifies +-a, phi(a) accordingly + k := ecc.SplitScalar(s, &glvBasis) + + if k[0].Cmp(&zero) == -1 { + k[0].Neg(&k[0]) + table[0].Neg(&table[0]) + } + if k[1].Cmp(&zero) == -1 { + k[1].Neg(&k[1]) + table[3].Neg(&table[3]) + } + + // precompute table (2 bits sliding window) + // table[b3b2b1b0-1] = b3b2*phi(a) + b1b0*a if b3b2b1b0 != 0 + table[1].Double(&table[0]) + table[2].Set(&table[1]).AddAssign(&table[0]) + table[4].Set(&table[3]).AddAssign(&table[0]) + table[5].Set(&table[3]).AddAssign(&table[1]) + table[6].Set(&table[3]).AddAssign(&table[2]) + table[7].Double(&table[3]) + table[8].Set(&table[7]).AddAssign(&table[0]) + table[9].Set(&table[7]).AddAssign(&table[1]) + table[10].Set(&table[7]).AddAssign(&table[2]) + table[11].Set(&table[7]).AddAssign(&table[3]) + table[12].Set(&table[11]).AddAssign(&table[0]) + table[13].Set(&table[11]).AddAssign(&table[1]) + table[14].Set(&table[11]).AddAssign(&table[2]) + + // bounds on the lattice base vectors guarantee that k1, k2 are len(r)/2 bits long max + k1.SetBigInt(&k[0]).FromMont() + k2.SetBigInt(&k[1]).FromMont() + + // loop starts from len(k1)/2 due to the bounds + for i := len(k1)/2 - 1; i >= 0; i-- { + mask := uint64(3) << 62 + for j := 0; j < 32; j++ { + res.Double(&res).Double(&res) + b1 := (k1[i] & mask) >> (62 - 2*j) + b2 := (k2[i] & mask) >> (62 - 2*j) + if b1|b2 != 0 { + s := (b2<<2 | b1) + res.AddAssign(&table[s-1]) + } + mask = mask >> 2 + } + } + + p.Set(&res) + return p +} + +// ClearCofactor ... +func (p *G2Affine) ClearCofactor(a *G2Affine) *G2Affine { + var _p G2Jac + _p.FromAffine(a) + _p.ClearCofactor(&_p) + p.FromJacobian(&_p) + return p +} + +// ClearCofactor ... +func (p *G2Jac) ClearCofactor(a *G2Jac) *G2Jac { + // cf http://cacr.uwaterloo.ca/techreports/2011/cacr2011-26.pdf, 6.1 + var points [4]G2Jac + + points[0].ScalarMultiplication(a, &xGen) + + points[1].Double(&points[0]). + AddAssign(&points[0]). + psi(&points[1]) + + points[2].psi(&points[0]). + psi(&points[2]) + + points[3].psi(a).psi(&points[3]).psi(&points[3]) + + var res G2Jac + res.Set(&g2Infinity) + for i := 0; i < 4; i++ { + res.AddAssign(&points[i]) + } + p.Set(&res) + return p + +} + +// ------------------------------------------------------------------------------------------------- +// Jacobian extended + +// Set sets p to the provided point +func (p *g2JacExtended) Set(a *g2JacExtended) *g2JacExtended { + p.X, p.Y, p.ZZ, p.ZZZ = a.X, a.Y, a.ZZ, a.ZZZ + return p +} + +// setInfinity sets p to O +func (p *g2JacExtended) setInfinity() *g2JacExtended { + p.X.SetOne() + p.Y.SetOne() + p.ZZ = fptower.E2{} + p.ZZZ = fptower.E2{} + return p +} + +// fromJacExtended sets Q in affine coords +func (p *G2Affine) fromJacExtended(Q *g2JacExtended) *G2Affine { + if Q.ZZ.IsZero() { + p.X = fptower.E2{} + p.Y = fptower.E2{} + return p + } + p.X.Inverse(&Q.ZZ).Mul(&p.X, &Q.X) + p.Y.Inverse(&Q.ZZZ).Mul(&p.Y, &Q.Y) + return p +} + +// fromJacExtended sets Q in Jacobian coords +func (p *G2Jac) fromJacExtended(Q *g2JacExtended) *G2Jac { + if Q.ZZ.IsZero() { + p.Set(&g2Infinity) + return p + } + p.X.Mul(&Q.ZZ, &Q.X).Mul(&p.X, &Q.ZZ) + p.Y.Mul(&Q.ZZZ, &Q.Y).Mul(&p.Y, &Q.ZZZ) + p.Z.Set(&Q.ZZZ) + return p +} + +// unsafeFromJacExtended sets p in jacobian coords, but don't check for infinity +func (p *G2Jac) unsafeFromJacExtended(Q *g2JacExtended) *G2Jac { + p.X.Square(&Q.ZZ).Mul(&p.X, &Q.X) + p.Y.Square(&Q.ZZZ).Mul(&p.Y, &Q.Y) + p.Z = Q.ZZZ + return p +} + +// add point in ZZ coords +// https://www.hyperelliptic.org/EFD/g1p/auto-shortw-xyzz.html#addition-add-2008-s +func (p *g2JacExtended) add(q *g2JacExtended) *g2JacExtended { + //if q is infinity return p + if q.ZZ.IsZero() { + return p + } + // p is infinity, return q + if p.ZZ.IsZero() { + p.Set(q) + return p + } + + var A, B, X1ZZ2, X2ZZ1, Y1ZZZ2, Y2ZZZ1 fptower.E2 + + // p2: q, p1: p + X2ZZ1.Mul(&q.X, &p.ZZ) + X1ZZ2.Mul(&p.X, &q.ZZ) + A.Sub(&X2ZZ1, &X1ZZ2) + Y2ZZZ1.Mul(&q.Y, &p.ZZZ) + Y1ZZZ2.Mul(&p.Y, &q.ZZZ) + B.Sub(&Y2ZZZ1, &Y1ZZZ2) + + if A.IsZero() { + if B.IsZero() { + return p.double(q) + + } + p.ZZ = fptower.E2{} + p.ZZZ = fptower.E2{} + return p + } + + var U1, U2, S1, S2, P, R, PP, PPP, Q, V fptower.E2 + U1.Mul(&p.X, &q.ZZ) + U2.Mul(&q.X, &p.ZZ) + S1.Mul(&p.Y, &q.ZZZ) + S2.Mul(&q.Y, &p.ZZZ) + P.Sub(&U2, &U1) + R.Sub(&S2, &S1) + PP.Square(&P) + PPP.Mul(&P, &PP) + Q.Mul(&U1, &PP) + V.Mul(&S1, &PPP) + + p.X.Square(&R). + Sub(&p.X, &PPP). + Sub(&p.X, &Q). + Sub(&p.X, &Q) + p.Y.Sub(&Q, &p.X). + Mul(&p.Y, &R). + Sub(&p.Y, &V) + p.ZZ.Mul(&p.ZZ, &q.ZZ). + Mul(&p.ZZ, &PP) + p.ZZZ.Mul(&p.ZZZ, &q.ZZZ). + Mul(&p.ZZZ, &PPP) + + return p +} + +// double point in ZZ coords +// http://www.hyperelliptic.org/EFD/g1p/auto-shortw-xyzz.html#doubling-dbl-2008-s-1 +func (p *g2JacExtended) double(q *g2JacExtended) *g2JacExtended { + var U, V, W, S, XX, M fptower.E2 + + U.Double(&q.Y) + V.Square(&U) + W.Mul(&U, &V) + S.Mul(&q.X, &V) + XX.Square(&q.X) + M.Double(&XX). + Add(&M, &XX) // -> + a, but a=0 here + U.Mul(&W, &q.Y) + + p.X.Square(&M). + Sub(&p.X, &S). + Sub(&p.X, &S) + p.Y.Sub(&S, &p.X). + Mul(&p.Y, &M). + Sub(&p.Y, &U) + p.ZZ.Mul(&V, &q.ZZ) + p.ZZZ.Mul(&W, &q.ZZZ) + + return p +} + +// subMixed same as addMixed, but will negate a.Y +// http://www.hyperelliptic.org/EFD/g1p/auto-shortw-xyzz.html#addition-madd-2008-s +func (p *g2JacExtended) subMixed(a *G2Affine) *g2JacExtended { + + //if a is infinity return p + if a.X.IsZero() && a.Y.IsZero() { + return p + } + // p is infinity, return a + if p.ZZ.IsZero() { + p.X = a.X + p.Y.Neg(&a.Y) + p.ZZ.SetOne() + p.ZZZ.SetOne() + return p + } + + var P, R fptower.E2 + + // p2: a, p1: p + P.Mul(&a.X, &p.ZZ) + P.Sub(&P, &p.X) + + R.Mul(&a.Y, &p.ZZZ) + R.Neg(&R) + R.Sub(&R, &p.Y) + + if P.IsZero() { + if R.IsZero() { + return p.doubleNegMixed(a) + + } + p.ZZ = fptower.E2{} + p.ZZZ = fptower.E2{} + return p + } + + var PP, PPP, Q, Q2, RR, X3, Y3 fptower.E2 + + PP.Square(&P) + PPP.Mul(&P, &PP) + Q.Mul(&p.X, &PP) + RR.Square(&R) + X3.Sub(&RR, &PPP) + Q2.Double(&Q) + p.X.Sub(&X3, &Q2) + Y3.Sub(&Q, &p.X).Mul(&Y3, &R) + R.Mul(&p.Y, &PPP) + p.Y.Sub(&Y3, &R) + p.ZZ.Mul(&p.ZZ, &PP) + p.ZZZ.Mul(&p.ZZZ, &PPP) + + return p + +} + +// addMixed +// http://www.hyperelliptic.org/EFD/g1p/auto-shortw-xyzz.html#addition-madd-2008-s +func (p *g2JacExtended) addMixed(a *G2Affine) *g2JacExtended { + + //if a is infinity return p + if a.X.IsZero() && a.Y.IsZero() { + return p + } + // p is infinity, return a + if p.ZZ.IsZero() { + p.X = a.X + p.Y = a.Y + p.ZZ.SetOne() + p.ZZZ.SetOne() + return p + } + + var P, R fptower.E2 + + // p2: a, p1: p + P.Mul(&a.X, &p.ZZ) + P.Sub(&P, &p.X) + + R.Mul(&a.Y, &p.ZZZ) + R.Sub(&R, &p.Y) + + if P.IsZero() { + if R.IsZero() { + return p.doubleMixed(a) + + } + p.ZZ = fptower.E2{} + p.ZZZ = fptower.E2{} + return p + } + + var PP, PPP, Q, Q2, RR, X3, Y3 fptower.E2 + + PP.Square(&P) + PPP.Mul(&P, &PP) + Q.Mul(&p.X, &PP) + RR.Square(&R) + X3.Sub(&RR, &PPP) + Q2.Double(&Q) + p.X.Sub(&X3, &Q2) + Y3.Sub(&Q, &p.X).Mul(&Y3, &R) + R.Mul(&p.Y, &PPP) + p.Y.Sub(&Y3, &R) + p.ZZ.Mul(&p.ZZ, &PP) + p.ZZZ.Mul(&p.ZZZ, &PPP) + + return p + +} + +// doubleNegMixed same as double, but will negate q.Y +func (p *g2JacExtended) doubleNegMixed(q *G2Affine) *g2JacExtended { + + var U, V, W, S, XX, M, S2, L fptower.E2 + + U.Double(&q.Y) + U.Neg(&U) + V.Square(&U) + W.Mul(&U, &V) + S.Mul(&q.X, &V) + XX.Square(&q.X) + M.Double(&XX). + Add(&M, &XX) // -> + a, but a=0 here + S2.Double(&S) + L.Mul(&W, &q.Y) + + p.X.Square(&M). + Sub(&p.X, &S2) + p.Y.Sub(&S, &p.X). + Mul(&p.Y, &M). + Add(&p.Y, &L) + p.ZZ.Set(&V) + p.ZZZ.Set(&W) + + return p +} + +// doubleMixed point in ZZ coords +// http://www.hyperelliptic.org/EFD/g1p/auto-shortw-xyzz.html#doubling-dbl-2008-s-1 +func (p *g2JacExtended) doubleMixed(q *G2Affine) *g2JacExtended { + + var U, V, W, S, XX, M, S2, L fptower.E2 + + U.Double(&q.Y) + V.Square(&U) + W.Mul(&U, &V) + S.Mul(&q.X, &V) + XX.Square(&q.X) + M.Double(&XX). + Add(&M, &XX) // -> + a, but a=0 here + S2.Double(&S) + L.Mul(&W, &q.Y) + + p.X.Square(&M). + Sub(&p.X, &S2) + p.Y.Sub(&S, &p.X). + Mul(&p.Y, &M). + Sub(&p.Y, &L) + p.ZZ.Set(&V) + p.ZZZ.Set(&W) + + return p +} + +// ------------------------------------------------------------------------------------------------- +// Homogenous projective + +// Set sets p to the provided point +func (p *g2Proj) Set(a *g2Proj) *g2Proj { + p.x, p.y, p.z = a.x, a.y, a.z + return p +} + +// FromJacobian converts a point from Jacobian to projective coordinates +func (p *g2Proj) FromJacobian(Q *G2Jac) *g2Proj { + var buf fptower.E2 + buf.Square(&Q.Z) + + p.x.Mul(&Q.X, &Q.Z) + p.y.Set(&Q.Y) + p.z.Mul(&Q.Z, &buf) + + return p +} + +// FromAffine sets p = Q, p in homogenous projective, Q in affine +func (p *g2Proj) FromAffine(Q *G2Affine) *g2Proj { + if Q.X.IsZero() && Q.Y.IsZero() { + p.z.SetZero() + p.x.SetOne() + p.y.SetOne() + return p + } + p.z.SetOne() + p.x.Set(&Q.X) + p.y.Set(&Q.Y) + return p +} + +// BatchScalarMultiplicationG2 multiplies the same base (generator) by all scalars +// and return resulting points in affine coordinates +// uses a simple windowed-NAF like exponentiation algorithm +func BatchScalarMultiplicationG2(base *G2Affine, scalars []fr.Element) []G2Affine { + + // approximate cost in group ops is + // cost = 2^{c-1} + n(scalar.nbBits+nbChunks) + + nbPoints := uint64(len(scalars)) + min := ^uint64(0) + bestC := 0 + for c := 2; c < 18; c++ { + cost := uint64(1 << (c - 1)) + nbChunks := uint64(fr.Limbs * 64 / c) + if (fr.Limbs*64)%c != 0 { + nbChunks++ + } + cost += nbPoints * ((fr.Limbs * 64) + nbChunks) + if cost < min { + min = cost + bestC = c + } + } + c := uint64(bestC) // window size + nbChunks := int(fr.Limbs * 64 / c) + if (fr.Limbs*64)%c != 0 { + nbChunks++ + } + mask := uint64((1 << c) - 1) // low c bits are 1 + msbWindow := uint64(1 << (c - 1)) + + // precompute all powers of base for our window + // note here that if performance is critical, we can implement as in the msmX methods + // this allocation to be on the stack + baseTable := make([]G2Jac, (1 << (c - 1))) + baseTable[0].Set(&g2Infinity) + baseTable[0].AddMixed(base) + for i := 1; i < len(baseTable); i++ { + baseTable[i] = baseTable[i-1] + baseTable[i].AddMixed(base) + } + + pScalars := partitionScalars(scalars, c) + + // compute offset and word selector / shift to select the right bits of our windows + selectors := make([]selector, nbChunks) + for chunk := 0; chunk < nbChunks; chunk++ { + jc := uint64(uint64(chunk) * c) + d := selector{} + d.index = jc / 64 + d.shift = jc - (d.index * 64) + d.mask = mask << d.shift + d.multiWordSelect = (64%c) != 0 && d.shift > (64-c) && d.index < (fr.Limbs-1) + if d.multiWordSelect { + nbBitsHigh := d.shift - uint64(64-c) + d.maskHigh = (1 << nbBitsHigh) - 1 + d.shiftHigh = (c - nbBitsHigh) + } + selectors[chunk] = d + } + toReturn := make([]G2Affine, len(scalars)) + + // for each digit, take value in the base table, double it c time, voila. + parallel.Execute(len(pScalars), func(start, end int) { + var p G2Jac + for i := start; i < end; i++ { + p.Set(&g2Infinity) + for chunk := nbChunks - 1; chunk >= 0; chunk-- { + s := selectors[chunk] + if chunk != nbChunks-1 { + for j := uint64(0); j < c; j++ { + p.DoubleAssign() + } + } + + bits := (pScalars[i][s.index] & s.mask) >> s.shift + if s.multiWordSelect { + bits += (pScalars[i][s.index+1] & s.maskHigh) << s.shiftHigh + } + + if bits == 0 { + continue + } + + // if msbWindow bit is set, we need to substract + if bits&msbWindow == 0 { + // add + p.AddAssign(&baseTable[bits-1]) + } else { + // sub + t := baseTable[bits & ^msbWindow] + t.Neg(&t) + p.AddAssign(&t) + } + } + + // set our result point + toReturn[i].FromJacobian(&p) + + } + }) + return toReturn +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/hash_to_curve.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/hash_to_curve.go new file mode 100644 index 00000000000..14fe62a0707 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/hash_to_curve.go @@ -0,0 +1,273 @@ +// Copyright 2020 ConsenSys AG +// +// 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. + +package bn254 + +import ( + "math/big" + + "github.com/consensys/gnark-crypto/ecc" + "github.com/consensys/gnark-crypto/ecc/bn254/fp" + "github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower" +) + +// hashToFp hashes msg to count prime field elements. +// https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-06#section-5.2 +func hashToFp(msg, dst []byte, count int) ([]fp.Element, error) { + + // 128 bits of security + // L = ceil((ceil(log2(p)) + k) / 8), where k is the security parameter = 128 + L := 48 + + lenInBytes := count * L + pseudoRandomBytes, err := ecc.ExpandMsgXmd(msg, dst, lenInBytes) + if err != nil { + return nil, err + } + + res := make([]fp.Element, count) + for i := 0; i < count; i++ { + res[i].SetBytes(pseudoRandomBytes[i*L : (i+1)*L]) + } + return res, nil +} + +// returns false if u>-u when seen as a bigInt +func sign0(u fp.Element) bool { + var a, b big.Int + u.ToBigIntRegular(&a) + u.Neg(&u) + u.ToBigIntRegular(&b) + return a.Cmp(&b) <= 0 +} + +// ---------------------------------------------------------------------------------------- +// G1Affine + +// https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-06#section-4.1 +// Shallue and van de Woestijne method, works for any elliptic curve in Weierstrass curve +func svdwMapG1(u fp.Element) G1Affine { + + var res G1Affine + + // constants + // sage script to find z: https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-06#appendix-E.1 + var z, c1, c2, c3, c4 fp.Element + z.SetOne() + c1.SetString("4") + c2.SetString("10944121435919637611123202872628637544348155578648911831344518947322613104291") + c3.SetString("8815841940592487685674414971303048083897117035520822607866") + c4.SetString("7296080957279758407415468581752425029565437052432607887563012631548408736189") + + var tv1, tv2, tv3, tv4, one, x1, gx1, x2, gx2, x3, x, gx, y fp.Element + one.SetOne() + tv1.Square(&u).Mul(&tv1, &c1) + tv2.Add(&one, &tv1) + tv1.Sub(&one, &tv1) + tv3.Mul(&tv2, &tv1).Inverse(&tv3) + tv4.Mul(&u, &tv1) + tv4.Mul(&tv4, &tv3) + tv4.Mul(&tv4, &c3) + x1.Sub(&c2, &tv4) + gx1.Square(&x1) + // 12. gx1 = gx1 + A + gx1.Mul(&gx1, &x1) + gx1.Add(&gx1, &bCurveCoeff) + e1 := gx1.Legendre() + x2.Add(&c2, &tv4) + gx2.Square(&x2) + // 18. gx2 = gx2 + A + gx2.Mul(&gx2, &x2) + gx2.Add(&gx2, &bCurveCoeff) + e2 := gx2.Legendre() - e1 // 2 if is_square(gx2) AND NOT e1 + x3.Square(&tv2) + x3.Mul(&x3, &tv3) + x3.Square(&x3) + x3.Mul(&x3, &c4) + x3.Add(&x3, &z) + if e1 == 1 { + x.Set(&x1) + } else { + x.Set(&x3) + } + if e2 == 2 { + x.Set(&x2) + } + gx.Square(&x) + // gx = gx + A + gx.Mul(&gx, &x) + gx.Add(&gx, &bCurveCoeff) + y.Sqrt(&gx) + e3 := sign0(u) && sign0(y) + if !e3 { + y.Neg(&y) + } + res.X.Set(&x) + res.Y.Set(&y) + + return res +} + +// MapToCurveG1Svdw maps an fp.Element to a point on the curve using the Shallue and van de Woestijne map +// https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-06#section-2.2.1 +func MapToCurveG1Svdw(t fp.Element) G1Affine { + res := svdwMapG1(t) + return res +} + +// EncodeToCurveG1Svdw maps an fp.Element to a point on the curve using the Shallue and van de Woestijne map +// https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-06#section-2.2.2 +func EncodeToCurveG1Svdw(msg, dst []byte) (G1Affine, error) { + var res G1Affine + t, err := hashToFp(msg, dst, 1) + if err != nil { + return res, err + } + res = MapToCurveG1Svdw(t[0]) + return res, nil +} + +// HashToCurveG1Svdw maps an fp.Element to a point on the curve using the Shallue and van de Woestijne map +// https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-06#section-3 +func HashToCurveG1Svdw(msg, dst []byte) (G1Affine, error) { + var res G1Affine + u, err := hashToFp(msg, dst, 2) + if err != nil { + return res, err + } + Q0 := MapToCurveG1Svdw(u[0]) + Q1 := MapToCurveG1Svdw(u[1]) + var _Q0, _Q1, _res G1Jac + _Q0.FromAffine(&Q0) + _Q1.FromAffine(&Q1) + _res.Set(&_Q1).AddAssign(&_Q0) + res.FromJacobian(&_res) + return res, nil +} + +// ---------------------------------------------------------------------------------------- +// G2Affine + +// https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-06#section-4.1 +// Shallue and van de Woestijne method, works for any elliptic curve in Weierstrass curve +func svdwMapG2(u fptower.E2) G2Affine { + + var res G2Affine + + // constants + // sage script to find z: https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-06#appendix-E.1 + var z, c1, c2, c3, c4 fptower.E2 + z.A1.SetString("1") + c1.A0.SetString("19485874751759354771024239261021720505790618469301721065564631296452457478373") + c1.A1.SetString("266929791119991161246907387137283842545076965332900288569378510910307636689") + c2.A1.SetString("10944121435919637611123202872628637544348155578648911831344518947322613104291") + c3.A0.SetString("13617985070220897759416741581922326973608167195618746963957740978229330444385") + c3.A1.SetString("6485072654231349560354894037339044590945718224403932749563131108378844487223") + c4.A0.SetString("18685085378399381287283517099609868978155387573303020199856495763721534568303") + c4.A1.SetString("355906388159988214995876516183045123393435953777200384759171347880410182252") + + var tv1, tv2, tv3, tv4, one, x1, gx1, x2, gx2, x3, x, gx, y fptower.E2 + one.SetOne() + tv1.Square(&u).Mul(&tv1, &c1) + tv2.Add(&one, &tv1) + tv1.Sub(&one, &tv1) + tv3.Mul(&tv2, &tv1).Inverse(&tv3) + tv4.Mul(&u, &tv1) + tv4.Mul(&tv4, &tv3) + tv4.Mul(&tv4, &c3) + x1.Sub(&c2, &tv4) + gx1.Square(&x1) + // 12. gx1 = gx1 + A + gx1.Mul(&gx1, &x1) + gx1.Add(&gx1, &bTwistCurveCoeff) + e1 := gx1.Legendre() + x2.Add(&c2, &tv4) + gx2.Square(&x2) + // 18. gx2 = gx2 + A + gx2.Mul(&gx2, &x2) + gx2.Add(&gx2, &bTwistCurveCoeff) + e2 := gx2.Legendre() - e1 // 2 if is_square(gx2) AND NOT e1 + x3.Square(&tv2) + x3.Mul(&x3, &tv3) + x3.Square(&x3) + x3.Mul(&x3, &c4) + x3.Add(&x3, &z) + if e1 == 1 { + x.Set(&x1) + } else { + x.Set(&x3) + } + if e2 == 2 { + x.Set(&x2) + } + gx.Square(&x) + // gx = gx + A + gx.Mul(&gx, &x) + gx.Add(&gx, &bTwistCurveCoeff) + y.Sqrt(&gx) + e3 := sign0(u.A0) && sign0(y.A0) + if !e3 { + y.Neg(&y) + } + res.X.Set(&x) + res.Y.Set(&y) + + return res +} + +// MapToCurveG2Svdw maps an fp.Element to a point on the curve using the Shallue and van de Woestijne map +// https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-06#section-2.2.1 +func MapToCurveG2Svdw(t fptower.E2) G2Affine { + res := svdwMapG2(t) + res.ClearCofactor(&res) + return res +} + +// EncodeToCurveG2Svdw maps an fp.Element to a point on the curve using the Shallue and van de Woestijne map +// https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-06#section-2.2.2 +func EncodeToCurveG2Svdw(msg, dst []byte) (G2Affine, error) { + var res G2Affine + _t, err := hashToFp(msg, dst, 2) + if err != nil { + return res, err + } + var t fptower.E2 + t.A0.Set(&_t[0]) + t.A1.Set(&_t[1]) + res = MapToCurveG2Svdw(t) + return res, nil +} + +// HashToCurveG2Svdw maps an fp.Element to a point on the curve using the Shallue and van de Woestijne map +// https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-06#section-3 +func HashToCurveG2Svdw(msg, dst []byte) (G2Affine, error) { + var res G2Affine + u, err := hashToFp(msg, dst, 4) + if err != nil { + return res, err + } + var u0, u1 fptower.E2 + u0.A0.Set(&u[0]) + u0.A1.Set(&u[1]) + u1.A0.Set(&u[2]) + u1.A1.Set(&u[3]) + Q0 := MapToCurveG2Svdw(u0) + Q1 := MapToCurveG2Svdw(u1) + var _Q0, _Q1, _res G2Jac + _Q0.FromAffine(&Q0) + _Q1.FromAffine(&Q1) + _res.Set(&_Q1).AddAssign(&_Q0) + res.FromJacobian(&_res) + return res, nil +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/asm.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/asm.go new file mode 100644 index 00000000000..c7bb911dfb9 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/asm.go @@ -0,0 +1,27 @@ +// +build !noadx + +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package fptower + +import "golang.org/x/sys/cpu" + +// supportAdx will be set only on amd64 that has MULX and ADDX instructions +var ( + supportAdx = cpu.X86.HasADX && cpu.X86.HasBMI2 + _ = supportAdx // used in asm +) diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/asm_noadx.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/asm_noadx.go new file mode 100644 index 00000000000..f09b13900c3 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/asm_noadx.go @@ -0,0 +1,24 @@ +// +build noadx + +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package fptower + +// note: this is needed for test purposes, as dynamically changing supportAdx doesn't flag +// certain errors (like fatal error: missing stackmap) +// this ensures we test all asm path. +var supportAdx = false diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e12.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e12.go new file mode 100644 index 00000000000..ef2c170e43b --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e12.go @@ -0,0 +1,355 @@ +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package fptower + +import ( + "encoding/binary" + "errors" + "github.com/consensys/gnark-crypto/ecc/bn254/fp" + "github.com/consensys/gnark-crypto/ecc/bn254/fr" + "math/big" +) + +// E12 is a degree two finite field extension of fp6 +type E12 struct { + C0, C1 E6 +} + +// Equal returns true if z equals x, fasle otherwise +func (z *E12) Equal(x *E12) bool { + return z.C0.Equal(&x.C0) && z.C1.Equal(&x.C1) +} + +// String puts E12 in string form +func (z *E12) String() string { + return (z.C0.String() + "+(" + z.C1.String() + ")*w") +} + +// SetString sets a E12 from string +func (z *E12) SetString(s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11 string) *E12 { + z.C0.SetString(s0, s1, s2, s3, s4, s5) + z.C1.SetString(s6, s7, s8, s9, s10, s11) + return z +} + +// Set copies x into z and returns z +func (z *E12) Set(x *E12) *E12 { + z.C0 = x.C0 + z.C1 = x.C1 + return z +} + +// SetOne sets z to 1 in Montgomery form and returns z +func (z *E12) SetOne() *E12 { + *z = E12{} + z.C0.B0.A0.SetOne() + return z +} + +// ToMont converts to Mont form +func (z *E12) ToMont() *E12 { + z.C0.ToMont() + z.C1.ToMont() + return z +} + +// FromMont converts from Mont form +func (z *E12) FromMont() *E12 { + z.C0.FromMont() + z.C1.FromMont() + return z +} + +// Add set z=x+y in E12 and return z +func (z *E12) Add(x, y *E12) *E12 { + z.C0.Add(&x.C0, &y.C0) + z.C1.Add(&x.C1, &y.C1) + return z +} + +// Sub sets z to x sub y and return z +func (z *E12) Sub(x, y *E12) *E12 { + z.C0.Sub(&x.C0, &y.C0) + z.C1.Sub(&x.C1, &y.C1) + return z +} + +// Double sets z=2*x and returns z +func (z *E12) Double(x *E12) *E12 { + z.C0.Double(&x.C0) + z.C1.Double(&x.C1) + return z +} + +// SetRandom used only in tests +func (z *E12) SetRandom() (*E12, error) { + if _, err := z.C0.SetRandom(); err != nil { + return nil, err + } + if _, err := z.C1.SetRandom(); err != nil { + return nil, err + } + return z, nil +} + +// Mul set z=x*y in E12 and return z +func (z *E12) Mul(x, y *E12) *E12 { + var a, b, c E6 + a.Add(&x.C0, &x.C1) + b.Add(&y.C0, &y.C1) + a.Mul(&a, &b) + b.Mul(&x.C0, &y.C0) + c.Mul(&x.C1, &y.C1) + z.C1.Sub(&a, &b).Sub(&z.C1, &c) + z.C0.MulByNonResidue(&c).Add(&z.C0, &b) + return z +} + +// Square set z=x*x in E12 and return z +func (z *E12) Square(x *E12) *E12 { + + //Algorithm 22 from https://eprint.iacr.org/2010/354.pdf + var c0, c2, c3 E6 + c0.Sub(&x.C0, &x.C1) + c3.MulByNonResidue(&x.C1).Neg(&c3).Add(&x.C0, &c3) + c2.Mul(&x.C0, &x.C1) + c0.Mul(&c0, &c3).Add(&c0, &c2) + z.C1.Double(&c2) + c2.MulByNonResidue(&c2) + z.C0.Add(&c0, &c2) + + return z +} + +// CyclotomicSquare https://eprint.iacr.org/2009/565.pdf, 3.2 +func (z *E12) CyclotomicSquare(x *E12) *E12 { + + // x=(x0,x1,x2,x3,x4,x5,x6,x7) in E2^6 + // cyclosquare(x)=(3*x4^2*u + 3*x0^2 - 2*x0, + // 3*x2^2*u + 3*x3^2 - 2*x1, + // 3*x5^2*u + 3*x1^2 - 2*x2, + // 6*x1*x5*u + 2*x3, + // 6*x0*x4 + 2*x4, + // 6*x2*x3 + 2*x5) + + var t [9]E2 + + t[0].Square(&x.C1.B1) + t[1].Square(&x.C0.B0) + t[6].Add(&x.C1.B1, &x.C0.B0).Square(&t[6]).Sub(&t[6], &t[0]).Sub(&t[6], &t[1]) // 2*x4*x0 + t[2].Square(&x.C0.B2) + t[3].Square(&x.C1.B0) + t[7].Add(&x.C0.B2, &x.C1.B0).Square(&t[7]).Sub(&t[7], &t[2]).Sub(&t[7], &t[3]) // 2*x2*x3 + t[4].Square(&x.C1.B2) + t[5].Square(&x.C0.B1) + t[8].Add(&x.C1.B2, &x.C0.B1).Square(&t[8]).Sub(&t[8], &t[4]).Sub(&t[8], &t[5]).MulByNonResidue(&t[8]) // 2*x5*x1*u + + t[0].MulByNonResidue(&t[0]).Add(&t[0], &t[1]) // x4^2*u + x0^2 + t[2].MulByNonResidue(&t[2]).Add(&t[2], &t[3]) // x2^2*u + x3^2 + t[4].MulByNonResidue(&t[4]).Add(&t[4], &t[5]) // x5^2*u + x1^2 + + z.C0.B0.Sub(&t[0], &x.C0.B0).Double(&z.C0.B0).Add(&z.C0.B0, &t[0]) + z.C0.B1.Sub(&t[2], &x.C0.B1).Double(&z.C0.B1).Add(&z.C0.B1, &t[2]) + z.C0.B2.Sub(&t[4], &x.C0.B2).Double(&z.C0.B2).Add(&z.C0.B2, &t[4]) + + z.C1.B0.Add(&t[8], &x.C1.B0).Double(&z.C1.B0).Add(&z.C1.B0, &t[8]) + z.C1.B1.Add(&t[6], &x.C1.B1).Double(&z.C1.B1).Add(&z.C1.B1, &t[6]) + z.C1.B2.Add(&t[7], &x.C1.B2).Double(&z.C1.B2).Add(&z.C1.B2, &t[7]) + + return z +} + +// Inverse set z to the inverse of x in E12 and return z +func (z *E12) Inverse(x *E12) *E12 { + // Algorithm 23 from https://eprint.iacr.org/2010/354.pdf + + var t0, t1, tmp E6 + t0.Square(&x.C0) + t1.Square(&x.C1) + tmp.MulByNonResidue(&t1) + t0.Sub(&t0, &tmp) + t1.Inverse(&t0) + z.C0.Mul(&x.C0, &t1) + z.C1.Mul(&x.C1, &t1).Neg(&z.C1) + + return z +} + +// Exp sets z=x**e and returns it +func (z *E12) Exp(x *E12, e big.Int) *E12 { + var res E12 + res.SetOne() + b := e.Bytes() + for i := range b { + w := b[i] + mask := byte(0x80) + for j := 7; j >= 0; j-- { + res.Square(&res) + if (w&mask)>>j != 0 { + res.Mul(&res, x) + } + mask = mask >> 1 + } + } + z.Set(&res) + return z +} + +// InverseUnitary inverse a unitary element +func (z *E12) InverseUnitary(x *E12) *E12 { + return z.Conjugate(x) +} + +// Conjugate set z to x conjugated and return z +func (z *E12) Conjugate(x *E12) *E12 { + *z = *x + z.C1.Neg(&z.C1) + return z +} + +// SizeOfGT represents the size in bytes that a GT element need in binary form +const SizeOfGT = 32 * 12 + +// Marshal converts z to a byte slice +func (z *E12) Marshal() []byte { + b := z.Bytes() + return b[:] +} + +// Unmarshal is an allias to SetBytes() +func (z *E12) Unmarshal(buf []byte) error { + return z.SetBytes(buf) +} + +// Bytes returns the regular (non montgomery) value +// of z as a big-endian byte array. +// z.C1.B2.A1 | z.C1.B2.A0 | z.C1.B1.A1 | ... +func (z *E12) Bytes() (r [SizeOfGT]byte) { + _z := *z + _z.FromMont() + binary.BigEndian.PutUint64(r[376:384], _z.C0.B0.A0[0]) + binary.BigEndian.PutUint64(r[368:376], _z.C0.B0.A0[1]) + binary.BigEndian.PutUint64(r[360:368], _z.C0.B0.A0[2]) + binary.BigEndian.PutUint64(r[352:360], _z.C0.B0.A0[3]) + + binary.BigEndian.PutUint64(r[344:352], _z.C0.B0.A1[0]) + binary.BigEndian.PutUint64(r[336:344], _z.C0.B0.A1[1]) + binary.BigEndian.PutUint64(r[328:336], _z.C0.B0.A1[2]) + binary.BigEndian.PutUint64(r[320:328], _z.C0.B0.A1[3]) + + binary.BigEndian.PutUint64(r[312:320], _z.C0.B1.A0[0]) + binary.BigEndian.PutUint64(r[304:312], _z.C0.B1.A0[1]) + binary.BigEndian.PutUint64(r[296:304], _z.C0.B1.A0[2]) + binary.BigEndian.PutUint64(r[288:296], _z.C0.B1.A0[3]) + + binary.BigEndian.PutUint64(r[280:288], _z.C0.B1.A1[0]) + binary.BigEndian.PutUint64(r[272:280], _z.C0.B1.A1[1]) + binary.BigEndian.PutUint64(r[264:272], _z.C0.B1.A1[2]) + binary.BigEndian.PutUint64(r[256:264], _z.C0.B1.A1[3]) + + binary.BigEndian.PutUint64(r[248:256], _z.C0.B2.A0[0]) + binary.BigEndian.PutUint64(r[240:248], _z.C0.B2.A0[1]) + binary.BigEndian.PutUint64(r[232:240], _z.C0.B2.A0[2]) + binary.BigEndian.PutUint64(r[224:232], _z.C0.B2.A0[3]) + + binary.BigEndian.PutUint64(r[216:224], _z.C0.B2.A1[0]) + binary.BigEndian.PutUint64(r[208:216], _z.C0.B2.A1[1]) + binary.BigEndian.PutUint64(r[200:208], _z.C0.B2.A1[2]) + binary.BigEndian.PutUint64(r[192:200], _z.C0.B2.A1[3]) + + binary.BigEndian.PutUint64(r[184:192], _z.C1.B0.A0[0]) + binary.BigEndian.PutUint64(r[176:184], _z.C1.B0.A0[1]) + binary.BigEndian.PutUint64(r[168:176], _z.C1.B0.A0[2]) + binary.BigEndian.PutUint64(r[160:168], _z.C1.B0.A0[3]) + + binary.BigEndian.PutUint64(r[152:160], _z.C1.B0.A1[0]) + binary.BigEndian.PutUint64(r[144:152], _z.C1.B0.A1[1]) + binary.BigEndian.PutUint64(r[136:144], _z.C1.B0.A1[2]) + binary.BigEndian.PutUint64(r[128:136], _z.C1.B0.A1[3]) + + binary.BigEndian.PutUint64(r[120:128], _z.C1.B1.A0[0]) + binary.BigEndian.PutUint64(r[112:120], _z.C1.B1.A0[1]) + binary.BigEndian.PutUint64(r[104:112], _z.C1.B1.A0[2]) + binary.BigEndian.PutUint64(r[96:104], _z.C1.B1.A0[3]) + + binary.BigEndian.PutUint64(r[88:96], _z.C1.B1.A1[0]) + binary.BigEndian.PutUint64(r[80:88], _z.C1.B1.A1[1]) + binary.BigEndian.PutUint64(r[72:80], _z.C1.B1.A1[2]) + binary.BigEndian.PutUint64(r[64:72], _z.C1.B1.A1[3]) + + binary.BigEndian.PutUint64(r[56:64], _z.C1.B2.A0[0]) + binary.BigEndian.PutUint64(r[48:56], _z.C1.B2.A0[1]) + binary.BigEndian.PutUint64(r[40:48], _z.C1.B2.A0[2]) + binary.BigEndian.PutUint64(r[32:40], _z.C1.B2.A0[3]) + + binary.BigEndian.PutUint64(r[24:32], _z.C1.B2.A1[0]) + binary.BigEndian.PutUint64(r[16:24], _z.C1.B2.A1[1]) + binary.BigEndian.PutUint64(r[8:16], _z.C1.B2.A1[2]) + binary.BigEndian.PutUint64(r[0:8], _z.C1.B2.A1[3]) + + return +} + +// SetBytes interprets e as the bytes of a big-endian GT +// sets z to that value (in Montgomery form), and returns z. +// size(e) == 32 * 12 +// z.C1.B2.A1 | z.C1.B2.A0 | z.C1.B1.A1 | ... +func (z *E12) SetBytes(e []byte) error { + if len(e) != SizeOfGT { + return errors.New("invalid buffer size") + } + z.C0.B0.A0.SetBytes(e[352 : 352+fp.Bytes]) + + z.C0.B0.A1.SetBytes(e[320 : 320+fp.Bytes]) + + z.C0.B1.A0.SetBytes(e[288 : 288+fp.Bytes]) + + z.C0.B1.A1.SetBytes(e[256 : 256+fp.Bytes]) + + z.C0.B2.A0.SetBytes(e[224 : 224+fp.Bytes]) + + z.C0.B2.A1.SetBytes(e[192 : 192+fp.Bytes]) + + z.C1.B0.A0.SetBytes(e[160 : 160+fp.Bytes]) + + z.C1.B0.A1.SetBytes(e[128 : 128+fp.Bytes]) + + z.C1.B1.A0.SetBytes(e[96 : 96+fp.Bytes]) + + z.C1.B1.A1.SetBytes(e[64 : 64+fp.Bytes]) + + z.C1.B2.A0.SetBytes(e[32 : 32+fp.Bytes]) + + z.C1.B2.A1.SetBytes(e[0 : 0+fp.Bytes]) + + // TODO is it the right place? + //if !z.IsInSubGroup() { + // return errors.New("subgroup check failed") + //} + + return nil +} + +var frModulus = fr.Modulus() + +// IsInSubGroup ensures GT/E12 is in correct sugroup +func (z *E12) IsInSubGroup() bool { + var one, _z E12 + one.SetOne() + _z.Exp(z, *frModulus) + return _z.Equal(&one) +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e12_pairing.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e12_pairing.go new file mode 100644 index 00000000000..6e7d4d3b752 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e12_pairing.go @@ -0,0 +1,130 @@ +package fptower + +import ( + "math/bits" +) + +// MulByVW set z to x*(y*v*w) and return z +// here y*v*w means the E12 element with C1.B1=y and all other components 0 +func (z *E12) MulByVW(x *E12, y *E2) *E12 { + + var result E12 + var yNR E2 + + yNR.MulByNonResidue(y) + result.C0.B0.Mul(&x.C1.B1, &yNR) + result.C0.B1.Mul(&x.C1.B2, &yNR) + result.C0.B2.Mul(&x.C1.B0, y) + result.C1.B0.Mul(&x.C0.B2, &yNR) + result.C1.B1.Mul(&x.C0.B0, y) + result.C1.B2.Mul(&x.C0.B1, y) + z.Set(&result) + return z +} + +// MulByV set z to x*(y*v) and return z +// here y*v means the E12 element with C0.B1=y and all other components 0 +func (z *E12) MulByV(x *E12, y *E2) *E12 { + + var result E12 + var yNR E2 + + yNR.MulByNonResidue(y) + result.C0.B0.Mul(&x.C0.B2, &yNR) + result.C0.B1.Mul(&x.C0.B0, y) + result.C0.B2.Mul(&x.C0.B1, y) + result.C1.B0.Mul(&x.C1.B2, &yNR) + result.C1.B1.Mul(&x.C1.B0, y) + result.C1.B2.Mul(&x.C1.B1, y) + z.Set(&result) + return z +} + +// MulByV2W set z to x*(y*v^2*w) and return z +// here y*v^2*w means the E12 element with C1.B2=y and all other components 0 +func (z *E12) MulByV2W(x *E12, y *E2) *E12 { + + var result E12 + var yNR E2 + + yNR.MulByNonResidue(y) + result.C0.B0.Mul(&x.C1.B0, &yNR) + result.C0.B1.Mul(&x.C1.B1, &yNR) + result.C0.B2.Mul(&x.C1.B2, &yNR) + result.C1.B0.Mul(&x.C0.B1, &yNR) + result.C1.B1.Mul(&x.C0.B2, &yNR) + result.C1.B2.Mul(&x.C0.B0, y) + z.Set(&result) + return z +} + +// Expt set z to x^t in E12 and return z (t is the generator of the BN curve) +func (z *E12) Expt(x *E12) *E12 { + + const tAbsVal uint64 = 4965661367192848881 + + var result E12 + result.Set(x) + + l := bits.Len64(tAbsVal) - 2 + for i := l; i >= 0; i-- { + result.CyclotomicSquare(&result) + if tAbsVal&(1< x +// +func (z *E2) Cmp(x *E2) int { + if a1 := z.A1.Cmp(&x.A1); a1 != 0 { + return a1 + } + return z.A0.Cmp(&x.A0) +} + +// LexicographicallyLargest returns true if this element is strictly lexicographically +// larger than its negation, false otherwise +func (z *E2) LexicographicallyLargest() bool { + // adapted from github.com/zkcrypto/bls12_381 + if z.A1.IsZero() { + return z.A0.LexicographicallyLargest() + } + return z.A1.LexicographicallyLargest() +} + +// SetString sets a E2 element from strings +func (z *E2) SetString(s1, s2 string) *E2 { + z.A0.SetString(s1) + z.A1.SetString(s2) + return z +} + +// SetZero sets an E2 elmt to zero +func (z *E2) SetZero() *E2 { + z.A0.SetZero() + z.A1.SetZero() + return z +} + +// Set sets an E2 from x +func (z *E2) Set(x *E2) *E2 { + z.A0 = x.A0 + z.A1 = x.A1 + return z +} + +// SetOne sets z to 1 in Montgomery form and returns z +func (z *E2) SetOne() *E2 { + z.A0.SetOne() + z.A1.SetZero() + return z +} + +// SetRandom sets a0 and a1 to random values +func (z *E2) SetRandom() (*E2, error) { + if _, err := z.A0.SetRandom(); err != nil { + return nil, err + } + if _, err := z.A1.SetRandom(); err != nil { + return nil, err + } + return z, nil +} + +// IsZero returns true if the two elements are equal, fasle otherwise +func (z *E2) IsZero() bool { + return z.A0.IsZero() && z.A1.IsZero() +} + +// Add adds two elements of E2 +func (z *E2) Add(x, y *E2) *E2 { + addE2(z, x, y) + return z +} + +// Sub two elements of E2 +func (z *E2) Sub(x, y *E2) *E2 { + subE2(z, x, y) + return z +} + +// Double doubles an E2 element +func (z *E2) Double(x *E2) *E2 { + doubleE2(z, x) + return z +} + +// Neg negates an E2 element +func (z *E2) Neg(x *E2) *E2 { + negE2(z, x) + return z +} + +// String implements Stringer interface for fancy printing +func (z *E2) String() string { + return (z.A0.String() + "+" + z.A1.String() + "*u") +} + +// ToMont converts to mont form +func (z *E2) ToMont() *E2 { + z.A0.ToMont() + z.A1.ToMont() + return z +} + +// FromMont converts from mont form +func (z *E2) FromMont() *E2 { + z.A0.FromMont() + z.A1.FromMont() + return z +} + +// MulByElement multiplies an element in E2 by an element in fp +func (z *E2) MulByElement(x *E2, y *fp.Element) *E2 { + var yCopy fp.Element + yCopy.Set(y) + z.A0.Mul(&x.A0, &yCopy) + z.A1.Mul(&x.A1, &yCopy) + return z +} + +// Conjugate conjugates an element in E2 +func (z *E2) Conjugate(x *E2) *E2 { + z.A0 = x.A0 + z.A1.Neg(&x.A1) + return z +} + +// Legendre returns the Legendre symbol of z +func (z *E2) Legendre() int { + var n fp.Element + z.norm(&n) + return n.Legendre() +} + +// Exp sets z=x**e and returns it +func (z *E2) Exp(x E2, exponent *big.Int) *E2 { + z.SetOne() + b := exponent.Bytes() + for i := 0; i < len(b); i++ { + w := b[i] + for j := 0; j < 8; j++ { + z.Square(z) + if (w & (0b10000000 >> j)) != 0 { + z.Mul(z, &x) + } + } + } + + return z +} + +func init() { + q := fp.Modulus() + tmp := big.NewInt(3) + sqrtExp1.Set(q).Sub(&sqrtExp1, tmp).Rsh(&sqrtExp1, 2) + + tmp.SetUint64(1) + sqrtExp2.Set(q).Sub(&sqrtExp2, tmp).Rsh(&sqrtExp2, 1) +} + +var sqrtExp1, sqrtExp2 big.Int + +// Sqrt sets z to the square root of and returns z +// The function does not test wether the square root +// exists or not, it's up to the caller to call +// Legendre beforehand. +// cf https://eprint.iacr.org/2012/685.pdf (algo 9) +func (z *E2) Sqrt(x *E2) *E2 { + + var a1, alpha, b, x0, minusone E2 + + minusone.SetOne().Neg(&minusone) + + a1.Exp(*x, &sqrtExp1) + alpha.Square(&a1). + Mul(&alpha, x) + x0.Mul(x, &a1) + if alpha.Equal(&minusone) { + var c fp.Element + c.Set(&x0.A0) + z.A0.Neg(&x0.A1) + z.A1.Set(&c) + return z + } + a1.SetOne() + b.Add(&a1, &alpha) + + b.Exp(b, &sqrtExp2).Mul(&x0, &b) + z.Set(&b) + return z +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_adx_amd64.s b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_adx_amd64.s new file mode 100644 index 00000000000..cda60cdbb8d --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_adx_amd64.s @@ -0,0 +1,732 @@ +// +build amd64_adx + +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +#include "textflag.h" +#include "funcdata.h" + +// modulus q +DATA q<>+0(SB)/8, $0x3c208c16d87cfd47 +DATA q<>+8(SB)/8, $0x97816a916871ca8d +DATA q<>+16(SB)/8, $0xb85045b68181585d +DATA q<>+24(SB)/8, $0x30644e72e131a029 +GLOBL q<>(SB), (RODATA+NOPTR), $32 + +// qInv0 q'[0] +DATA qInv0<>(SB)/8, $0x87d20782e4866389 +GLOBL qInv0<>(SB), (RODATA+NOPTR), $8 + +#define REDUCE(ra0, ra1, ra2, ra3, rb0, rb1, rb2, rb3) \ + MOVQ ra0, rb0; \ + SUBQ q<>(SB), ra0; \ + MOVQ ra1, rb1; \ + SBBQ q<>+8(SB), ra1; \ + MOVQ ra2, rb2; \ + SBBQ q<>+16(SB), ra2; \ + MOVQ ra3, rb3; \ + SBBQ q<>+24(SB), ra3; \ + CMOVQCS rb0, ra0; \ + CMOVQCS rb1, ra1; \ + CMOVQCS rb2, ra2; \ + CMOVQCS rb3, ra3; \ + +// this code is generated and identical to fp.Mul(...) +#define MUL() \ + XORQ AX, AX; \ + MOVQ SI, DX; \ + MULXQ R14, R10, R11; \ + MULXQ R15, AX, R12; \ + ADOXQ AX, R11; \ + MULXQ CX, AX, R13; \ + ADOXQ AX, R12; \ + MULXQ BX, AX, BP; \ + ADOXQ AX, R13; \ + MOVQ $0, AX; \ + ADOXQ AX, BP; \ + PUSHQ BP; \ + MOVQ qInv0<>(SB), DX; \ + IMULQ R10, DX; \ + XORQ AX, AX; \ + MULXQ q<>+0(SB), AX, BP; \ + ADCXQ R10, AX; \ + MOVQ BP, R10; \ + POPQ BP; \ + ADCXQ R11, R10; \ + MULXQ q<>+8(SB), AX, R11; \ + ADOXQ AX, R10; \ + ADCXQ R12, R11; \ + MULXQ q<>+16(SB), AX, R12; \ + ADOXQ AX, R11; \ + ADCXQ R13, R12; \ + MULXQ q<>+24(SB), AX, R13; \ + ADOXQ AX, R12; \ + MOVQ $0, AX; \ + ADCXQ AX, R13; \ + ADOXQ BP, R13; \ + XORQ AX, AX; \ + MOVQ DI, DX; \ + MULXQ R14, AX, BP; \ + ADOXQ AX, R10; \ + ADCXQ BP, R11; \ + MULXQ R15, AX, BP; \ + ADOXQ AX, R11; \ + ADCXQ BP, R12; \ + MULXQ CX, AX, BP; \ + ADOXQ AX, R12; \ + ADCXQ BP, R13; \ + MULXQ BX, AX, BP; \ + ADOXQ AX, R13; \ + MOVQ $0, AX; \ + ADCXQ AX, BP; \ + ADOXQ AX, BP; \ + PUSHQ BP; \ + MOVQ qInv0<>(SB), DX; \ + IMULQ R10, DX; \ + XORQ AX, AX; \ + MULXQ q<>+0(SB), AX, BP; \ + ADCXQ R10, AX; \ + MOVQ BP, R10; \ + POPQ BP; \ + ADCXQ R11, R10; \ + MULXQ q<>+8(SB), AX, R11; \ + ADOXQ AX, R10; \ + ADCXQ R12, R11; \ + MULXQ q<>+16(SB), AX, R12; \ + ADOXQ AX, R11; \ + ADCXQ R13, R12; \ + MULXQ q<>+24(SB), AX, R13; \ + ADOXQ AX, R12; \ + MOVQ $0, AX; \ + ADCXQ AX, R13; \ + ADOXQ BP, R13; \ + XORQ AX, AX; \ + MOVQ R8, DX; \ + MULXQ R14, AX, BP; \ + ADOXQ AX, R10; \ + ADCXQ BP, R11; \ + MULXQ R15, AX, BP; \ + ADOXQ AX, R11; \ + ADCXQ BP, R12; \ + MULXQ CX, AX, BP; \ + ADOXQ AX, R12; \ + ADCXQ BP, R13; \ + MULXQ BX, AX, BP; \ + ADOXQ AX, R13; \ + MOVQ $0, AX; \ + ADCXQ AX, BP; \ + ADOXQ AX, BP; \ + PUSHQ BP; \ + MOVQ qInv0<>(SB), DX; \ + IMULQ R10, DX; \ + XORQ AX, AX; \ + MULXQ q<>+0(SB), AX, BP; \ + ADCXQ R10, AX; \ + MOVQ BP, R10; \ + POPQ BP; \ + ADCXQ R11, R10; \ + MULXQ q<>+8(SB), AX, R11; \ + ADOXQ AX, R10; \ + ADCXQ R12, R11; \ + MULXQ q<>+16(SB), AX, R12; \ + ADOXQ AX, R11; \ + ADCXQ R13, R12; \ + MULXQ q<>+24(SB), AX, R13; \ + ADOXQ AX, R12; \ + MOVQ $0, AX; \ + ADCXQ AX, R13; \ + ADOXQ BP, R13; \ + XORQ AX, AX; \ + MOVQ R9, DX; \ + MULXQ R14, AX, BP; \ + ADOXQ AX, R10; \ + ADCXQ BP, R11; \ + MULXQ R15, AX, BP; \ + ADOXQ AX, R11; \ + ADCXQ BP, R12; \ + MULXQ CX, AX, BP; \ + ADOXQ AX, R12; \ + ADCXQ BP, R13; \ + MULXQ BX, AX, BP; \ + ADOXQ AX, R13; \ + MOVQ $0, AX; \ + ADCXQ AX, BP; \ + ADOXQ AX, BP; \ + PUSHQ BP; \ + MOVQ qInv0<>(SB), DX; \ + IMULQ R10, DX; \ + XORQ AX, AX; \ + MULXQ q<>+0(SB), AX, BP; \ + ADCXQ R10, AX; \ + MOVQ BP, R10; \ + POPQ BP; \ + ADCXQ R11, R10; \ + MULXQ q<>+8(SB), AX, R11; \ + ADOXQ AX, R10; \ + ADCXQ R12, R11; \ + MULXQ q<>+16(SB), AX, R12; \ + ADOXQ AX, R11; \ + ADCXQ R13, R12; \ + MULXQ q<>+24(SB), AX, R13; \ + ADOXQ AX, R12; \ + MOVQ $0, AX; \ + ADCXQ AX, R13; \ + ADOXQ BP, R13; \ + +TEXT ·addE2(SB), NOSPLIT, $0-24 + MOVQ x+8(FP), AX + MOVQ 0(AX), BX + MOVQ 8(AX), SI + MOVQ 16(AX), DI + MOVQ 24(AX), R8 + MOVQ y+16(FP), DX + ADDQ 0(DX), BX + ADCQ 8(DX), SI + ADCQ 16(DX), DI + ADCQ 24(DX), R8 + + // reduce element(BX,SI,DI,R8) using temp registers (R9,R10,R11,R12) + REDUCE(BX,SI,DI,R8,R9,R10,R11,R12) + + MOVQ res+0(FP), CX + MOVQ BX, 0(CX) + MOVQ SI, 8(CX) + MOVQ DI, 16(CX) + MOVQ R8, 24(CX) + MOVQ 32(AX), BX + MOVQ 40(AX), SI + MOVQ 48(AX), DI + MOVQ 56(AX), R8 + ADDQ 32(DX), BX + ADCQ 40(DX), SI + ADCQ 48(DX), DI + ADCQ 56(DX), R8 + + // reduce element(BX,SI,DI,R8) using temp registers (R13,R14,R15,R9) + REDUCE(BX,SI,DI,R8,R13,R14,R15,R9) + + MOVQ BX, 32(CX) + MOVQ SI, 40(CX) + MOVQ DI, 48(CX) + MOVQ R8, 56(CX) + RET + +TEXT ·doubleE2(SB), NOSPLIT, $0-16 + MOVQ res+0(FP), DX + MOVQ x+8(FP), AX + MOVQ 0(AX), CX + MOVQ 8(AX), BX + MOVQ 16(AX), SI + MOVQ 24(AX), DI + ADDQ CX, CX + ADCQ BX, BX + ADCQ SI, SI + ADCQ DI, DI + + // reduce element(CX,BX,SI,DI) using temp registers (R8,R9,R10,R11) + REDUCE(CX,BX,SI,DI,R8,R9,R10,R11) + + MOVQ CX, 0(DX) + MOVQ BX, 8(DX) + MOVQ SI, 16(DX) + MOVQ DI, 24(DX) + MOVQ 32(AX), CX + MOVQ 40(AX), BX + MOVQ 48(AX), SI + MOVQ 56(AX), DI + ADDQ CX, CX + ADCQ BX, BX + ADCQ SI, SI + ADCQ DI, DI + + // reduce element(CX,BX,SI,DI) using temp registers (R12,R13,R14,R15) + REDUCE(CX,BX,SI,DI,R12,R13,R14,R15) + + MOVQ CX, 32(DX) + MOVQ BX, 40(DX) + MOVQ SI, 48(DX) + MOVQ DI, 56(DX) + RET + +TEXT ·subE2(SB), NOSPLIT, $0-24 + XORQ DI, DI + MOVQ x+8(FP), SI + MOVQ 0(SI), AX + MOVQ 8(SI), DX + MOVQ 16(SI), CX + MOVQ 24(SI), BX + MOVQ y+16(FP), SI + SUBQ 0(SI), AX + SBBQ 8(SI), DX + SBBQ 16(SI), CX + SBBQ 24(SI), BX + MOVQ x+8(FP), SI + MOVQ $0x3c208c16d87cfd47, R8 + MOVQ $0x97816a916871ca8d, R9 + MOVQ $0xb85045b68181585d, R10 + MOVQ $0x30644e72e131a029, R11 + CMOVQCC DI, R8 + CMOVQCC DI, R9 + CMOVQCC DI, R10 + CMOVQCC DI, R11 + ADDQ R8, AX + ADCQ R9, DX + ADCQ R10, CX + ADCQ R11, BX + MOVQ res+0(FP), R12 + MOVQ AX, 0(R12) + MOVQ DX, 8(R12) + MOVQ CX, 16(R12) + MOVQ BX, 24(R12) + MOVQ 32(SI), AX + MOVQ 40(SI), DX + MOVQ 48(SI), CX + MOVQ 56(SI), BX + MOVQ y+16(FP), SI + SUBQ 32(SI), AX + SBBQ 40(SI), DX + SBBQ 48(SI), CX + SBBQ 56(SI), BX + MOVQ $0x3c208c16d87cfd47, R13 + MOVQ $0x97816a916871ca8d, R14 + MOVQ $0xb85045b68181585d, R15 + MOVQ $0x30644e72e131a029, R8 + CMOVQCC DI, R13 + CMOVQCC DI, R14 + CMOVQCC DI, R15 + CMOVQCC DI, R8 + ADDQ R13, AX + ADCQ R14, DX + ADCQ R15, CX + ADCQ R8, BX + MOVQ res+0(FP), SI + MOVQ AX, 32(SI) + MOVQ DX, 40(SI) + MOVQ CX, 48(SI) + MOVQ BX, 56(SI) + RET + +TEXT ·negE2(SB), NOSPLIT, $0-16 + MOVQ res+0(FP), DX + MOVQ x+8(FP), AX + MOVQ 0(AX), BX + MOVQ 8(AX), SI + MOVQ 16(AX), DI + MOVQ 24(AX), R8 + MOVQ BX, AX + ORQ SI, AX + ORQ DI, AX + ORQ R8, AX + TESTQ AX, AX + JNE l1 + MOVQ AX, 32(DX) + MOVQ AX, 40(DX) + MOVQ AX, 48(DX) + MOVQ AX, 56(DX) + JMP l3 + +l1: + MOVQ $0x3c208c16d87cfd47, CX + SUBQ BX, CX + MOVQ CX, 0(DX) + MOVQ $0x97816a916871ca8d, CX + SBBQ SI, CX + MOVQ CX, 8(DX) + MOVQ $0xb85045b68181585d, CX + SBBQ DI, CX + MOVQ CX, 16(DX) + MOVQ $0x30644e72e131a029, CX + SBBQ R8, CX + MOVQ CX, 24(DX) + +l3: + MOVQ x+8(FP), AX + MOVQ 32(AX), BX + MOVQ 40(AX), SI + MOVQ 48(AX), DI + MOVQ 56(AX), R8 + MOVQ BX, AX + ORQ SI, AX + ORQ DI, AX + ORQ R8, AX + TESTQ AX, AX + JNE l2 + MOVQ AX, 32(DX) + MOVQ AX, 40(DX) + MOVQ AX, 48(DX) + MOVQ AX, 56(DX) + RET + +l2: + MOVQ $0x3c208c16d87cfd47, CX + SUBQ BX, CX + MOVQ CX, 32(DX) + MOVQ $0x97816a916871ca8d, CX + SBBQ SI, CX + MOVQ CX, 40(DX) + MOVQ $0xb85045b68181585d, CX + SBBQ DI, CX + MOVQ CX, 48(DX) + MOVQ $0x30644e72e131a029, CX + SBBQ R8, CX + MOVQ CX, 56(DX) + RET + +TEXT ·mulNonResE2(SB), NOSPLIT, $0-16 + MOVQ x+8(FP), R10 + MOVQ 0(R10), AX + MOVQ 8(R10), DX + MOVQ 16(R10), CX + MOVQ 24(R10), BX + ADDQ AX, AX + ADCQ DX, DX + ADCQ CX, CX + ADCQ BX, BX + + // reduce element(AX,DX,CX,BX) using temp registers (R11,R12,R13,R14) + REDUCE(AX,DX,CX,BX,R11,R12,R13,R14) + + ADDQ AX, AX + ADCQ DX, DX + ADCQ CX, CX + ADCQ BX, BX + + // reduce element(AX,DX,CX,BX) using temp registers (R15,R11,R12,R13) + REDUCE(AX,DX,CX,BX,R15,R11,R12,R13) + + ADDQ AX, AX + ADCQ DX, DX + ADCQ CX, CX + ADCQ BX, BX + + // reduce element(AX,DX,CX,BX) using temp registers (R14,R15,R11,R12) + REDUCE(AX,DX,CX,BX,R14,R15,R11,R12) + + ADDQ 0(R10), AX + ADCQ 8(R10), DX + ADCQ 16(R10), CX + ADCQ 24(R10), BX + + // reduce element(AX,DX,CX,BX) using temp registers (R13,R14,R15,R11) + REDUCE(AX,DX,CX,BX,R13,R14,R15,R11) + + MOVQ 32(R10), SI + MOVQ 40(R10), DI + MOVQ 48(R10), R8 + MOVQ 56(R10), R9 + XORQ R12, R12 + SUBQ SI, AX + SBBQ DI, DX + SBBQ R8, CX + SBBQ R9, BX + MOVQ $0x3c208c16d87cfd47, R13 + MOVQ $0x97816a916871ca8d, R14 + MOVQ $0xb85045b68181585d, R15 + MOVQ $0x30644e72e131a029, R11 + CMOVQCC R12, R13 + CMOVQCC R12, R14 + CMOVQCC R12, R15 + CMOVQCC R12, R11 + ADDQ R13, AX + ADCQ R14, DX + ADCQ R15, CX + ADCQ R11, BX + ADDQ SI, SI + ADCQ DI, DI + ADCQ R8, R8 + ADCQ R9, R9 + + // reduce element(SI,DI,R8,R9) using temp registers (R13,R14,R15,R11) + REDUCE(SI,DI,R8,R9,R13,R14,R15,R11) + + ADDQ SI, SI + ADCQ DI, DI + ADCQ R8, R8 + ADCQ R9, R9 + + // reduce element(SI,DI,R8,R9) using temp registers (R12,R13,R14,R15) + REDUCE(SI,DI,R8,R9,R12,R13,R14,R15) + + ADDQ SI, SI + ADCQ DI, DI + ADCQ R8, R8 + ADCQ R9, R9 + + // reduce element(SI,DI,R8,R9) using temp registers (R11,R12,R13,R14) + REDUCE(SI,DI,R8,R9,R11,R12,R13,R14) + + ADDQ 32(R10), SI + ADCQ 40(R10), DI + ADCQ 48(R10), R8 + ADCQ 56(R10), R9 + + // reduce element(SI,DI,R8,R9) using temp registers (R15,R11,R12,R13) + REDUCE(SI,DI,R8,R9,R15,R11,R12,R13) + + ADDQ 0(R10), SI + ADCQ 8(R10), DI + ADCQ 16(R10), R8 + ADCQ 24(R10), R9 + + // reduce element(SI,DI,R8,R9) using temp registers (R14,R15,R11,R12) + REDUCE(SI,DI,R8,R9,R14,R15,R11,R12) + + MOVQ res+0(FP), R10 + MOVQ AX, 0(R10) + MOVQ DX, 8(R10) + MOVQ CX, 16(R10) + MOVQ BX, 24(R10) + MOVQ SI, 32(R10) + MOVQ DI, 40(R10) + MOVQ R8, 48(R10) + MOVQ R9, 56(R10) + RET + +TEXT ·mulAdxE2(SB), $64-24 + NO_LOCAL_POINTERS + + // var a, b, c fp.Element + // a.Add(&x.A0, &x.A1) + // b.Add(&y.A0, &y.A1) + // a.Mul(&a, &b) + // b.Mul(&x.A0, &y.A0) + // c.Mul(&x.A1, &y.A1) + // z.A1.Sub(&a, &b).Sub(&z.A1, &c) + // z.A0.Sub(&b, &c) + + MOVQ x+8(FP), AX + MOVQ y+16(FP), DX + MOVQ 32(AX), R14 + MOVQ 40(AX), R15 + MOVQ 48(AX), CX + MOVQ 56(AX), BX + MOVQ 32(DX), SI + MOVQ 40(DX), DI + MOVQ 48(DX), R8 + MOVQ 56(DX), R9 + + // mul (R14,R15,CX,BX) with (SI,DI,R8,R9) into (R10,R11,R12,R13) + MUL() + + // reduce element(R10,R11,R12,R13) using temp registers (SI,DI,R8,R9) + REDUCE(R10,R11,R12,R13,SI,DI,R8,R9) + + MOVQ R10, s4-40(SP) + MOVQ R11, s5-48(SP) + MOVQ R12, s6-56(SP) + MOVQ R13, s7-64(SP) + MOVQ x+8(FP), AX + MOVQ y+16(FP), DX + ADDQ 0(AX), R14 + ADCQ 8(AX), R15 + ADCQ 16(AX), CX + ADCQ 24(AX), BX + MOVQ 0(DX), SI + MOVQ 8(DX), DI + MOVQ 16(DX), R8 + MOVQ 24(DX), R9 + ADDQ 32(DX), SI + ADCQ 40(DX), DI + ADCQ 48(DX), R8 + ADCQ 56(DX), R9 + + // mul (R14,R15,CX,BX) with (SI,DI,R8,R9) into (R10,R11,R12,R13) + MUL() + + // reduce element(R10,R11,R12,R13) using temp registers (SI,DI,R8,R9) + REDUCE(R10,R11,R12,R13,SI,DI,R8,R9) + + MOVQ R10, s0-8(SP) + MOVQ R11, s1-16(SP) + MOVQ R12, s2-24(SP) + MOVQ R13, s3-32(SP) + MOVQ x+8(FP), AX + MOVQ y+16(FP), DX + MOVQ 0(AX), R14 + MOVQ 8(AX), R15 + MOVQ 16(AX), CX + MOVQ 24(AX), BX + MOVQ 0(DX), SI + MOVQ 8(DX), DI + MOVQ 16(DX), R8 + MOVQ 24(DX), R9 + + // mul (R14,R15,CX,BX) with (SI,DI,R8,R9) into (R10,R11,R12,R13) + MUL() + + // reduce element(R10,R11,R12,R13) using temp registers (SI,DI,R8,R9) + REDUCE(R10,R11,R12,R13,SI,DI,R8,R9) + + XORQ DX, DX + MOVQ s0-8(SP), R14 + MOVQ s1-16(SP), R15 + MOVQ s2-24(SP), CX + MOVQ s3-32(SP), BX + SUBQ R10, R14 + SBBQ R11, R15 + SBBQ R12, CX + SBBQ R13, BX + MOVQ $0x3c208c16d87cfd47, SI + MOVQ $0x97816a916871ca8d, DI + MOVQ $0xb85045b68181585d, R8 + MOVQ $0x30644e72e131a029, R9 + CMOVQCC DX, SI + CMOVQCC DX, DI + CMOVQCC DX, R8 + CMOVQCC DX, R9 + ADDQ SI, R14 + ADCQ DI, R15 + ADCQ R8, CX + ADCQ R9, BX + SUBQ s4-40(SP), R14 + SBBQ s5-48(SP), R15 + SBBQ s6-56(SP), CX + SBBQ s7-64(SP), BX + MOVQ $0x3c208c16d87cfd47, SI + MOVQ $0x97816a916871ca8d, DI + MOVQ $0xb85045b68181585d, R8 + MOVQ $0x30644e72e131a029, R9 + CMOVQCC DX, SI + CMOVQCC DX, DI + CMOVQCC DX, R8 + CMOVQCC DX, R9 + ADDQ SI, R14 + ADCQ DI, R15 + ADCQ R8, CX + ADCQ R9, BX + MOVQ res+0(FP), AX + MOVQ R14, 32(AX) + MOVQ R15, 40(AX) + MOVQ CX, 48(AX) + MOVQ BX, 56(AX) + MOVQ s4-40(SP), SI + MOVQ s5-48(SP), DI + MOVQ s6-56(SP), R8 + MOVQ s7-64(SP), R9 + SUBQ SI, R10 + SBBQ DI, R11 + SBBQ R8, R12 + SBBQ R9, R13 + MOVQ $0x3c208c16d87cfd47, R14 + MOVQ $0x97816a916871ca8d, R15 + MOVQ $0xb85045b68181585d, CX + MOVQ $0x30644e72e131a029, BX + CMOVQCC DX, R14 + CMOVQCC DX, R15 + CMOVQCC DX, CX + CMOVQCC DX, BX + ADDQ R14, R10 + ADCQ R15, R11 + ADCQ CX, R12 + ADCQ BX, R13 + MOVQ R10, 0(AX) + MOVQ R11, 8(AX) + MOVQ R12, 16(AX) + MOVQ R13, 24(AX) + RET + +TEXT ·squareAdxE2(SB), NOSPLIT, $0-16 + NO_LOCAL_POINTERS + + // z.A0 = (x.A0 + x.A1) * (x.A0 - x.A1) + // z.A1 = 2 * x.A0 * x.A1 + + // 2 * x.A0 * x.A1 + MOVQ x+8(FP), AX + + // x.A0[0] -> SI + // x.A0[1] -> DI + // x.A0[2] -> R8 + // x.A0[3] -> R9 + MOVQ 0(AX), SI + MOVQ 8(AX), DI + MOVQ 16(AX), R8 + MOVQ 24(AX), R9 + + // 2 * x.A1[0] -> R14 + // 2 * x.A1[1] -> R15 + // 2 * x.A1[2] -> CX + // 2 * x.A1[3] -> BX + MOVQ 32(AX), R14 + MOVQ 40(AX), R15 + MOVQ 48(AX), CX + MOVQ 56(AX), BX + ADDQ R14, R14 + ADCQ R15, R15 + ADCQ CX, CX + ADCQ BX, BX + + // mul (R14,R15,CX,BX) with (SI,DI,R8,R9) into (R10,R11,R12,R13) + MUL() + + // reduce element(R10,R11,R12,R13) using temp registers (R14,R15,CX,BX) + REDUCE(R10,R11,R12,R13,R14,R15,CX,BX) + + MOVQ x+8(FP), AX + + // x.A1[0] -> R14 + // x.A1[1] -> R15 + // x.A1[2] -> CX + // x.A1[3] -> BX + MOVQ 32(AX), R14 + MOVQ 40(AX), R15 + MOVQ 48(AX), CX + MOVQ 56(AX), BX + MOVQ res+0(FP), DX + MOVQ R10, 32(DX) + MOVQ R11, 40(DX) + MOVQ R12, 48(DX) + MOVQ R13, 56(DX) + MOVQ R14, R10 + MOVQ R15, R11 + MOVQ CX, R12 + MOVQ BX, R13 + + // Add(&x.A0, &x.A1) + ADDQ SI, R14 + ADCQ DI, R15 + ADCQ R8, CX + ADCQ R9, BX + XORQ BP, BP + + // Sub(&x.A0, &x.A1) + SUBQ R10, SI + SBBQ R11, DI + SBBQ R12, R8 + SBBQ R13, R9 + MOVQ $0x3c208c16d87cfd47, R10 + MOVQ $0x97816a916871ca8d, R11 + MOVQ $0xb85045b68181585d, R12 + MOVQ $0x30644e72e131a029, R13 + CMOVQCC BP, R10 + CMOVQCC BP, R11 + CMOVQCC BP, R12 + CMOVQCC BP, R13 + ADDQ R10, SI + ADCQ R11, DI + ADCQ R12, R8 + ADCQ R13, R9 + + // mul (R14,R15,CX,BX) with (SI,DI,R8,R9) into (R10,R11,R12,R13) + MUL() + + // reduce element(R10,R11,R12,R13) using temp registers (R14,R15,CX,BX) + REDUCE(R10,R11,R12,R13,R14,R15,CX,BX) + + MOVQ res+0(FP), AX + MOVQ R10, 0(AX) + MOVQ R11, 8(AX) + MOVQ R12, 16(AX) + MOVQ R13, 24(AX) + RET diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_amd64.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_amd64.go new file mode 100644 index 00000000000..7f5b3d3f5e3 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_amd64.go @@ -0,0 +1,70 @@ +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package fptower + +// q (modulus) +var qE2 = [4]uint64{ + 4332616871279656263, + 10917124144477883021, + 13281191951274694749, + 3486998266802970665, +} + +// q'[0], see montgommery multiplication algorithm +var ( + qE2Inv0 uint64 = 9786893198990664585 + _ = qE2Inv0 // used in asm +) + +//go:noescape +func addE2(res, x, y *E2) + +//go:noescape +func subE2(res, x, y *E2) + +//go:noescape +func doubleE2(res, x *E2) + +//go:noescape +func negE2(res, x *E2) + +//go:noescape +func mulNonResE2(res, x *E2) + +//go:noescape +func squareAdxE2(res, x *E2) + +//go:noescape +func mulAdxE2(res, x, y *E2) + +// MulByNonResidue multiplies a E2 by (9,1) +func (z *E2) MulByNonResidue(x *E2) *E2 { + mulNonResE2(z, x) + return z +} + +// Mul sets z to the E2-product of x,y, returns z +func (z *E2) Mul(x, y *E2) *E2 { + mulAdxE2(z, x, y) + return z +} + +// Square sets z to the E2-product of x,x, returns z +func (z *E2) Square(x *E2) *E2 { + squareAdxE2(z, x) + return z +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_amd64.s b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_amd64.s new file mode 100644 index 00000000000..48a1035bae4 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_amd64.s @@ -0,0 +1,755 @@ +// +build !amd64_adx + +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +#include "textflag.h" +#include "funcdata.h" + +// modulus q +DATA q<>+0(SB)/8, $0x3c208c16d87cfd47 +DATA q<>+8(SB)/8, $0x97816a916871ca8d +DATA q<>+16(SB)/8, $0xb85045b68181585d +DATA q<>+24(SB)/8, $0x30644e72e131a029 +GLOBL q<>(SB), (RODATA+NOPTR), $32 + +// qInv0 q'[0] +DATA qInv0<>(SB)/8, $0x87d20782e4866389 +GLOBL qInv0<>(SB), (RODATA+NOPTR), $8 + +#define REDUCE(ra0, ra1, ra2, ra3, rb0, rb1, rb2, rb3) \ + MOVQ ra0, rb0; \ + SUBQ q<>(SB), ra0; \ + MOVQ ra1, rb1; \ + SBBQ q<>+8(SB), ra1; \ + MOVQ ra2, rb2; \ + SBBQ q<>+16(SB), ra2; \ + MOVQ ra3, rb3; \ + SBBQ q<>+24(SB), ra3; \ + CMOVQCS rb0, ra0; \ + CMOVQCS rb1, ra1; \ + CMOVQCS rb2, ra2; \ + CMOVQCS rb3, ra3; \ + +// this code is generated and identical to fp.Mul(...) +#define MUL() \ + XORQ AX, AX; \ + MOVQ SI, DX; \ + MULXQ R14, R10, R11; \ + MULXQ R15, AX, R12; \ + ADOXQ AX, R11; \ + MULXQ CX, AX, R13; \ + ADOXQ AX, R12; \ + MULXQ BX, AX, BP; \ + ADOXQ AX, R13; \ + MOVQ $0, AX; \ + ADOXQ AX, BP; \ + PUSHQ BP; \ + MOVQ qInv0<>(SB), DX; \ + IMULQ R10, DX; \ + XORQ AX, AX; \ + MULXQ q<>+0(SB), AX, BP; \ + ADCXQ R10, AX; \ + MOVQ BP, R10; \ + POPQ BP; \ + ADCXQ R11, R10; \ + MULXQ q<>+8(SB), AX, R11; \ + ADOXQ AX, R10; \ + ADCXQ R12, R11; \ + MULXQ q<>+16(SB), AX, R12; \ + ADOXQ AX, R11; \ + ADCXQ R13, R12; \ + MULXQ q<>+24(SB), AX, R13; \ + ADOXQ AX, R12; \ + MOVQ $0, AX; \ + ADCXQ AX, R13; \ + ADOXQ BP, R13; \ + XORQ AX, AX; \ + MOVQ DI, DX; \ + MULXQ R14, AX, BP; \ + ADOXQ AX, R10; \ + ADCXQ BP, R11; \ + MULXQ R15, AX, BP; \ + ADOXQ AX, R11; \ + ADCXQ BP, R12; \ + MULXQ CX, AX, BP; \ + ADOXQ AX, R12; \ + ADCXQ BP, R13; \ + MULXQ BX, AX, BP; \ + ADOXQ AX, R13; \ + MOVQ $0, AX; \ + ADCXQ AX, BP; \ + ADOXQ AX, BP; \ + PUSHQ BP; \ + MOVQ qInv0<>(SB), DX; \ + IMULQ R10, DX; \ + XORQ AX, AX; \ + MULXQ q<>+0(SB), AX, BP; \ + ADCXQ R10, AX; \ + MOVQ BP, R10; \ + POPQ BP; \ + ADCXQ R11, R10; \ + MULXQ q<>+8(SB), AX, R11; \ + ADOXQ AX, R10; \ + ADCXQ R12, R11; \ + MULXQ q<>+16(SB), AX, R12; \ + ADOXQ AX, R11; \ + ADCXQ R13, R12; \ + MULXQ q<>+24(SB), AX, R13; \ + ADOXQ AX, R12; \ + MOVQ $0, AX; \ + ADCXQ AX, R13; \ + ADOXQ BP, R13; \ + XORQ AX, AX; \ + MOVQ R8, DX; \ + MULXQ R14, AX, BP; \ + ADOXQ AX, R10; \ + ADCXQ BP, R11; \ + MULXQ R15, AX, BP; \ + ADOXQ AX, R11; \ + ADCXQ BP, R12; \ + MULXQ CX, AX, BP; \ + ADOXQ AX, R12; \ + ADCXQ BP, R13; \ + MULXQ BX, AX, BP; \ + ADOXQ AX, R13; \ + MOVQ $0, AX; \ + ADCXQ AX, BP; \ + ADOXQ AX, BP; \ + PUSHQ BP; \ + MOVQ qInv0<>(SB), DX; \ + IMULQ R10, DX; \ + XORQ AX, AX; \ + MULXQ q<>+0(SB), AX, BP; \ + ADCXQ R10, AX; \ + MOVQ BP, R10; \ + POPQ BP; \ + ADCXQ R11, R10; \ + MULXQ q<>+8(SB), AX, R11; \ + ADOXQ AX, R10; \ + ADCXQ R12, R11; \ + MULXQ q<>+16(SB), AX, R12; \ + ADOXQ AX, R11; \ + ADCXQ R13, R12; \ + MULXQ q<>+24(SB), AX, R13; \ + ADOXQ AX, R12; \ + MOVQ $0, AX; \ + ADCXQ AX, R13; \ + ADOXQ BP, R13; \ + XORQ AX, AX; \ + MOVQ R9, DX; \ + MULXQ R14, AX, BP; \ + ADOXQ AX, R10; \ + ADCXQ BP, R11; \ + MULXQ R15, AX, BP; \ + ADOXQ AX, R11; \ + ADCXQ BP, R12; \ + MULXQ CX, AX, BP; \ + ADOXQ AX, R12; \ + ADCXQ BP, R13; \ + MULXQ BX, AX, BP; \ + ADOXQ AX, R13; \ + MOVQ $0, AX; \ + ADCXQ AX, BP; \ + ADOXQ AX, BP; \ + PUSHQ BP; \ + MOVQ qInv0<>(SB), DX; \ + IMULQ R10, DX; \ + XORQ AX, AX; \ + MULXQ q<>+0(SB), AX, BP; \ + ADCXQ R10, AX; \ + MOVQ BP, R10; \ + POPQ BP; \ + ADCXQ R11, R10; \ + MULXQ q<>+8(SB), AX, R11; \ + ADOXQ AX, R10; \ + ADCXQ R12, R11; \ + MULXQ q<>+16(SB), AX, R12; \ + ADOXQ AX, R11; \ + ADCXQ R13, R12; \ + MULXQ q<>+24(SB), AX, R13; \ + ADOXQ AX, R12; \ + MOVQ $0, AX; \ + ADCXQ AX, R13; \ + ADOXQ BP, R13; \ + +TEXT ·addE2(SB), NOSPLIT, $0-24 + MOVQ x+8(FP), AX + MOVQ 0(AX), BX + MOVQ 8(AX), SI + MOVQ 16(AX), DI + MOVQ 24(AX), R8 + MOVQ y+16(FP), DX + ADDQ 0(DX), BX + ADCQ 8(DX), SI + ADCQ 16(DX), DI + ADCQ 24(DX), R8 + + // reduce element(BX,SI,DI,R8) using temp registers (R9,R10,R11,R12) + REDUCE(BX,SI,DI,R8,R9,R10,R11,R12) + + MOVQ res+0(FP), CX + MOVQ BX, 0(CX) + MOVQ SI, 8(CX) + MOVQ DI, 16(CX) + MOVQ R8, 24(CX) + MOVQ 32(AX), BX + MOVQ 40(AX), SI + MOVQ 48(AX), DI + MOVQ 56(AX), R8 + ADDQ 32(DX), BX + ADCQ 40(DX), SI + ADCQ 48(DX), DI + ADCQ 56(DX), R8 + + // reduce element(BX,SI,DI,R8) using temp registers (R13,R14,R15,R9) + REDUCE(BX,SI,DI,R8,R13,R14,R15,R9) + + MOVQ BX, 32(CX) + MOVQ SI, 40(CX) + MOVQ DI, 48(CX) + MOVQ R8, 56(CX) + RET + +TEXT ·doubleE2(SB), NOSPLIT, $0-16 + MOVQ res+0(FP), DX + MOVQ x+8(FP), AX + MOVQ 0(AX), CX + MOVQ 8(AX), BX + MOVQ 16(AX), SI + MOVQ 24(AX), DI + ADDQ CX, CX + ADCQ BX, BX + ADCQ SI, SI + ADCQ DI, DI + + // reduce element(CX,BX,SI,DI) using temp registers (R8,R9,R10,R11) + REDUCE(CX,BX,SI,DI,R8,R9,R10,R11) + + MOVQ CX, 0(DX) + MOVQ BX, 8(DX) + MOVQ SI, 16(DX) + MOVQ DI, 24(DX) + MOVQ 32(AX), CX + MOVQ 40(AX), BX + MOVQ 48(AX), SI + MOVQ 56(AX), DI + ADDQ CX, CX + ADCQ BX, BX + ADCQ SI, SI + ADCQ DI, DI + + // reduce element(CX,BX,SI,DI) using temp registers (R12,R13,R14,R15) + REDUCE(CX,BX,SI,DI,R12,R13,R14,R15) + + MOVQ CX, 32(DX) + MOVQ BX, 40(DX) + MOVQ SI, 48(DX) + MOVQ DI, 56(DX) + RET + +TEXT ·subE2(SB), NOSPLIT, $0-24 + XORQ DI, DI + MOVQ x+8(FP), SI + MOVQ 0(SI), AX + MOVQ 8(SI), DX + MOVQ 16(SI), CX + MOVQ 24(SI), BX + MOVQ y+16(FP), SI + SUBQ 0(SI), AX + SBBQ 8(SI), DX + SBBQ 16(SI), CX + SBBQ 24(SI), BX + MOVQ x+8(FP), SI + MOVQ $0x3c208c16d87cfd47, R8 + MOVQ $0x97816a916871ca8d, R9 + MOVQ $0xb85045b68181585d, R10 + MOVQ $0x30644e72e131a029, R11 + CMOVQCC DI, R8 + CMOVQCC DI, R9 + CMOVQCC DI, R10 + CMOVQCC DI, R11 + ADDQ R8, AX + ADCQ R9, DX + ADCQ R10, CX + ADCQ R11, BX + MOVQ res+0(FP), R12 + MOVQ AX, 0(R12) + MOVQ DX, 8(R12) + MOVQ CX, 16(R12) + MOVQ BX, 24(R12) + MOVQ 32(SI), AX + MOVQ 40(SI), DX + MOVQ 48(SI), CX + MOVQ 56(SI), BX + MOVQ y+16(FP), SI + SUBQ 32(SI), AX + SBBQ 40(SI), DX + SBBQ 48(SI), CX + SBBQ 56(SI), BX + MOVQ $0x3c208c16d87cfd47, R13 + MOVQ $0x97816a916871ca8d, R14 + MOVQ $0xb85045b68181585d, R15 + MOVQ $0x30644e72e131a029, R8 + CMOVQCC DI, R13 + CMOVQCC DI, R14 + CMOVQCC DI, R15 + CMOVQCC DI, R8 + ADDQ R13, AX + ADCQ R14, DX + ADCQ R15, CX + ADCQ R8, BX + MOVQ res+0(FP), SI + MOVQ AX, 32(SI) + MOVQ DX, 40(SI) + MOVQ CX, 48(SI) + MOVQ BX, 56(SI) + RET + +TEXT ·negE2(SB), NOSPLIT, $0-16 + MOVQ res+0(FP), DX + MOVQ x+8(FP), AX + MOVQ 0(AX), BX + MOVQ 8(AX), SI + MOVQ 16(AX), DI + MOVQ 24(AX), R8 + MOVQ BX, AX + ORQ SI, AX + ORQ DI, AX + ORQ R8, AX + TESTQ AX, AX + JNE l1 + MOVQ AX, 32(DX) + MOVQ AX, 40(DX) + MOVQ AX, 48(DX) + MOVQ AX, 56(DX) + JMP l3 + +l1: + MOVQ $0x3c208c16d87cfd47, CX + SUBQ BX, CX + MOVQ CX, 0(DX) + MOVQ $0x97816a916871ca8d, CX + SBBQ SI, CX + MOVQ CX, 8(DX) + MOVQ $0xb85045b68181585d, CX + SBBQ DI, CX + MOVQ CX, 16(DX) + MOVQ $0x30644e72e131a029, CX + SBBQ R8, CX + MOVQ CX, 24(DX) + +l3: + MOVQ x+8(FP), AX + MOVQ 32(AX), BX + MOVQ 40(AX), SI + MOVQ 48(AX), DI + MOVQ 56(AX), R8 + MOVQ BX, AX + ORQ SI, AX + ORQ DI, AX + ORQ R8, AX + TESTQ AX, AX + JNE l2 + MOVQ AX, 32(DX) + MOVQ AX, 40(DX) + MOVQ AX, 48(DX) + MOVQ AX, 56(DX) + RET + +l2: + MOVQ $0x3c208c16d87cfd47, CX + SUBQ BX, CX + MOVQ CX, 32(DX) + MOVQ $0x97816a916871ca8d, CX + SBBQ SI, CX + MOVQ CX, 40(DX) + MOVQ $0xb85045b68181585d, CX + SBBQ DI, CX + MOVQ CX, 48(DX) + MOVQ $0x30644e72e131a029, CX + SBBQ R8, CX + MOVQ CX, 56(DX) + RET + +TEXT ·mulNonResE2(SB), NOSPLIT, $0-16 + MOVQ x+8(FP), R10 + MOVQ 0(R10), AX + MOVQ 8(R10), DX + MOVQ 16(R10), CX + MOVQ 24(R10), BX + ADDQ AX, AX + ADCQ DX, DX + ADCQ CX, CX + ADCQ BX, BX + + // reduce element(AX,DX,CX,BX) using temp registers (R11,R12,R13,R14) + REDUCE(AX,DX,CX,BX,R11,R12,R13,R14) + + ADDQ AX, AX + ADCQ DX, DX + ADCQ CX, CX + ADCQ BX, BX + + // reduce element(AX,DX,CX,BX) using temp registers (R15,R11,R12,R13) + REDUCE(AX,DX,CX,BX,R15,R11,R12,R13) + + ADDQ AX, AX + ADCQ DX, DX + ADCQ CX, CX + ADCQ BX, BX + + // reduce element(AX,DX,CX,BX) using temp registers (R14,R15,R11,R12) + REDUCE(AX,DX,CX,BX,R14,R15,R11,R12) + + ADDQ 0(R10), AX + ADCQ 8(R10), DX + ADCQ 16(R10), CX + ADCQ 24(R10), BX + + // reduce element(AX,DX,CX,BX) using temp registers (R13,R14,R15,R11) + REDUCE(AX,DX,CX,BX,R13,R14,R15,R11) + + MOVQ 32(R10), SI + MOVQ 40(R10), DI + MOVQ 48(R10), R8 + MOVQ 56(R10), R9 + XORQ R12, R12 + SUBQ SI, AX + SBBQ DI, DX + SBBQ R8, CX + SBBQ R9, BX + MOVQ $0x3c208c16d87cfd47, R13 + MOVQ $0x97816a916871ca8d, R14 + MOVQ $0xb85045b68181585d, R15 + MOVQ $0x30644e72e131a029, R11 + CMOVQCC R12, R13 + CMOVQCC R12, R14 + CMOVQCC R12, R15 + CMOVQCC R12, R11 + ADDQ R13, AX + ADCQ R14, DX + ADCQ R15, CX + ADCQ R11, BX + ADDQ SI, SI + ADCQ DI, DI + ADCQ R8, R8 + ADCQ R9, R9 + + // reduce element(SI,DI,R8,R9) using temp registers (R13,R14,R15,R11) + REDUCE(SI,DI,R8,R9,R13,R14,R15,R11) + + ADDQ SI, SI + ADCQ DI, DI + ADCQ R8, R8 + ADCQ R9, R9 + + // reduce element(SI,DI,R8,R9) using temp registers (R12,R13,R14,R15) + REDUCE(SI,DI,R8,R9,R12,R13,R14,R15) + + ADDQ SI, SI + ADCQ DI, DI + ADCQ R8, R8 + ADCQ R9, R9 + + // reduce element(SI,DI,R8,R9) using temp registers (R11,R12,R13,R14) + REDUCE(SI,DI,R8,R9,R11,R12,R13,R14) + + ADDQ 32(R10), SI + ADCQ 40(R10), DI + ADCQ 48(R10), R8 + ADCQ 56(R10), R9 + + // reduce element(SI,DI,R8,R9) using temp registers (R15,R11,R12,R13) + REDUCE(SI,DI,R8,R9,R15,R11,R12,R13) + + ADDQ 0(R10), SI + ADCQ 8(R10), DI + ADCQ 16(R10), R8 + ADCQ 24(R10), R9 + + // reduce element(SI,DI,R8,R9) using temp registers (R14,R15,R11,R12) + REDUCE(SI,DI,R8,R9,R14,R15,R11,R12) + + MOVQ res+0(FP), R10 + MOVQ AX, 0(R10) + MOVQ DX, 8(R10) + MOVQ CX, 16(R10) + MOVQ BX, 24(R10) + MOVQ SI, 32(R10) + MOVQ DI, 40(R10) + MOVQ R8, 48(R10) + MOVQ R9, 56(R10) + RET + +TEXT ·mulAdxE2(SB), $64-24 + NO_LOCAL_POINTERS + + // var a, b, c fp.Element + // a.Add(&x.A0, &x.A1) + // b.Add(&y.A0, &y.A1) + // a.Mul(&a, &b) + // b.Mul(&x.A0, &y.A0) + // c.Mul(&x.A1, &y.A1) + // z.A1.Sub(&a, &b).Sub(&z.A1, &c) + // z.A0.Sub(&b, &c) + + CMPB ·supportAdx(SB), $1 + JNE l4 + MOVQ x+8(FP), AX + MOVQ y+16(FP), DX + MOVQ 32(AX), R14 + MOVQ 40(AX), R15 + MOVQ 48(AX), CX + MOVQ 56(AX), BX + MOVQ 32(DX), SI + MOVQ 40(DX), DI + MOVQ 48(DX), R8 + MOVQ 56(DX), R9 + + // mul (R14,R15,CX,BX) with (SI,DI,R8,R9) into (R10,R11,R12,R13) + MUL() + + // reduce element(R10,R11,R12,R13) using temp registers (SI,DI,R8,R9) + REDUCE(R10,R11,R12,R13,SI,DI,R8,R9) + + MOVQ R10, s4-40(SP) + MOVQ R11, s5-48(SP) + MOVQ R12, s6-56(SP) + MOVQ R13, s7-64(SP) + MOVQ x+8(FP), AX + MOVQ y+16(FP), DX + ADDQ 0(AX), R14 + ADCQ 8(AX), R15 + ADCQ 16(AX), CX + ADCQ 24(AX), BX + MOVQ 0(DX), SI + MOVQ 8(DX), DI + MOVQ 16(DX), R8 + MOVQ 24(DX), R9 + ADDQ 32(DX), SI + ADCQ 40(DX), DI + ADCQ 48(DX), R8 + ADCQ 56(DX), R9 + + // mul (R14,R15,CX,BX) with (SI,DI,R8,R9) into (R10,R11,R12,R13) + MUL() + + // reduce element(R10,R11,R12,R13) using temp registers (SI,DI,R8,R9) + REDUCE(R10,R11,R12,R13,SI,DI,R8,R9) + + MOVQ R10, s0-8(SP) + MOVQ R11, s1-16(SP) + MOVQ R12, s2-24(SP) + MOVQ R13, s3-32(SP) + MOVQ x+8(FP), AX + MOVQ y+16(FP), DX + MOVQ 0(AX), R14 + MOVQ 8(AX), R15 + MOVQ 16(AX), CX + MOVQ 24(AX), BX + MOVQ 0(DX), SI + MOVQ 8(DX), DI + MOVQ 16(DX), R8 + MOVQ 24(DX), R9 + + // mul (R14,R15,CX,BX) with (SI,DI,R8,R9) into (R10,R11,R12,R13) + MUL() + + // reduce element(R10,R11,R12,R13) using temp registers (SI,DI,R8,R9) + REDUCE(R10,R11,R12,R13,SI,DI,R8,R9) + + XORQ DX, DX + MOVQ s0-8(SP), R14 + MOVQ s1-16(SP), R15 + MOVQ s2-24(SP), CX + MOVQ s3-32(SP), BX + SUBQ R10, R14 + SBBQ R11, R15 + SBBQ R12, CX + SBBQ R13, BX + MOVQ $0x3c208c16d87cfd47, SI + MOVQ $0x97816a916871ca8d, DI + MOVQ $0xb85045b68181585d, R8 + MOVQ $0x30644e72e131a029, R9 + CMOVQCC DX, SI + CMOVQCC DX, DI + CMOVQCC DX, R8 + CMOVQCC DX, R9 + ADDQ SI, R14 + ADCQ DI, R15 + ADCQ R8, CX + ADCQ R9, BX + SUBQ s4-40(SP), R14 + SBBQ s5-48(SP), R15 + SBBQ s6-56(SP), CX + SBBQ s7-64(SP), BX + MOVQ $0x3c208c16d87cfd47, SI + MOVQ $0x97816a916871ca8d, DI + MOVQ $0xb85045b68181585d, R8 + MOVQ $0x30644e72e131a029, R9 + CMOVQCC DX, SI + CMOVQCC DX, DI + CMOVQCC DX, R8 + CMOVQCC DX, R9 + ADDQ SI, R14 + ADCQ DI, R15 + ADCQ R8, CX + ADCQ R9, BX + MOVQ res+0(FP), AX + MOVQ R14, 32(AX) + MOVQ R15, 40(AX) + MOVQ CX, 48(AX) + MOVQ BX, 56(AX) + MOVQ s4-40(SP), SI + MOVQ s5-48(SP), DI + MOVQ s6-56(SP), R8 + MOVQ s7-64(SP), R9 + SUBQ SI, R10 + SBBQ DI, R11 + SBBQ R8, R12 + SBBQ R9, R13 + MOVQ $0x3c208c16d87cfd47, R14 + MOVQ $0x97816a916871ca8d, R15 + MOVQ $0xb85045b68181585d, CX + MOVQ $0x30644e72e131a029, BX + CMOVQCC DX, R14 + CMOVQCC DX, R15 + CMOVQCC DX, CX + CMOVQCC DX, BX + ADDQ R14, R10 + ADCQ R15, R11 + ADCQ CX, R12 + ADCQ BX, R13 + MOVQ R10, 0(AX) + MOVQ R11, 8(AX) + MOVQ R12, 16(AX) + MOVQ R13, 24(AX) + RET + +l4: + MOVQ res+0(FP), AX + MOVQ AX, (SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·mulGenericE2(SB) + RET + +TEXT ·squareAdxE2(SB), $16-16 + NO_LOCAL_POINTERS + + // z.A0 = (x.A0 + x.A1) * (x.A0 - x.A1) + // z.A1 = 2 * x.A0 * x.A1 + + CMPB ·supportAdx(SB), $1 + JNE l5 + + // 2 * x.A0 * x.A1 + MOVQ x+8(FP), AX + + // x.A0[0] -> SI + // x.A0[1] -> DI + // x.A0[2] -> R8 + // x.A0[3] -> R9 + MOVQ 0(AX), SI + MOVQ 8(AX), DI + MOVQ 16(AX), R8 + MOVQ 24(AX), R9 + + // 2 * x.A1[0] -> R14 + // 2 * x.A1[1] -> R15 + // 2 * x.A1[2] -> CX + // 2 * x.A1[3] -> BX + MOVQ 32(AX), R14 + MOVQ 40(AX), R15 + MOVQ 48(AX), CX + MOVQ 56(AX), BX + ADDQ R14, R14 + ADCQ R15, R15 + ADCQ CX, CX + ADCQ BX, BX + + // mul (R14,R15,CX,BX) with (SI,DI,R8,R9) into (R10,R11,R12,R13) + MUL() + + // reduce element(R10,R11,R12,R13) using temp registers (R14,R15,CX,BX) + REDUCE(R10,R11,R12,R13,R14,R15,CX,BX) + + MOVQ x+8(FP), AX + + // x.A1[0] -> R14 + // x.A1[1] -> R15 + // x.A1[2] -> CX + // x.A1[3] -> BX + MOVQ 32(AX), R14 + MOVQ 40(AX), R15 + MOVQ 48(AX), CX + MOVQ 56(AX), BX + MOVQ res+0(FP), DX + MOVQ R10, 32(DX) + MOVQ R11, 40(DX) + MOVQ R12, 48(DX) + MOVQ R13, 56(DX) + MOVQ R14, R10 + MOVQ R15, R11 + MOVQ CX, R12 + MOVQ BX, R13 + + // Add(&x.A0, &x.A1) + ADDQ SI, R14 + ADCQ DI, R15 + ADCQ R8, CX + ADCQ R9, BX + XORQ BP, BP + + // Sub(&x.A0, &x.A1) + SUBQ R10, SI + SBBQ R11, DI + SBBQ R12, R8 + SBBQ R13, R9 + MOVQ $0x3c208c16d87cfd47, R10 + MOVQ $0x97816a916871ca8d, R11 + MOVQ $0xb85045b68181585d, R12 + MOVQ $0x30644e72e131a029, R13 + CMOVQCC BP, R10 + CMOVQCC BP, R11 + CMOVQCC BP, R12 + CMOVQCC BP, R13 + ADDQ R10, SI + ADCQ R11, DI + ADCQ R12, R8 + ADCQ R13, R9 + + // mul (R14,R15,CX,BX) with (SI,DI,R8,R9) into (R10,R11,R12,R13) + MUL() + + // reduce element(R10,R11,R12,R13) using temp registers (R14,R15,CX,BX) + REDUCE(R10,R11,R12,R13,R14,R15,CX,BX) + + MOVQ res+0(FP), AX + MOVQ R10, 0(AX) + MOVQ R11, 8(AX) + MOVQ R12, 16(AX) + MOVQ R13, 24(AX) + RET + +l5: + MOVQ res+0(FP), AX + MOVQ AX, (SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·squareGenericE2(SB) + RET diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_bn254.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_bn254.go new file mode 100644 index 00000000000..0a120c4e687 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_bn254.go @@ -0,0 +1,92 @@ +// Copyright 2020 ConsenSys AG +// +// 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. + +package fptower + +import ( + "github.com/consensys/gnark-crypto/ecc/bn254/fp" +) + +// declaring nonResInverse as global makes MulByNonResInv inlinable +var nonResInverse E2 + +func init() { + nonResInverse.A0 = fp.Element{ + 10477841894441615122, + 7327163185667482322, + 3635199979766503006, + 3215324977242306624, + } + nonResInverse.A1 = fp.Element{ + 7515750141297360845, + 14746352163864140223, + 11319968037783994424, + 30185921062296004, + } +} + +// mulGenericE2 sets z to the E2-product of x,y, returns z +// note: do not rename, this is referenced in the x86 assembly impl +func mulGenericE2(z, x, y *E2) { + var a, b, c fp.Element + a.Add(&x.A0, &x.A1) + b.Add(&y.A0, &y.A1) + a.Mul(&a, &b) + b.Mul(&x.A0, &y.A0) + c.Mul(&x.A1, &y.A1) + z.A1.Sub(&a, &b).Sub(&z.A1, &c) + z.A0.Sub(&b, &c) //z.A0.MulByNonResidue(&c).Add(&z.A0, &b) +} + +// squareGenericE2 sets z to the E2-product of x,x returns z +// note: do not rename, this is referenced in the x86 assembly impl +func squareGenericE2(z, x *E2) *E2 { + // algo 22 https://eprint.iacr.org/2010/354.pdf + var a, b fp.Element + a.Add(&x.A0, &x.A1) + b.Sub(&x.A0, &x.A1) + a.Mul(&a, &b) + b.Mul(&x.A0, &x.A1).Double(&b) + z.A0.Set(&a) + z.A1.Set(&b) + return z +} + +// MulByNonResidueInv multiplies a E2 by (9,1)^{-1} +func (z *E2) MulByNonResidueInv(x *E2) *E2 { + z.Mul(x, &nonResInverse) + return z +} + +// Inverse sets z to the E2-inverse of x, returns z +func (z *E2) Inverse(x *E2) *E2 { + // Algorithm 8 from https://eprint.iacr.org/2010/354.pdf + var t0, t1 fp.Element + t0.Square(&x.A0) + t1.Square(&x.A1) + t0.Add(&t0, &t1) + t1.Inverse(&t0) + z.A0.Mul(&x.A0, &t1) + z.A1.Mul(&x.A1, &t1).Neg(&z.A1) + + return z +} + +// norm sets x to the norm of z +func (z *E2) norm(x *fp.Element) { + var tmp fp.Element + x.Square(&z.A0) + tmp.Square(&z.A1) + x.Add(x, &tmp) +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_bn254_fallback.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_bn254_fallback.go new file mode 100644 index 00000000000..8c04804b23d --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_bn254_fallback.go @@ -0,0 +1,41 @@ +// +build !amd64 + +// Copyright 2020 ConsenSys AG +// +// 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. + +package fptower + +import "github.com/consensys/gnark-crypto/ecc/bn254/fp" + +// MulByNonResidue multiplies a E2 by (9,1) +func (z *E2) MulByNonResidue(x *E2) *E2 { + var a, b fp.Element + a.Double(&x.A0).Double(&a).Double(&a).Add(&a, &x.A0).Sub(&a, &x.A1) + b.Double(&x.A1).Double(&b).Double(&b).Add(&b, &x.A1).Add(&b, &x.A0) + z.A0.Set(&a) + z.A1.Set(&b) + return z +} + +// Mul sets z to the E2-product of x,y, returns z +func (z *E2) Mul(x, y *E2) *E2 { + mulGenericE2(z, x, y) + return z +} + +// Square sets z to the E2-product of x,x returns z +func (z *E2) Square(x *E2) *E2 { + squareGenericE2(z, x) + return z +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_fallback.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_fallback.go new file mode 100644 index 00000000000..eada4c6b580 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e2_fallback.go @@ -0,0 +1,39 @@ +// +build !amd64 + +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package fptower + +func addE2(z, x, y *E2) { + z.A0.Add(&x.A0, &y.A0) + z.A1.Add(&x.A1, &y.A1) +} + +func subE2(z, x, y *E2) { + z.A0.Sub(&x.A0, &y.A0) + z.A1.Sub(&x.A1, &y.A1) +} + +func doubleE2(z, x *E2) { + z.A0.Double(&x.A0) + z.A1.Double(&x.A1) +} + +func negE2(z, x *E2) { + z.A0.Neg(&x.A0) + z.A1.Neg(&x.A1) +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e6.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e6.go new file mode 100644 index 00000000000..5ba35cf0207 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e6.go @@ -0,0 +1,200 @@ +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package fptower + +// E6 is a degree three finite field extension of fp2 +type E6 struct { + B0, B1, B2 E2 +} + +// Equal returns true if z equals x, fasle otherwise +func (z *E6) Equal(x *E6) bool { + return z.B0.Equal(&x.B0) && z.B1.Equal(&x.B1) && z.B2.Equal(&x.B2) +} + +// SetString sets a E6 elmt from stringf +func (z *E6) SetString(s1, s2, s3, s4, s5, s6 string) *E6 { + z.B0.SetString(s1, s2) + z.B1.SetString(s3, s4) + z.B2.SetString(s5, s6) + return z +} + +// Set Sets a E6 elmt form another E6 elmt +func (z *E6) Set(x *E6) *E6 { + z.B0 = x.B0 + z.B1 = x.B1 + z.B2 = x.B2 + return z +} + +// SetOne sets z to 1 in Montgomery form and returns z +func (z *E6) SetOne() *E6 { + *z = E6{} + z.B0.A0.SetOne() + return z +} + +// SetRandom set z to a random elmt +func (z *E6) SetRandom() (*E6, error) { + if _, err := z.B0.SetRandom(); err != nil { + return nil, err + } + if _, err := z.B1.SetRandom(); err != nil { + return nil, err + } + if _, err := z.B2.SetRandom(); err != nil { + return nil, err + } + return z, nil +} + +// ToMont converts to Mont form +func (z *E6) ToMont() *E6 { + z.B0.ToMont() + z.B1.ToMont() + z.B2.ToMont() + return z +} + +// FromMont converts from Mont form +func (z *E6) FromMont() *E6 { + z.B0.FromMont() + z.B1.FromMont() + z.B2.FromMont() + return z +} + +// Add adds two elements of E6 +func (z *E6) Add(x, y *E6) *E6 { + z.B0.Add(&x.B0, &y.B0) + z.B1.Add(&x.B1, &y.B1) + z.B2.Add(&x.B2, &y.B2) + return z +} + +// Neg negates the E6 number +func (z *E6) Neg(x *E6) *E6 { + z.B0.Neg(&x.B0) + z.B1.Neg(&x.B1) + z.B2.Neg(&x.B2) + return z +} + +// Sub two elements of E6 +func (z *E6) Sub(x, y *E6) *E6 { + z.B0.Sub(&x.B0, &y.B0) + z.B1.Sub(&x.B1, &y.B1) + z.B2.Sub(&x.B2, &y.B2) + return z +} + +// Double doubles an element in E6 +func (z *E6) Double(x *E6) *E6 { + z.B0.Double(&x.B0) + z.B1.Double(&x.B1) + z.B2.Double(&x.B2) + return z +} + +// String puts E6 elmt in string form +func (z *E6) String() string { + return (z.B0.String() + "+(" + z.B1.String() + ")*v+(" + z.B2.String() + ")*v**2") +} + +// MulByNonResidue mul x by (0,1,0) +func (z *E6) MulByNonResidue(x *E6) *E6 { + z.B2, z.B1, z.B0 = x.B1, x.B0, x.B2 + z.B0.MulByNonResidue(&z.B0) + return z +} + +// Mul sets z to the E6 product of x,y, returns z +func (z *E6) Mul(x, y *E6) *E6 { + // Algorithm 13 from https://eprint.iacr.org/2010/354.pdf + var t0, t1, t2, c0, c1, c2, tmp E2 + t0.Mul(&x.B0, &y.B0) + t1.Mul(&x.B1, &y.B1) + t2.Mul(&x.B2, &y.B2) + + c0.Add(&x.B1, &x.B2) + tmp.Add(&y.B1, &y.B2) + c0.Mul(&c0, &tmp).Sub(&c0, &t1).Sub(&c0, &t2).MulByNonResidue(&c0).Add(&c0, &t0) + + c1.Add(&x.B0, &x.B1) + tmp.Add(&y.B0, &y.B1) + c1.Mul(&c1, &tmp).Sub(&c1, &t0).Sub(&c1, &t1) + tmp.MulByNonResidue(&t2) + c1.Add(&c1, &tmp) + + tmp.Add(&x.B0, &x.B2) + c2.Add(&y.B0, &y.B2).Mul(&c2, &tmp).Sub(&c2, &t0).Sub(&c2, &t2).Add(&c2, &t1) + + z.B0.Set(&c0) + z.B1.Set(&c1) + z.B2.Set(&c2) + + return z +} + +// Square sets z to the E6 product of x,x, returns z +func (z *E6) Square(x *E6) *E6 { + + // Algorithm 16 from https://eprint.iacr.org/2010/354.pdf + var c4, c5, c1, c2, c3, c0 E2 + c4.Mul(&x.B0, &x.B1).Double(&c4) + c5.Square(&x.B2) + c1.MulByNonResidue(&c5).Add(&c1, &c4) + c2.Sub(&c4, &c5) + c3.Square(&x.B0) + c4.Sub(&x.B0, &x.B1).Add(&c4, &x.B2) + c5.Mul(&x.B1, &x.B2).Double(&c5) + c4.Square(&c4) + c0.MulByNonResidue(&c5).Add(&c0, &c3) + z.B2.Add(&c2, &c4).Add(&z.B2, &c5).Sub(&z.B2, &c3) + z.B0.Set(&c0) + z.B1.Set(&c1) + + return z +} + +// Inverse an element in E6 +func (z *E6) Inverse(x *E6) *E6 { + // Algorithm 17 from https://eprint.iacr.org/2010/354.pdf + // step 9 is wrong in the paper it's t1-t4 + var t0, t1, t2, t3, t4, t5, t6, c0, c1, c2, d1, d2 E2 + t0.Square(&x.B0) + t1.Square(&x.B1) + t2.Square(&x.B2) + t3.Mul(&x.B0, &x.B1) + t4.Mul(&x.B0, &x.B2) + t5.Mul(&x.B1, &x.B2) + c0.MulByNonResidue(&t5).Neg(&c0).Add(&c0, &t0) + c1.MulByNonResidue(&t2).Sub(&c1, &t3) + c2.Sub(&t1, &t4) + t6.Mul(&x.B0, &c0) + d1.Mul(&x.B2, &c1) + d2.Mul(&x.B1, &c2) + d1.Add(&d1, &d2).MulByNonResidue(&d1) + t6.Add(&t6, &d1) + t6.Inverse(&t6) + z.B0.Mul(&c0, &t6) + z.B1.Mul(&c1, &t6) + z.B2.Mul(&c2, &t6) + + return z +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/frobenius.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/frobenius.go new file mode 100644 index 00000000000..18d8fef960f --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/frobenius.go @@ -0,0 +1,392 @@ +// Copyright 2020 ConsenSys AG +// +// 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. + +package fptower + +import "github.com/consensys/gnark-crypto/ecc/bn254/fp" + +// Frobenius set z to Frobenius(x), return z +func (z *E12) Frobenius(x *E12) *E12 { + // Algorithm 28 from https://eprint.iacr.org/2010/354.pdf + var t [6]E2 + + // Frobenius acts on fp2 by conjugation + t[0].Conjugate(&x.C0.B0) + t[1].Conjugate(&x.C0.B1) + t[2].Conjugate(&x.C0.B2) + t[3].Conjugate(&x.C1.B0) + t[4].Conjugate(&x.C1.B1) + t[5].Conjugate(&x.C1.B2) + + t[1].MulByNonResidue1Power2(&t[1]) + t[2].MulByNonResidue1Power4(&t[2]) + t[3].MulByNonResidue1Power1(&t[3]) + t[4].MulByNonResidue1Power3(&t[4]) + t[5].MulByNonResidue1Power5(&t[5]) + + z.C0.B0 = t[0] + z.C0.B1 = t[1] + z.C0.B2 = t[2] + z.C1.B0 = t[3] + z.C1.B1 = t[4] + z.C1.B2 = t[5] + + return z +} + +// FrobeniusSquare set z to Frobenius^2(x), and return z +func (z *E12) FrobeniusSquare(x *E12) *E12 { + // Algorithm 29 from https://eprint.iacr.org/2010/354.pdf + z.C0.B0 = x.C0.B0 + z.C0.B1.MulByNonResidue2Power2(&x.C0.B1) + z.C0.B2.MulByNonResidue2Power4(&x.C0.B2) + z.C1.B0.MulByNonResidue2Power1(&x.C1.B0) + z.C1.B1.MulByNonResidue2Power3(&x.C1.B1) + z.C1.B2.MulByNonResidue2Power5(&x.C1.B2) + + return z +} + +// FrobeniusCube set z to Frobenius^3(x), return z +func (z *E12) FrobeniusCube(x *E12) *E12 { + // Algorithm 30 from https://eprint.iacr.org/2010/354.pdf + var t [6]E2 + + // Frobenius^3 acts on fp2 by conjugation + t[0].Conjugate(&x.C0.B0) + t[1].Conjugate(&x.C0.B1) + t[2].Conjugate(&x.C0.B2) + t[3].Conjugate(&x.C1.B0) + t[4].Conjugate(&x.C1.B1) + t[5].Conjugate(&x.C1.B2) + + t[1].MulByNonResidue3Power2(&t[1]) + t[2].MulByNonResidue3Power4(&t[2]) + t[3].MulByNonResidue3Power1(&t[3]) + t[4].MulByNonResidue3Power3(&t[4]) + t[5].MulByNonResidue3Power5(&t[5]) + + z.C0.B0 = t[0] + z.C0.B1 = t[1] + z.C0.B2 = t[2] + z.C1.B0 = t[3] + z.C1.B1 = t[4] + z.C1.B2 = t[5] + + return z +} + +// declaring these here instead of in the functions allow to inline the calls +var nonRes1Pow1to5 [5]E2 +var nonRes3Pow1To5 [5]E2 + +func init() { + // (11697423496358154304825782922584725312912383441159505038794027105778954184319,303847389135065887422783454877609941456349188919719272345083954437860409601) + nonRes3Pow1To5[0] = E2{ + A0: fp.Element{ + 3914496794763385213, + 790120733010914719, + 7322192392869644725, + 581366264293887267, + }, + A1: fp.Element{ + 12817045492518885689, + 4440270538777280383, + 11178533038884588256, + 2767537931541304486, + }, + } + + // (3772000881919853776433695186713858239009073593817195771773381919316419345261,2236595495967245188281701248203181795121068902605861227855261137820944008926) + nonRes3Pow1To5[1] = E2{ + A0: fp.Element{ + 14532872967180610477, + 12903226530429559474, + 1868623743233345524, + 2316889217940299650, + }, + A1: fp.Element{ + 12447993766991532972, + 4121872836076202828, + 7630813605053367399, + 740282956577754197, + }, + } + + // (19066677689644738377698246183563772429336693972053703295610958340458742082029,18382399103927718843559375435273026243156067647398564021675359801612095278180) + nonRes3Pow1To5[2] = E2{ + A0: fp.Element{ + 6297350639395948318, + 15875321927225446337, + 9702569988553770230, + 805825149519570764, + }, + A1: fp.Element{ + 11117433864585119104, + 10363184613815941297, + 5420513773305887730, + 278429812070195549, + }, + } + + // (5324479202449903542726783395506214481928257762400643279780343368557297135718,16208900380737693084919495127334387981393726419856888799917914180988844123039) + nonRes3Pow1To5[3] = E2{ + A0: fp.Element{ + 4938922280314430175, + 13823286637238282975, + 15589480384090068090, + 481952561930628184, + }, + A1: fp.Element{ + 3105754162722846417, + 11647802298615474591, + 13057042392041828081, + 1660844386505564338, + }, + } + + // (8941241848238582420466759817324047081148088512956452953208002715982955420483,10338197737521362862238855242243140895517409139741313354160881284257516364953) + nonRes3Pow1To5[4] = E2{ + A0: fp.Element{ + 16193900971494954399, + 13995139551301264911, + 9239559758168096094, + 1571199014989505406, + }, + A1: fp.Element{ + 3254114329011132839, + 11171599147282597747, + 10965492220518093659, + 2657556514797346915, + }, + } + + // (8376118865763821496583973867626364092589906065868298776909617916018768340080,16469823323077808223889137241176536799009286646108169935659301613961712198316) + nonRes1Pow1to5[0] = E2{ + A0: fp.Element{ + 12653890742059813127, + 14585784200204367754, + 1278438861261381767, + 212598772761311868, + }, + A1: fp.Element{ + 11683091849979440498, + 14992204589386555739, + 15866167890766973222, + 1200023580730561873, + }, + } + + // (21575463638280843010398324269430826099269044274347216827212613867836435027261,10307601595873709700152284273816112264069230130616436755625194854815875713954) + nonRes1Pow1to5[1] = E2{ + A0: fp.Element{ + 13075984984163199792, + 3782902503040509012, + 8791150885551868305, + 1825854335138010348, + }, + A1: fp.Element{ + 7963664994991228759, + 12257807996192067905, + 13179524609921305146, + 2767831111890561987, + }, + } + + // (2821565182194536844548159561693502659359617185244120367078079554186484126554,3505843767911556378687030309984248845540243509899259641013678093033130930403) + nonRes1Pow1to5[2] = E2{ + A0: fp.Element{ + 16482010305593259561, + 13488546290961988299, + 3578621962720924518, + 2681173117283399901, + }, + A1: fp.Element{ + 11661927080404088775, + 553939530661941723, + 7860678177968807019, + 3208568454732775116, + }, + } + + // (2581911344467009335267311115468803099551665605076196740867805258568234346338,19937756971775647987995932169929341994314640652964949448313374472400716661030) + nonRes1Pow1to5[3] = E2{ + A0: fp.Element{ + 8314163329781907090, + 11942187022798819835, + 11282677263046157209, + 1576150870752482284, + }, + A1: fp.Element{ + 6763840483288992073, + 7118829427391486816, + 4016233444936635065, + 2630958277570195709, + }, + } + + // (685108087231508774477564247770172212460312782337200605669322048753928464687,8447204650696766136447902020341177575205426561248465145919723016860428151883) + nonRes1Pow1to5[4] = E2{ + A0: fp.Element{ + 14515217250696892391, + 16303087968080972555, + 3656613296917993960, + 1345095164996126785, + }, + A1: fp.Element{ + 957117326806663081, + 367382125163301975, + 15253872307375509749, + 3396254757538665050, + }, + } +} + +// MulByNonResidue1Power1 set z=x*(9,1)^(1*(p^1-1)/6) and return z +func (z *E2) MulByNonResidue1Power1(x *E2) *E2 { + // (8376118865763821496583973867626364092589906065868298776909617916018768340080,16469823323077808223889137241176536799009286646108169935659301613961712198316) + z.Mul(x, &nonRes1Pow1to5[0]) + return z +} + +// MulByNonResidue1Power2 set z=x*(9,1)^(2*(p^1-1)/6) and return z +func (z *E2) MulByNonResidue1Power2(x *E2) *E2 { + // (21575463638280843010398324269430826099269044274347216827212613867836435027261,10307601595873709700152284273816112264069230130616436755625194854815875713954) + z.Mul(x, &nonRes1Pow1to5[1]) + return z +} + +// MulByNonResidue1Power3 set z=x*(9,1)^(3*(p^1-1)/6) and return z +func (z *E2) MulByNonResidue1Power3(x *E2) *E2 { + // (2821565182194536844548159561693502659359617185244120367078079554186484126554,3505843767911556378687030309984248845540243509899259641013678093033130930403) + z.Mul(x, &nonRes1Pow1to5[2]) + return z +} + +// MulByNonResidue1Power4 set z=x*(9,1)^(4*(p^1-1)/6) and return z +func (z *E2) MulByNonResidue1Power4(x *E2) *E2 { + // (2581911344467009335267311115468803099551665605076196740867805258568234346338,19937756971775647987995932169929341994314640652964949448313374472400716661030) + z.Mul(x, &nonRes1Pow1to5[3]) + return z +} + +// MulByNonResidue1Power5 set z=x*(9,1)^(5*(p^1-1)/6) and return z +func (z *E2) MulByNonResidue1Power5(x *E2) *E2 { + // (685108087231508774477564247770172212460312782337200605669322048753928464687,8447204650696766136447902020341177575205426561248465145919723016860428151883) + z.Mul(x, &nonRes1Pow1to5[4]) + return z +} + +// MulByNonResidue2Power1 set z=x*(9,1)^(1*(p^2-1)/6) and return z +func (z *E2) MulByNonResidue2Power1(x *E2) *E2 { + // 21888242871839275220042445260109153167277707414472061641714758635765020556617 + b := fp.Element{ + 14595462726357228530, + 17349508522658994025, + 1017833795229664280, + 299787779797702374, + } + z.A0.Mul(&x.A0, &b) + z.A1.Mul(&x.A1, &b) + return z +} + +// MulByNonResidue2Power2 set z=x*(9,1)^(2*(p^2-1)/6) and return z +func (z *E2) MulByNonResidue2Power2(x *E2) *E2 { + // 21888242871839275220042445260109153167277707414472061641714758635765020556616 + b := fp.Element{ + 3697675806616062876, + 9065277094688085689, + 6918009208039626314, + 2775033306905974752, + } + z.A0.Mul(&x.A0, &b) + z.A1.Mul(&x.A1, &b) + return z +} + +// MulByNonResidue2Power3 set z=x*(9,1)^(3*(p^2-1)/6) and return z +func (z *E2) MulByNonResidue2Power3(x *E2) *E2 { + // 21888242871839275222246405745257275088696311157297823662689037894645226208582 + b := fp.Element{ + 7548957153968385962, + 10162512645738643279, + 5900175412809962033, + 2475245527108272378, + } + z.A0.Mul(&x.A0, &b) + z.A1.Mul(&x.A1, &b) + return z +} + +// MulByNonResidue2Power4 set z=x*(9,1)^(4*(p^2-1)/6) and return z +func (z *E2) MulByNonResidue2Power4(x *E2) *E2 { + // 2203960485148121921418603742825762020974279258880205651966 + b := fp.Element{ + 8183898218631979349, + 12014359695528440611, + 12263358156045030468, + 3187210487005268291, + } + z.A0.Mul(&x.A0, &b) + z.A1.Mul(&x.A1, &b) + return z +} + +// MulByNonResidue2Power5 set z=x*(9,1)^(5*(p^2-1)/6) and return z +func (z *E2) MulByNonResidue2Power5(x *E2) *E2 { + // 2203960485148121921418603742825762020974279258880205651967 + b := fp.Element{ + 634941064663593387, + 1851847049789797332, + 6363182743235068435, + 711964959896995913, + } + z.A0.Mul(&x.A0, &b) + z.A1.Mul(&x.A1, &b) + return z +} + +// MulByNonResidue3Power1 set z=x*(9,1)^(1*(p^3-1)/6) and return z +func (z *E2) MulByNonResidue3Power1(x *E2) *E2 { + // (11697423496358154304825782922584725312912383441159505038794027105778954184319,303847389135065887422783454877609941456349188919719272345083954437860409601) + z.Mul(x, &nonRes3Pow1To5[0]) + return z +} + +// MulByNonResidue3Power2 set z=x*(9,1)^(2*(p^3-1)/6) and return z +func (z *E2) MulByNonResidue3Power2(x *E2) *E2 { + // (3772000881919853776433695186713858239009073593817195771773381919316419345261,2236595495967245188281701248203181795121068902605861227855261137820944008926) + z.Mul(x, &nonRes3Pow1To5[1]) + return z +} + +// MulByNonResidue3Power3 set z=x*(9,1)^(3*(p^3-1)/6) and return z +func (z *E2) MulByNonResidue3Power3(x *E2) *E2 { + // (19066677689644738377698246183563772429336693972053703295610958340458742082029,18382399103927718843559375435273026243156067647398564021675359801612095278180) + z.Mul(x, &nonRes3Pow1To5[2]) + return z +} + +// MulByNonResidue3Power4 set z=x*(9,1)^(4*(p^3-1)/6) and return z +func (z *E2) MulByNonResidue3Power4(x *E2) *E2 { + z.Mul(x, &nonRes3Pow1To5[3]) + return z +} + +// MulByNonResidue3Power5 set z=x*(9,1)^(5*(p^3-1)/6) and return z +func (z *E2) MulByNonResidue3Power5(x *E2) *E2 { + z.Mul(x, &nonRes3Pow1To5[4]) + return z +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/marshal.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/marshal.go new file mode 100644 index 00000000000..68a0b40523d --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/marshal.go @@ -0,0 +1,1001 @@ +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +// Package bn254 provides efficient elliptic curve and pairing implementation for bn254 +package bn254 + +import ( + "encoding/binary" + "errors" + "io" + "reflect" + "sync/atomic" + + "github.com/consensys/gnark-crypto/ecc/bn254/fp" + "github.com/consensys/gnark-crypto/ecc/bn254/fr" + "github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower" + "github.com/consensys/gnark-crypto/internal/parallel" +) + +// To encode G1Affine and G2Affine points, we mask the most significant bits with these bits to specify without ambiguity +// metadata needed for point (de)compression +// we have less than 3 bits available on the msw, so we can't follow BLS12-381 style encoding. +// the difference is the case where a point is infinity and uncompressed is not flagged +const ( + mMask byte = 0b11 << 6 + mUncompressed byte = 0b00 << 6 + mCompressedSmallest byte = 0b10 << 6 + mCompressedLargest byte = 0b11 << 6 + mCompressedInfinity byte = 0b01 << 6 +) + +// SizeOfGT represents the size in bytes that a GT element need in binary form +const SizeOfGT = fptower.SizeOfGT + +// Encoder writes bn254 object values to an output stream +type Encoder struct { + w io.Writer + n int64 // written bytes + raw bool // raw vs compressed encoding +} + +// Decoder reads bn254 object values from an inbound stream +type Decoder struct { + r io.Reader + n int64 // read bytes +} + +// NewDecoder returns a binary decoder supporting curve bn254 objects in both +// compressed and uncompressed (raw) forms +func NewDecoder(r io.Reader) *Decoder { + return &Decoder{r: r} +} + +// Decode reads the binary encoding of v from the stream +// type must be *uint64, *fr.Element, *fp.Element, *G1Affine, *G2Affine, *[]G1Affine or *[]G2Affine +func (dec *Decoder) Decode(v interface{}) (err error) { + rv := reflect.ValueOf(v) + if rv.Kind() != reflect.Ptr || rv.IsNil() || !rv.Elem().CanSet() { + return errors.New("bn254 decoder: unsupported type, need pointer") + } + + // implementation note: code is a bit verbose (abusing code generation), but minimize allocations on the heap + // TODO double check memory usage and factorize this + + var buf [SizeOfG2AffineUncompressed]byte + var read int + + switch t := v.(type) { + case *uint64: + var r uint64 + r, err = dec.readUint64() + if err != nil { + return + } + *t = r + return + case *fr.Element: + read, err = io.ReadFull(dec.r, buf[:fr.Limbs*8]) + dec.n += int64(read) + if err != nil { + return + } + t.SetBytes(buf[:fr.Limbs*8]) + return + case *fp.Element: + read, err = io.ReadFull(dec.r, buf[:fp.Limbs*8]) + dec.n += int64(read) + if err != nil { + return + } + t.SetBytes(buf[:fp.Limbs*8]) + return + case *G1Affine: + // we start by reading compressed point size, if metadata tells us it is uncompressed, we read more. + read, err = io.ReadFull(dec.r, buf[:SizeOfG1AffineCompressed]) + dec.n += int64(read) + if err != nil { + return + } + nbBytes := SizeOfG1AffineCompressed + // most significant byte contains metadata + if !isCompressed(buf[0]) { + nbBytes = SizeOfG1AffineUncompressed + // we read more. + read, err = io.ReadFull(dec.r, buf[SizeOfG1AffineCompressed:SizeOfG1AffineUncompressed]) + dec.n += int64(read) + if err != nil { + return + } + } + _, err = t.SetBytes(buf[:nbBytes]) + return + case *G2Affine: + // we start by reading compressed point size, if metadata tells us it is uncompressed, we read more. + read, err = io.ReadFull(dec.r, buf[:SizeOfG2AffineCompressed]) + dec.n += int64(read) + if err != nil { + return + } + nbBytes := SizeOfG2AffineCompressed + // most significant byte contains metadata + if !isCompressed(buf[0]) { + nbBytes = SizeOfG2AffineUncompressed + // we read more. + read, err = io.ReadFull(dec.r, buf[SizeOfG2AffineCompressed:SizeOfG2AffineUncompressed]) + dec.n += int64(read) + if err != nil { + return + } + } + _, err = t.SetBytes(buf[:nbBytes]) + return + case *[]G1Affine: + var sliceLen uint32 + sliceLen, err = dec.readUint32() + if err != nil { + return + } + if len(*t) != int(sliceLen) { + *t = make([]G1Affine, sliceLen) + } + compressed := make([]bool, sliceLen) + for i := 0; i < len(*t); i++ { + + // we start by reading compressed point size, if metadata tells us it is uncompressed, we read more. + read, err = io.ReadFull(dec.r, buf[:SizeOfG1AffineCompressed]) + dec.n += int64(read) + if err != nil { + return + } + nbBytes := SizeOfG1AffineCompressed + // most significant byte contains metadata + if !isCompressed(buf[0]) { + nbBytes = SizeOfG1AffineUncompressed + // we read more. + read, err = io.ReadFull(dec.r, buf[SizeOfG1AffineCompressed:SizeOfG1AffineUncompressed]) + dec.n += int64(read) + if err != nil { + return + } + _, err = (*t)[i].SetBytes(buf[:nbBytes]) + if err != nil { + return + } + } else { + compressed[i] = !((*t)[i].unsafeSetCompressedBytes(buf[:nbBytes])) + } + } + var nbErrs uint64 + parallel.Execute(len(compressed), func(start, end int) { + for i := start; i < end; i++ { + if compressed[i] { + if err := (*t)[i].unsafeComputeY(); err != nil { + atomic.AddUint64(&nbErrs, 1) + } + } + } + }) + if nbErrs != 0 { + return errors.New("point decompression failed") + } + + return nil + case *[]G2Affine: + var sliceLen uint32 + sliceLen, err = dec.readUint32() + if err != nil { + return + } + if len(*t) != int(sliceLen) { + *t = make([]G2Affine, sliceLen) + } + compressed := make([]bool, sliceLen) + for i := 0; i < len(*t); i++ { + + // we start by reading compressed point size, if metadata tells us it is uncompressed, we read more. + read, err = io.ReadFull(dec.r, buf[:SizeOfG2AffineCompressed]) + dec.n += int64(read) + if err != nil { + return + } + nbBytes := SizeOfG2AffineCompressed + // most significant byte contains metadata + if !isCompressed(buf[0]) { + nbBytes = SizeOfG2AffineUncompressed + // we read more. + read, err = io.ReadFull(dec.r, buf[SizeOfG2AffineCompressed:SizeOfG2AffineUncompressed]) + dec.n += int64(read) + if err != nil { + return + } + _, err = (*t)[i].SetBytes(buf[:nbBytes]) + if err != nil { + return + } + } else { + compressed[i] = !((*t)[i].unsafeSetCompressedBytes(buf[:nbBytes])) + } + } + var nbErrs uint64 + parallel.Execute(len(compressed), func(start, end int) { + for i := start; i < end; i++ { + if compressed[i] { + if err := (*t)[i].unsafeComputeY(); err != nil { + atomic.AddUint64(&nbErrs, 1) + } + } + } + }) + if nbErrs != 0 { + return errors.New("point decompression failed") + } + + return nil + default: + return errors.New("bn254 encoder: unsupported type") + } +} + +// BytesRead return total bytes read from reader +func (dec *Decoder) BytesRead() int64 { + return dec.n +} + +func (dec *Decoder) readUint64() (r uint64, err error) { + var read int + var buf [8]byte + read, err = io.ReadFull(dec.r, buf[:8]) + dec.n += int64(read) + if err != nil { + return + } + r = binary.BigEndian.Uint64(buf[:8]) + return +} + +func (dec *Decoder) readUint32() (r uint32, err error) { + var read int + var buf [4]byte + read, err = io.ReadFull(dec.r, buf[:4]) + dec.n += int64(read) + if err != nil { + return + } + r = binary.BigEndian.Uint32(buf[:4]) + return +} + +func isCompressed(msb byte) bool { + mData := msb & mMask + return !(mData == mUncompressed) +} + +// NewEncoder returns a binary encoder supporting curve bn254 objects +func NewEncoder(w io.Writer, options ...func(*Encoder)) *Encoder { + // default settings + enc := &Encoder{ + w: w, + n: 0, + raw: false, + } + + // handle options + for _, option := range options { + option(enc) + } + + return enc +} + +// Encode writes the binary encoding of v to the stream +// type must be uint64, *fr.Element, *fp.Element, *G1Affine, *G2Affine, []G1Affine or []G2Affine +func (enc *Encoder) Encode(v interface{}) (err error) { + if enc.raw { + return enc.encodeRaw(v) + } + return enc.encode(v) +} + +// BytesWritten return total bytes written on writer +func (enc *Encoder) BytesWritten() int64 { + return enc.n +} + +// RawEncoding returns an option to use in NewEncoder(...) which sets raw encoding mode to true +// points will not be compressed using this option +func RawEncoding() func(*Encoder) { + return func(enc *Encoder) { + enc.raw = true + } +} + +func (enc *Encoder) encode(v interface{}) (err error) { + + // implementation note: code is a bit verbose (abusing code generation), but minimize allocations on the heap + // TODO double check memory usage and factorize this + + var written int + switch t := v.(type) { + case uint64: + err = binary.Write(enc.w, binary.BigEndian, t) + enc.n += 8 + return + case *fr.Element: + buf := t.Bytes() + written, err = enc.w.Write(buf[:]) + enc.n += int64(written) + return + case *fp.Element: + buf := t.Bytes() + written, err = enc.w.Write(buf[:]) + enc.n += int64(written) + return + case *G1Affine: + buf := t.Bytes() + written, err = enc.w.Write(buf[:]) + enc.n += int64(written) + return + case *G2Affine: + buf := t.Bytes() + written, err = enc.w.Write(buf[:]) + enc.n += int64(written) + return + case []G1Affine: + // write slice length + err = binary.Write(enc.w, binary.BigEndian, uint32(len(t))) + if err != nil { + return + } + enc.n += 4 + + var buf [SizeOfG1AffineCompressed]byte + + for i := 0; i < len(t); i++ { + buf = t[i].Bytes() + written, err = enc.w.Write(buf[:]) + enc.n += int64(written) + if err != nil { + return + } + } + return nil + case []G2Affine: + // write slice length + err = binary.Write(enc.w, binary.BigEndian, uint32(len(t))) + if err != nil { + return + } + enc.n += 4 + + var buf [SizeOfG2AffineCompressed]byte + + for i := 0; i < len(t); i++ { + buf = t[i].Bytes() + written, err = enc.w.Write(buf[:]) + enc.n += int64(written) + if err != nil { + return + } + } + return nil + default: + return errors.New(" encoder: unsupported type") + } +} + +func (enc *Encoder) encodeRaw(v interface{}) (err error) { + + // implementation note: code is a bit verbose (abusing code generation), but minimize allocations on the heap + // TODO double check memory usage and factorize this + + var written int + switch t := v.(type) { + case uint64: + err = binary.Write(enc.w, binary.BigEndian, t) + enc.n += 8 + return + case *fr.Element: + buf := t.Bytes() + written, err = enc.w.Write(buf[:]) + enc.n += int64(written) + return + case *fp.Element: + buf := t.Bytes() + written, err = enc.w.Write(buf[:]) + enc.n += int64(written) + return + case *G1Affine: + buf := t.RawBytes() + written, err = enc.w.Write(buf[:]) + enc.n += int64(written) + return + case *G2Affine: + buf := t.RawBytes() + written, err = enc.w.Write(buf[:]) + enc.n += int64(written) + return + case []G1Affine: + // write slice length + err = binary.Write(enc.w, binary.BigEndian, uint32(len(t))) + if err != nil { + return + } + enc.n += 4 + + var buf [SizeOfG1AffineUncompressed]byte + + for i := 0; i < len(t); i++ { + buf = t[i].RawBytes() + written, err = enc.w.Write(buf[:]) + enc.n += int64(written) + if err != nil { + return + } + } + return nil + case []G2Affine: + // write slice length + err = binary.Write(enc.w, binary.BigEndian, uint32(len(t))) + if err != nil { + return + } + enc.n += 4 + + var buf [SizeOfG2AffineUncompressed]byte + + for i := 0; i < len(t); i++ { + buf = t[i].RawBytes() + written, err = enc.w.Write(buf[:]) + enc.n += int64(written) + if err != nil { + return + } + } + return nil + default: + return errors.New(" encoder: unsupported type") + } +} + +// SizeOfG1AffineCompressed represents the size in bytes that a G1Affine need in binary form, compressed +const SizeOfG1AffineCompressed = 32 + +// SizeOfG1AffineUncompressed represents the size in bytes that a G1Affine need in binary form, uncompressed +const SizeOfG1AffineUncompressed = SizeOfG1AffineCompressed * 2 + +// Marshal converts p to a byte slice (without point compression) +func (p *G1Affine) Marshal() []byte { + b := p.RawBytes() + return b[:] +} + +// Unmarshal is an allias to SetBytes() +func (p *G1Affine) Unmarshal(buf []byte) error { + _, err := p.SetBytes(buf) + return err +} + +// Bytes returns binary representation of p +// will store X coordinate in regular form and a parity bit +// as we have less than 3 bits available in our coordinate, we can't follow BLS12-381 style encoding (ZCash/IETF) +// we use the 2 most significant bits instead +// 00 -> uncompressed +// 10 -> compressed, use smallest lexicographically square root of Y^2 +// 11 -> compressed, use largest lexicographically square root of Y^2 +// 01 -> compressed infinity point +// the "uncompressed infinity point" will just have 00 (uncompressed) followed by zeroes (infinity = 0,0 in affine coordinates) +func (p *G1Affine) Bytes() (res [SizeOfG1AffineCompressed]byte) { + + // check if p is infinity point + if p.X.IsZero() && p.Y.IsZero() { + res[0] = mCompressedInfinity + return + } + + // tmp is used to convert from montgomery representation to regular + var tmp fp.Element + + msbMask := mCompressedSmallest + // compressed, we need to know if Y is lexicographically bigger than -Y + // if p.Y ">" -p.Y + if p.Y.LexicographicallyLargest() { + msbMask = mCompressedLargest + } + + // we store X and mask the most significant word with our metadata mask + tmp = p.X + tmp.FromMont() + binary.BigEndian.PutUint64(res[24:32], tmp[0]) + binary.BigEndian.PutUint64(res[16:24], tmp[1]) + binary.BigEndian.PutUint64(res[8:16], tmp[2]) + binary.BigEndian.PutUint64(res[0:8], tmp[3]) + + res[0] |= msbMask + + return +} + +// RawBytes returns binary representation of p (stores X and Y coordinate) +// see Bytes() for a compressed representation +func (p *G1Affine) RawBytes() (res [SizeOfG1AffineUncompressed]byte) { + + // check if p is infinity point + if p.X.IsZero() && p.Y.IsZero() { + + res[0] = mUncompressed + + return + } + + // tmp is used to convert from montgomery representation to regular + var tmp fp.Element + + // not compressed + // we store the Y coordinate + tmp = p.Y + tmp.FromMont() + binary.BigEndian.PutUint64(res[56:64], tmp[0]) + binary.BigEndian.PutUint64(res[48:56], tmp[1]) + binary.BigEndian.PutUint64(res[40:48], tmp[2]) + binary.BigEndian.PutUint64(res[32:40], tmp[3]) + + // we store X and mask the most significant word with our metadata mask + tmp = p.X + tmp.FromMont() + binary.BigEndian.PutUint64(res[24:32], tmp[0]) + binary.BigEndian.PutUint64(res[16:24], tmp[1]) + binary.BigEndian.PutUint64(res[8:16], tmp[2]) + binary.BigEndian.PutUint64(res[0:8], tmp[3]) + + res[0] |= mUncompressed + + return +} + +// SetBytes sets p from binary representation in buf and returns number of consumed bytes +// bytes in buf must match either RawBytes() or Bytes() output +// if buf is too short io.ErrShortBuffer is returned +// if buf contains compressed representation (output from Bytes()) and we're unable to compute +// the Y coordinate (i.e the square root doesn't exist) this function retunrs an error +// this check if the resulting point is on the curve and in the correct subgroup +func (p *G1Affine) SetBytes(buf []byte) (int, error) { + if len(buf) < SizeOfG1AffineCompressed { + return 0, io.ErrShortBuffer + } + + // most significant byte + mData := buf[0] & mMask + + // check buffer size + if mData == mUncompressed { + if len(buf) < SizeOfG1AffineUncompressed { + return 0, io.ErrShortBuffer + } + } + + // if infinity is encoded in the metadata, we don't need to read the buffer + if mData == mCompressedInfinity { + p.X.SetZero() + p.Y.SetZero() + return SizeOfG1AffineCompressed, nil + } + + // uncompressed point + if mData == mUncompressed { + // read X and Y coordinates + p.X.SetBytes(buf[:fp.Bytes]) + p.Y.SetBytes(buf[fp.Bytes : fp.Bytes*2]) + + // subgroup check + if !p.IsInSubGroup() { + return 0, errors.New("invalid point: subgroup check failed") + } + + return SizeOfG1AffineUncompressed, nil + } + + // we have a compressed coordinate + // we need to + // 1. copy the buffer (to keep this method thread safe) + // 2. we need to solve the curve equation to compute Y + + var bufX [fp.Bytes]byte + copy(bufX[:fp.Bytes], buf[:fp.Bytes]) + bufX[0] &= ^mMask + + // read X coordinate + p.X.SetBytes(bufX[:fp.Bytes]) + + var YSquared, Y fp.Element + + YSquared.Square(&p.X).Mul(&YSquared, &p.X) + YSquared.Add(&YSquared, &bCurveCoeff) + if Y.Sqrt(&YSquared) == nil { + return 0, errors.New("invalid compressed coordinate: square root doesn't exist") + } + + if Y.LexicographicallyLargest() { + // Y ">" -Y + if mData == mCompressedSmallest { + Y.Neg(&Y) + } + } else { + // Y "<=" -Y + if mData == mCompressedLargest { + Y.Neg(&Y) + } + } + + p.Y = Y + + // subgroup check + if !p.IsInSubGroup() { + return 0, errors.New("invalid point: subgroup check failed") + } + + return SizeOfG1AffineCompressed, nil +} + +// unsafeComputeY called by Decoder when processing slices of compressed point in parallel (step 2) +// it computes the Y coordinate from the already set X coordinate and is compute intensive +func (p *G1Affine) unsafeComputeY() error { + // stored in unsafeSetCompressedBytes + + mData := byte(p.Y[0]) + + // we have a compressed coordinate, we need to solve the curve equation to compute Y + var YSquared, Y fp.Element + + YSquared.Square(&p.X).Mul(&YSquared, &p.X) + YSquared.Add(&YSquared, &bCurveCoeff) + if Y.Sqrt(&YSquared) == nil { + return errors.New("invalid compressed coordinate: square root doesn't exist") + } + + if Y.LexicographicallyLargest() { + // Y ">" -Y + if mData == mCompressedSmallest { + Y.Neg(&Y) + } + } else { + // Y "<=" -Y + if mData == mCompressedLargest { + Y.Neg(&Y) + } + } + + p.Y = Y + + // subgroup check + if !p.IsInSubGroup() { + return errors.New("invalid point: subgroup check failed") + } + + return nil +} + +// unsafeSetCompressedBytes is called by Decoder when processing slices of compressed point in parallel (step 1) +// assumes buf[:8] mask is set to compressed +// returns true if point is infinity and need no further processing +// it sets X coordinate and uses Y for scratch space to store decompression metadata +func (p *G1Affine) unsafeSetCompressedBytes(buf []byte) (isInfinity bool) { + + // read the most significant byte + mData := buf[0] & mMask + + if mData == mCompressedInfinity { + p.X.SetZero() + p.Y.SetZero() + isInfinity = true + return + } + + // we need to copy the input buffer (to keep this method thread safe) + var bufX [fp.Bytes]byte + copy(bufX[:fp.Bytes], buf[:fp.Bytes]) + bufX[0] &= ^mMask + + // read X coordinate + p.X.SetBytes(bufX[:fp.Bytes]) + // store mData in p.Y[0] + p.Y[0] = uint64(mData) + + // recomputing Y will be done asynchronously + return +} + +// SizeOfG2AffineCompressed represents the size in bytes that a G2Affine need in binary form, compressed +const SizeOfG2AffineCompressed = 32 * 2 + +// SizeOfG2AffineUncompressed represents the size in bytes that a G2Affine need in binary form, uncompressed +const SizeOfG2AffineUncompressed = SizeOfG2AffineCompressed * 2 + +// Marshal converts p to a byte slice (without point compression) +func (p *G2Affine) Marshal() []byte { + b := p.RawBytes() + return b[:] +} + +// Unmarshal is an allias to SetBytes() +func (p *G2Affine) Unmarshal(buf []byte) error { + _, err := p.SetBytes(buf) + return err +} + +// Bytes returns binary representation of p +// will store X coordinate in regular form and a parity bit +// as we have less than 3 bits available in our coordinate, we can't follow BLS12-381 style encoding (ZCash/IETF) +// we use the 2 most significant bits instead +// 00 -> uncompressed +// 10 -> compressed, use smallest lexicographically square root of Y^2 +// 11 -> compressed, use largest lexicographically square root of Y^2 +// 01 -> compressed infinity point +// the "uncompressed infinity point" will just have 00 (uncompressed) followed by zeroes (infinity = 0,0 in affine coordinates) +func (p *G2Affine) Bytes() (res [SizeOfG2AffineCompressed]byte) { + + // check if p is infinity point + if p.X.IsZero() && p.Y.IsZero() { + res[0] = mCompressedInfinity + return + } + + // tmp is used to convert from montgomery representation to regular + var tmp fp.Element + + msbMask := mCompressedSmallest + // compressed, we need to know if Y is lexicographically bigger than -Y + // if p.Y ">" -p.Y + if p.Y.LexicographicallyLargest() { + msbMask = mCompressedLargest + } + + // we store X and mask the most significant word with our metadata mask + // p.X.A0 | p.X.A1 + tmp = p.X.A0 + tmp.FromMont() + binary.BigEndian.PutUint64(res[56:64], tmp[0]) + binary.BigEndian.PutUint64(res[48:56], tmp[1]) + binary.BigEndian.PutUint64(res[40:48], tmp[2]) + binary.BigEndian.PutUint64(res[32:40], tmp[3]) + + tmp = p.X.A1 + tmp.FromMont() + binary.BigEndian.PutUint64(res[24:32], tmp[0]) + binary.BigEndian.PutUint64(res[16:24], tmp[1]) + binary.BigEndian.PutUint64(res[8:16], tmp[2]) + binary.BigEndian.PutUint64(res[0:8], tmp[3]) + + res[0] |= msbMask + + return +} + +// RawBytes returns binary representation of p (stores X and Y coordinate) +// see Bytes() for a compressed representation +func (p *G2Affine) RawBytes() (res [SizeOfG2AffineUncompressed]byte) { + + // check if p is infinity point + if p.X.IsZero() && p.Y.IsZero() { + + res[0] = mUncompressed + + return + } + + // tmp is used to convert from montgomery representation to regular + var tmp fp.Element + + // not compressed + // we store the Y coordinate + // p.Y.A0 | p.Y.A1 + tmp = p.Y.A0 + tmp.FromMont() + binary.BigEndian.PutUint64(res[120:128], tmp[0]) + binary.BigEndian.PutUint64(res[112:120], tmp[1]) + binary.BigEndian.PutUint64(res[104:112], tmp[2]) + binary.BigEndian.PutUint64(res[96:104], tmp[3]) + + tmp = p.Y.A1 + tmp.FromMont() + binary.BigEndian.PutUint64(res[88:96], tmp[0]) + binary.BigEndian.PutUint64(res[80:88], tmp[1]) + binary.BigEndian.PutUint64(res[72:80], tmp[2]) + binary.BigEndian.PutUint64(res[64:72], tmp[3]) + + // we store X and mask the most significant word with our metadata mask + // p.X.A0 | p.X.A1 + tmp = p.X.A1 + tmp.FromMont() + binary.BigEndian.PutUint64(res[24:32], tmp[0]) + binary.BigEndian.PutUint64(res[16:24], tmp[1]) + binary.BigEndian.PutUint64(res[8:16], tmp[2]) + binary.BigEndian.PutUint64(res[0:8], tmp[3]) + + tmp = p.X.A0 + tmp.FromMont() + binary.BigEndian.PutUint64(res[56:64], tmp[0]) + binary.BigEndian.PutUint64(res[48:56], tmp[1]) + binary.BigEndian.PutUint64(res[40:48], tmp[2]) + binary.BigEndian.PutUint64(res[32:40], tmp[3]) + + res[0] |= mUncompressed + + return +} + +// SetBytes sets p from binary representation in buf and returns number of consumed bytes +// bytes in buf must match either RawBytes() or Bytes() output +// if buf is too short io.ErrShortBuffer is returned +// if buf contains compressed representation (output from Bytes()) and we're unable to compute +// the Y coordinate (i.e the square root doesn't exist) this function retunrs an error +// this check if the resulting point is on the curve and in the correct subgroup +func (p *G2Affine) SetBytes(buf []byte) (int, error) { + if len(buf) < SizeOfG2AffineCompressed { + return 0, io.ErrShortBuffer + } + + // most significant byte + mData := buf[0] & mMask + + // check buffer size + if mData == mUncompressed { + if len(buf) < SizeOfG2AffineUncompressed { + return 0, io.ErrShortBuffer + } + } + + // if infinity is encoded in the metadata, we don't need to read the buffer + if mData == mCompressedInfinity { + p.X.SetZero() + p.Y.SetZero() + return SizeOfG2AffineCompressed, nil + } + + // uncompressed point + if mData == mUncompressed { + // read X and Y coordinates + // p.X.A1 | p.X.A0 + p.X.A1.SetBytes(buf[:fp.Bytes]) + p.X.A0.SetBytes(buf[fp.Bytes : fp.Bytes*2]) + // p.Y.A1 | p.Y.A0 + p.Y.A1.SetBytes(buf[fp.Bytes*2 : fp.Bytes*3]) + p.Y.A0.SetBytes(buf[fp.Bytes*3 : fp.Bytes*4]) + + // subgroup check + if !p.IsInSubGroup() { + return 0, errors.New("invalid point: subgroup check failed") + } + + return SizeOfG2AffineUncompressed, nil + } + + // we have a compressed coordinate + // we need to + // 1. copy the buffer (to keep this method thread safe) + // 2. we need to solve the curve equation to compute Y + + var bufX [fp.Bytes]byte + copy(bufX[:fp.Bytes], buf[:fp.Bytes]) + bufX[0] &= ^mMask + + // read X coordinate + // p.X.A1 | p.X.A0 + p.X.A1.SetBytes(bufX[:fp.Bytes]) + p.X.A0.SetBytes(buf[fp.Bytes : fp.Bytes*2]) + + var YSquared, Y fptower.E2 + + YSquared.Square(&p.X).Mul(&YSquared, &p.X) + YSquared.Add(&YSquared, &bTwistCurveCoeff) + if YSquared.Legendre() == -1 { + return 0, errors.New("invalid compressed coordinate: square root doesn't exist") + } + Y.Sqrt(&YSquared) + + if Y.LexicographicallyLargest() { + // Y ">" -Y + if mData == mCompressedSmallest { + Y.Neg(&Y) + } + } else { + // Y "<=" -Y + if mData == mCompressedLargest { + Y.Neg(&Y) + } + } + + p.Y = Y + + // subgroup check + if !p.IsInSubGroup() { + return 0, errors.New("invalid point: subgroup check failed") + } + + return SizeOfG2AffineCompressed, nil +} + +// unsafeComputeY called by Decoder when processing slices of compressed point in parallel (step 2) +// it computes the Y coordinate from the already set X coordinate and is compute intensive +func (p *G2Affine) unsafeComputeY() error { + // stored in unsafeSetCompressedBytes + + mData := byte(p.Y.A0[0]) + + // we have a compressed coordinate, we need to solve the curve equation to compute Y + var YSquared, Y fptower.E2 + + YSquared.Square(&p.X).Mul(&YSquared, &p.X) + YSquared.Add(&YSquared, &bTwistCurveCoeff) + if YSquared.Legendre() == -1 { + return errors.New("invalid compressed coordinate: square root doesn't exist") + } + Y.Sqrt(&YSquared) + + if Y.LexicographicallyLargest() { + // Y ">" -Y + if mData == mCompressedSmallest { + Y.Neg(&Y) + } + } else { + // Y "<=" -Y + if mData == mCompressedLargest { + Y.Neg(&Y) + } + } + + p.Y = Y + + // subgroup check + if !p.IsInSubGroup() { + return errors.New("invalid point: subgroup check failed") + } + + return nil +} + +// unsafeSetCompressedBytes is called by Decoder when processing slices of compressed point in parallel (step 1) +// assumes buf[:8] mask is set to compressed +// returns true if point is infinity and need no further processing +// it sets X coordinate and uses Y for scratch space to store decompression metadata +func (p *G2Affine) unsafeSetCompressedBytes(buf []byte) (isInfinity bool) { + + // read the most significant byte + mData := buf[0] & mMask + + if mData == mCompressedInfinity { + p.X.SetZero() + p.Y.SetZero() + isInfinity = true + return + } + + // we need to copy the input buffer (to keep this method thread safe) + var bufX [fp.Bytes]byte + copy(bufX[:fp.Bytes], buf[:fp.Bytes]) + bufX[0] &= ^mMask + + // read X coordinate + // p.X.A1 | p.X.A0 + p.X.A1.SetBytes(bufX[:fp.Bytes]) + p.X.A0.SetBytes(buf[fp.Bytes : fp.Bytes*2]) + + // store mData in p.Y.A0[0] + p.Y.A0[0] = uint64(mData) + + // recomputing Y will be done asynchronously + return +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/multiexp.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/multiexp.go new file mode 100644 index 00000000000..89d958a575d --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/multiexp.go @@ -0,0 +1,1808 @@ +// Copyright 2020 ConsenSys Software Inc. +// +// 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. + +// Code generated by consensys/gnark-crypto DO NOT EDIT + +package bn254 + +import ( + "github.com/consensys/gnark-crypto/ecc/bn254/fr" + "github.com/consensys/gnark-crypto/internal/parallel" + "math" + "runtime" + "sync" +) + +// CPUSemaphore enables users to set optional number of CPUs the multiexp will use +// this is thread safe and can be used accross parallel calls of MultiExp +type CPUSemaphore struct { + chCpus chan struct{} // semaphore to limit number of cpus iterating through points and scalrs at the same time + lock sync.Mutex +} + +// NewCPUSemaphore returns a new multiExp options to be used with MultiExp +// this option can be shared between different MultiExp calls and will ensure only numCpus are used +// through a semaphore +func NewCPUSemaphore(numCpus int) *CPUSemaphore { + toReturn := &CPUSemaphore{ + chCpus: make(chan struct{}, numCpus), + } + for i := 0; i < numCpus; i++ { + toReturn.chCpus <- struct{}{} + } + return toReturn +} + +// selector stores the index, mask and shifts needed to select bits from a scalar +// it is used during the multiExp algorithm or the batch scalar multiplication +type selector struct { + index uint64 // index in the multi-word scalar to select bits from + mask uint64 // mask (c-bit wide) + shift uint64 // shift needed to get our bits on low positions + + multiWordSelect bool // set to true if we need to select bits from 2 words (case where c doesn't divide 64) + maskHigh uint64 // same than mask, for index+1 + shiftHigh uint64 // same than shift, for index+1 +} + +// partitionScalars compute, for each scalars over c-bit wide windows, nbChunk digits +// if the digit is larger than 2^{c-1}, then, we borrow 2^c from the next window and substract +// 2^{c} to the current digit, making it negative. +// negative digits can be processed in a later step as adding -G into the bucket instead of G +// (computing -G is cheap, and this saves us half of the buckets in the MultiExp or BatchScalarMul) +func partitionScalars(scalars []fr.Element, c uint64) []fr.Element { + toReturn := make([]fr.Element, len(scalars)) + + // number of c-bit radixes in a scalar + nbChunks := fr.Limbs * 64 / c + if (fr.Limbs*64)%c != 0 { + nbChunks++ + } + + mask := uint64((1 << c) - 1) // low c bits are 1 + msbWindow := uint64(1 << (c - 1)) // msb of the c-bit window + max := int(1 << (c - 1)) // max value we want for our digits + cDivides64 := (64 % c) == 0 // if c doesn't divide 64, we may need to select over multiple words + + // compute offset and word selector / shift to select the right bits of our windows + selectors := make([]selector, nbChunks) + for chunk := uint64(0); chunk < nbChunks; chunk++ { + jc := uint64(chunk * c) + d := selector{} + d.index = jc / 64 + d.shift = jc - (d.index * 64) + d.mask = mask << d.shift + d.multiWordSelect = !cDivides64 && d.shift > (64-c) && d.index < (fr.Limbs-1) + if d.multiWordSelect { + nbBitsHigh := d.shift - uint64(64-c) + d.maskHigh = (1 << nbBitsHigh) - 1 + d.shiftHigh = (c - nbBitsHigh) + } + selectors[chunk] = d + } + + parallel.Execute(len(scalars), func(start, end int) { + for i := start; i < end; i++ { + var carry int + + // for each chunk in the scalar, compute the current digit, and an eventual carry + for chunk := uint64(0); chunk < nbChunks; chunk++ { + s := selectors[chunk] + + // init with carry if any + digit := carry + carry = 0 + + // digit = value of the c-bit window + digit += int((scalars[i][s.index] & s.mask) >> s.shift) + + if s.multiWordSelect { + // we are selecting bits over 2 words + digit += int(scalars[i][s.index+1]&s.maskHigh) << s.shiftHigh + } + + // if the digit is larger than 2^{c-1}, then, we borrow 2^c from the next window and substract + // 2^{c} to the current digit, making it negative. + if digit >= max { + digit -= (1 << c) + carry = 1 + } + + var bits uint64 + if digit >= 0 { + bits = uint64(digit) + } else { + bits = uint64(-digit-1) | msbWindow + } + + toReturn[i][s.index] |= (bits << s.shift) + if s.multiWordSelect { + toReturn[i][s.index+1] |= (bits >> s.shiftHigh) + } + + } + } + }) + return toReturn +} + +// MultiExp implements section 4 of https://eprint.iacr.org/2012/549.pdf +// optionally, takes as parameter a CPUSemaphore struct +// enabling to set max number of cpus to use +func (p *G1Affine) MultiExp(points []G1Affine, scalars []fr.Element, opts ...*CPUSemaphore) *G1Affine { + var _p G1Jac + _p.MultiExp(points, scalars, opts...) + p.FromJacobian(&_p) + return p +} + +// MultiExp implements section 4 of https://eprint.iacr.org/2012/549.pdf +// optionally, takes as parameter a CPUSemaphore struct +// enabling to set max number of cpus to use +func (p *G1Jac) MultiExp(points []G1Affine, scalars []fr.Element, opts ...*CPUSemaphore) *G1Jac { + // note: + // each of the msmCX method is the same, except for the c constant it declares + // duplicating (through template generation) these methods allows to declare the buckets on the stack + // the choice of c needs to be improved: + // there is a theoritical value that gives optimal asymptotics + // but in practice, other factors come into play, including: + // * if c doesn't divide 64, the word size, then we're bound to select bits over 2 words of our scalars, instead of 1 + // * number of CPUs + // * cache friendliness (which depends on the host, G1 or G2... ) + // --> for example, on BN254, a G1 point fits into one cache line of 64bytes, but a G2 point don't. + + // for each msmCX + // step 1 + // we compute, for each scalars over c-bit wide windows, nbChunk digits + // if the digit is larger than 2^{c-1}, then, we borrow 2^c from the next window and substract + // 2^{c} to the current digit, making it negative. + // negative digits will be processed in the next step as adding -G into the bucket instead of G + // (computing -G is cheap, and this saves us half of the buckets) + // step 2 + // buckets are declared on the stack + // notice that we have 2^{c-1} buckets instead of 2^{c} (see step1) + // we use jacobian extended formulas here as they are faster than mixed addition + // msmProcessChunk places points into buckets base on their selector and return the weighted bucket sum in given channel + // step 3 + // reduce the buckets weigthed sums into our result (msmReduceChunk) + + var opt *CPUSemaphore + if len(opts) > 0 { + opt = opts[0] + } else { + opt = NewCPUSemaphore(runtime.NumCPU()) + } + + var C uint64 + nbPoints := len(points) + + // implemented msmC methods (the c we use must be in this slice) + implementedCs := []uint64{4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 21} + + // approximate cost (in group operations) + // cost = bits/c * (nbPoints + 2^{c}) + // this needs to be verified empirically. + // for example, on a MBP 2016, for G2 MultiExp > 8M points, hand picking c gives better results + min := math.MaxFloat64 + for _, c := range implementedCs { + cc := fr.Limbs * 64 * (nbPoints + (1 << (c))) + cost := float64(cc) / float64(c) + if cost < min { + min = cost + C = c + } + } + + // empirical, needs to be tuned. + // if C > 16 && nbPoints < 1 << 23 { + // C = 16 + // } + + // take all the cpus to ourselves + opt.lock.Lock() + + // partition the scalars + // note: we do that before the actual chunk processing, as for each c-bit window (starting from LSW) + // if it's larger than 2^{c-1}, we have a carry we need to propagate up to the higher window + scalars = partitionScalars(scalars, C) + + switch C { + + case 4: + return p.msmC4(points, scalars, opt) + + case 5: + return p.msmC5(points, scalars, opt) + + case 6: + return p.msmC6(points, scalars, opt) + + case 7: + return p.msmC7(points, scalars, opt) + + case 8: + return p.msmC8(points, scalars, opt) + + case 9: + return p.msmC9(points, scalars, opt) + + case 10: + return p.msmC10(points, scalars, opt) + + case 11: + return p.msmC11(points, scalars, opt) + + case 12: + return p.msmC12(points, scalars, opt) + + case 13: + return p.msmC13(points, scalars, opt) + + case 14: + return p.msmC14(points, scalars, opt) + + case 15: + return p.msmC15(points, scalars, opt) + + case 16: + return p.msmC16(points, scalars, opt) + + case 20: + return p.msmC20(points, scalars, opt) + + case 21: + return p.msmC21(points, scalars, opt) + + case 22: + return p.msmC22(points, scalars, opt) + + default: + panic("unimplemented") + } +} + +// msmReduceChunkG1Affine reduces the weighted sum of the buckets into the result of the multiExp +func msmReduceChunkG1Affine(p *G1Jac, c int, chChunks []chan g1JacExtended) *G1Jac { + var _p g1JacExtended + totalj := <-chChunks[len(chChunks)-1] + _p.Set(&totalj) + for j := len(chChunks) - 2; j >= 0; j-- { + for l := 0; l < c; l++ { + _p.double(&_p) + } + totalj := <-chChunks[j] + _p.add(&totalj) + } + + return p.unsafeFromJacExtended(&_p) +} + +func msmProcessChunkG1Affine(chunk uint64, + chRes chan<- g1JacExtended, + buckets []g1JacExtended, + c uint64, + points []G1Affine, + scalars []fr.Element) { + + mask := uint64((1 << c) - 1) // low c bits are 1 + msbWindow := uint64(1 << (c - 1)) + + for i := 0; i < len(buckets); i++ { + buckets[i].setInfinity() + } + + jc := uint64(chunk * c) + s := selector{} + s.index = jc / 64 + s.shift = jc - (s.index * 64) + s.mask = mask << s.shift + s.multiWordSelect = (64%c) != 0 && s.shift > (64-c) && s.index < (fr.Limbs-1) + if s.multiWordSelect { + nbBitsHigh := s.shift - uint64(64-c) + s.maskHigh = (1 << nbBitsHigh) - 1 + s.shiftHigh = (c - nbBitsHigh) + } + + // for each scalars, get the digit corresponding to the chunk we're processing. + for i := 0; i < len(scalars); i++ { + bits := (scalars[i][s.index] & s.mask) >> s.shift + if s.multiWordSelect { + bits += (scalars[i][s.index+1] & s.maskHigh) << s.shiftHigh + } + + if bits == 0 { + continue + } + + // if msbWindow bit is set, we need to substract + if bits&msbWindow == 0 { + // add + buckets[bits-1].addMixed(&points[i]) + } else { + // sub + buckets[bits & ^msbWindow].subMixed(&points[i]) + } + } + + // reduce buckets into total + // total = bucket[0] + 2*bucket[1] + 3*bucket[2] ... + n*bucket[n-1] + + var runningSum, total g1JacExtended + runningSum.setInfinity() + total.setInfinity() + for k := len(buckets) - 1; k >= 0; k-- { + if !buckets[k].ZZ.IsZero() { + runningSum.add(&buckets[k]) + } + total.add(&runningSum) + } + + chRes <- total + close(chRes) +} + +func (p *G1Jac) msmC4(points []G1Affine, scalars []fr.Element, opt *CPUSemaphore) *G1Jac { + const c = 4 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g1JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + for chunk := nbChunks - 1; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG1Affine(p, c, chChunks[:]) +} + +func (p *G1Jac) msmC5(points []G1Affine, scalars []fr.Element, opt *CPUSemaphore) *G1Jac { + const c = 5 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g1JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG1Affine(p, c, chChunks[:]) +} + +func (p *G1Jac) msmC6(points []G1Affine, scalars []fr.Element, opt *CPUSemaphore) *G1Jac { + const c = 6 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g1JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG1Affine(p, c, chChunks[:]) +} + +func (p *G1Jac) msmC7(points []G1Affine, scalars []fr.Element, opt *CPUSemaphore) *G1Jac { + const c = 7 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g1JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG1Affine(p, c, chChunks[:]) +} + +func (p *G1Jac) msmC8(points []G1Affine, scalars []fr.Element, opt *CPUSemaphore) *G1Jac { + const c = 8 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g1JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + for chunk := nbChunks - 1; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG1Affine(p, c, chChunks[:]) +} + +func (p *G1Jac) msmC9(points []G1Affine, scalars []fr.Element, opt *CPUSemaphore) *G1Jac { + const c = 9 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g1JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG1Affine(p, c, chChunks[:]) +} + +func (p *G1Jac) msmC10(points []G1Affine, scalars []fr.Element, opt *CPUSemaphore) *G1Jac { + const c = 10 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g1JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG1Affine(p, c, chChunks[:]) +} + +func (p *G1Jac) msmC11(points []G1Affine, scalars []fr.Element, opt *CPUSemaphore) *G1Jac { + const c = 11 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g1JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG1Affine(p, c, chChunks[:]) +} + +func (p *G1Jac) msmC12(points []G1Affine, scalars []fr.Element, opt *CPUSemaphore) *G1Jac { + const c = 12 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g1JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG1Affine(p, c, chChunks[:]) +} + +func (p *G1Jac) msmC13(points []G1Affine, scalars []fr.Element, opt *CPUSemaphore) *G1Jac { + const c = 13 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g1JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG1Affine(p, c, chChunks[:]) +} + +func (p *G1Jac) msmC14(points []G1Affine, scalars []fr.Element, opt *CPUSemaphore) *G1Jac { + const c = 14 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g1JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG1Affine(p, c, chChunks[:]) +} + +func (p *G1Jac) msmC15(points []G1Affine, scalars []fr.Element, opt *CPUSemaphore) *G1Jac { + const c = 15 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g1JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG1Affine(p, c, chChunks[:]) +} + +func (p *G1Jac) msmC16(points []G1Affine, scalars []fr.Element, opt *CPUSemaphore) *G1Jac { + const c = 16 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g1JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + for chunk := nbChunks - 1; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG1Affine(p, c, chChunks[:]) +} + +func (p *G1Jac) msmC20(points []G1Affine, scalars []fr.Element, opt *CPUSemaphore) *G1Jac { + const c = 20 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g1JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG1Affine(p, c, chChunks[:]) +} + +func (p *G1Jac) msmC21(points []G1Affine, scalars []fr.Element, opt *CPUSemaphore) *G1Jac { + const c = 21 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g1JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG1Affine(p, c, chChunks[:]) +} + +func (p *G1Jac) msmC22(points []G1Affine, scalars []fr.Element, opt *CPUSemaphore) *G1Jac { + const c = 22 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g1JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g1JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g1JacExtended, points []G1Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g1JacExtended + msmProcessChunkG1Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG1Affine(p, c, chChunks[:]) +} + +// MultiExp implements section 4 of https://eprint.iacr.org/2012/549.pdf +// optionally, takes as parameter a CPUSemaphore struct +// enabling to set max number of cpus to use +func (p *G2Affine) MultiExp(points []G2Affine, scalars []fr.Element, opts ...*CPUSemaphore) *G2Affine { + var _p G2Jac + _p.MultiExp(points, scalars, opts...) + p.FromJacobian(&_p) + return p +} + +// MultiExp implements section 4 of https://eprint.iacr.org/2012/549.pdf +// optionally, takes as parameter a CPUSemaphore struct +// enabling to set max number of cpus to use +func (p *G2Jac) MultiExp(points []G2Affine, scalars []fr.Element, opts ...*CPUSemaphore) *G2Jac { + // note: + // each of the msmCX method is the same, except for the c constant it declares + // duplicating (through template generation) these methods allows to declare the buckets on the stack + // the choice of c needs to be improved: + // there is a theoritical value that gives optimal asymptotics + // but in practice, other factors come into play, including: + // * if c doesn't divide 64, the word size, then we're bound to select bits over 2 words of our scalars, instead of 1 + // * number of CPUs + // * cache friendliness (which depends on the host, G1 or G2... ) + // --> for example, on BN254, a G1 point fits into one cache line of 64bytes, but a G2 point don't. + + // for each msmCX + // step 1 + // we compute, for each scalars over c-bit wide windows, nbChunk digits + // if the digit is larger than 2^{c-1}, then, we borrow 2^c from the next window and substract + // 2^{c} to the current digit, making it negative. + // negative digits will be processed in the next step as adding -G into the bucket instead of G + // (computing -G is cheap, and this saves us half of the buckets) + // step 2 + // buckets are declared on the stack + // notice that we have 2^{c-1} buckets instead of 2^{c} (see step1) + // we use jacobian extended formulas here as they are faster than mixed addition + // msmProcessChunk places points into buckets base on their selector and return the weighted bucket sum in given channel + // step 3 + // reduce the buckets weigthed sums into our result (msmReduceChunk) + + var opt *CPUSemaphore + if len(opts) > 0 { + opt = opts[0] + } else { + opt = NewCPUSemaphore(runtime.NumCPU()) + } + + var C uint64 + nbPoints := len(points) + + // implemented msmC methods (the c we use must be in this slice) + implementedCs := []uint64{4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 21, 22} + + // approximate cost (in group operations) + // cost = bits/c * (nbPoints + 2^{c}) + // this needs to be verified empirically. + // for example, on a MBP 2016, for G2 MultiExp > 8M points, hand picking c gives better results + min := math.MaxFloat64 + for _, c := range implementedCs { + cc := fr.Limbs * 64 * (nbPoints + (1 << (c))) + cost := float64(cc) / float64(c) + if cost < min { + min = cost + C = c + } + } + + // empirical, needs to be tuned. + // if C > 16 && nbPoints < 1 << 23 { + // C = 16 + // } + + // take all the cpus to ourselves + opt.lock.Lock() + + // partition the scalars + // note: we do that before the actual chunk processing, as for each c-bit window (starting from LSW) + // if it's larger than 2^{c-1}, we have a carry we need to propagate up to the higher window + scalars = partitionScalars(scalars, C) + + switch C { + + case 4: + return p.msmC4(points, scalars, opt) + + case 5: + return p.msmC5(points, scalars, opt) + + case 6: + return p.msmC6(points, scalars, opt) + + case 7: + return p.msmC7(points, scalars, opt) + + case 8: + return p.msmC8(points, scalars, opt) + + case 9: + return p.msmC9(points, scalars, opt) + + case 10: + return p.msmC10(points, scalars, opt) + + case 11: + return p.msmC11(points, scalars, opt) + + case 12: + return p.msmC12(points, scalars, opt) + + case 13: + return p.msmC13(points, scalars, opt) + + case 14: + return p.msmC14(points, scalars, opt) + + case 15: + return p.msmC15(points, scalars, opt) + + case 16: + return p.msmC16(points, scalars, opt) + + case 20: + return p.msmC20(points, scalars, opt) + + case 21: + return p.msmC21(points, scalars, opt) + + case 22: + return p.msmC22(points, scalars, opt) + + default: + panic("unimplemented") + } +} + +// msmReduceChunkG2Affine reduces the weighted sum of the buckets into the result of the multiExp +func msmReduceChunkG2Affine(p *G2Jac, c int, chChunks []chan g2JacExtended) *G2Jac { + var _p g2JacExtended + totalj := <-chChunks[len(chChunks)-1] + _p.Set(&totalj) + for j := len(chChunks) - 2; j >= 0; j-- { + for l := 0; l < c; l++ { + _p.double(&_p) + } + totalj := <-chChunks[j] + _p.add(&totalj) + } + + return p.unsafeFromJacExtended(&_p) +} + +func msmProcessChunkG2Affine(chunk uint64, + chRes chan<- g2JacExtended, + buckets []g2JacExtended, + c uint64, + points []G2Affine, + scalars []fr.Element) { + + mask := uint64((1 << c) - 1) // low c bits are 1 + msbWindow := uint64(1 << (c - 1)) + + for i := 0; i < len(buckets); i++ { + buckets[i].setInfinity() + } + + jc := uint64(chunk * c) + s := selector{} + s.index = jc / 64 + s.shift = jc - (s.index * 64) + s.mask = mask << s.shift + s.multiWordSelect = (64%c) != 0 && s.shift > (64-c) && s.index < (fr.Limbs-1) + if s.multiWordSelect { + nbBitsHigh := s.shift - uint64(64-c) + s.maskHigh = (1 << nbBitsHigh) - 1 + s.shiftHigh = (c - nbBitsHigh) + } + + // for each scalars, get the digit corresponding to the chunk we're processing. + for i := 0; i < len(scalars); i++ { + bits := (scalars[i][s.index] & s.mask) >> s.shift + if s.multiWordSelect { + bits += (scalars[i][s.index+1] & s.maskHigh) << s.shiftHigh + } + + if bits == 0 { + continue + } + + // if msbWindow bit is set, we need to substract + if bits&msbWindow == 0 { + // add + buckets[bits-1].addMixed(&points[i]) + } else { + // sub + buckets[bits & ^msbWindow].subMixed(&points[i]) + } + } + + // reduce buckets into total + // total = bucket[0] + 2*bucket[1] + 3*bucket[2] ... + n*bucket[n-1] + + var runningSum, total g2JacExtended + runningSum.setInfinity() + total.setInfinity() + for k := len(buckets) - 1; k >= 0; k-- { + if !buckets[k].ZZ.IsZero() { + runningSum.add(&buckets[k]) + } + total.add(&runningSum) + } + + chRes <- total + close(chRes) +} + +func (p *G2Jac) msmC4(points []G2Affine, scalars []fr.Element, opt *CPUSemaphore) *G2Jac { + const c = 4 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g2JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + for chunk := nbChunks - 1; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG2Affine(p, c, chChunks[:]) +} + +func (p *G2Jac) msmC5(points []G2Affine, scalars []fr.Element, opt *CPUSemaphore) *G2Jac { + const c = 5 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g2JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG2Affine(p, c, chChunks[:]) +} + +func (p *G2Jac) msmC6(points []G2Affine, scalars []fr.Element, opt *CPUSemaphore) *G2Jac { + const c = 6 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g2JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG2Affine(p, c, chChunks[:]) +} + +func (p *G2Jac) msmC7(points []G2Affine, scalars []fr.Element, opt *CPUSemaphore) *G2Jac { + const c = 7 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g2JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG2Affine(p, c, chChunks[:]) +} + +func (p *G2Jac) msmC8(points []G2Affine, scalars []fr.Element, opt *CPUSemaphore) *G2Jac { + const c = 8 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g2JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + for chunk := nbChunks - 1; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG2Affine(p, c, chChunks[:]) +} + +func (p *G2Jac) msmC9(points []G2Affine, scalars []fr.Element, opt *CPUSemaphore) *G2Jac { + const c = 9 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g2JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG2Affine(p, c, chChunks[:]) +} + +func (p *G2Jac) msmC10(points []G2Affine, scalars []fr.Element, opt *CPUSemaphore) *G2Jac { + const c = 10 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g2JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG2Affine(p, c, chChunks[:]) +} + +func (p *G2Jac) msmC11(points []G2Affine, scalars []fr.Element, opt *CPUSemaphore) *G2Jac { + const c = 11 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g2JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG2Affine(p, c, chChunks[:]) +} + +func (p *G2Jac) msmC12(points []G2Affine, scalars []fr.Element, opt *CPUSemaphore) *G2Jac { + const c = 12 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g2JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG2Affine(p, c, chChunks[:]) +} + +func (p *G2Jac) msmC13(points []G2Affine, scalars []fr.Element, opt *CPUSemaphore) *G2Jac { + const c = 13 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g2JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG2Affine(p, c, chChunks[:]) +} + +func (p *G2Jac) msmC14(points []G2Affine, scalars []fr.Element, opt *CPUSemaphore) *G2Jac { + const c = 14 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g2JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG2Affine(p, c, chChunks[:]) +} + +func (p *G2Jac) msmC15(points []G2Affine, scalars []fr.Element, opt *CPUSemaphore) *G2Jac { + const c = 15 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g2JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG2Affine(p, c, chChunks[:]) +} + +func (p *G2Jac) msmC16(points []G2Affine, scalars []fr.Element, opt *CPUSemaphore) *G2Jac { + const c = 16 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g2JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + for chunk := nbChunks - 1; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG2Affine(p, c, chChunks[:]) +} + +func (p *G2Jac) msmC20(points []G2Affine, scalars []fr.Element, opt *CPUSemaphore) *G2Jac { + const c = 20 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g2JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG2Affine(p, c, chChunks[:]) +} + +func (p *G2Jac) msmC21(points []G2Affine, scalars []fr.Element, opt *CPUSemaphore) *G2Jac { + const c = 21 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g2JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG2Affine(p, c, chChunks[:]) +} + +func (p *G2Jac) msmC22(points []G2Affine, scalars []fr.Element, opt *CPUSemaphore) *G2Jac { + const c = 22 // scalars partitioned into c-bit radixes + const nbChunks = (fr.Limbs * 64 / c) + 1 // number of c-bit radixes in a scalar + + // for each chunk, spawn a go routine that'll loop through all the scalars + var chChunks [nbChunks]chan g2JacExtended + + // wait group to wait for all the go routines to start + var wg sync.WaitGroup + // c doesn't divide 256, last window is smaller we can allocate less buckets + const lastC = (fr.Limbs * 64) - (c * (fr.Limbs * 64 / c)) + chChunks[nbChunks-1] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (lastC - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(nbChunks-1), chChunks[nbChunks-1], points, scalars) + + for chunk := nbChunks - 2; chunk >= 0; chunk-- { + chChunks[chunk] = make(chan g2JacExtended, 1) + <-opt.chCpus // wait to have a cpu before scheduling + wg.Add(1) + go func(j uint64, chRes chan g2JacExtended, points []G2Affine, scalars []fr.Element) { + wg.Done() + var buckets [1 << (c - 1)]g2JacExtended + msmProcessChunkG2Affine(j, chRes, buckets[:], c, points, scalars) + opt.chCpus <- struct{}{} // release token in the semaphore + }(uint64(chunk), chChunks[chunk], points, scalars) + } + + // wait for all goRoutines to actually start + wg.Wait() + + // all my tasks are scheduled, I can let other func use avaiable tokens in the semaphore + opt.lock.Unlock() + return msmReduceChunkG2Affine(p, c, chChunks[:]) +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/pairing.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/pairing.go new file mode 100644 index 00000000000..c73918f7196 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/pairing.go @@ -0,0 +1,287 @@ +// Copyright 2020 ConsenSys AG +// +// 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. + +package bn254 + +import ( + "errors" + + "github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower" +) + +// GT target group of the pairing +type GT = fptower.E12 + +type lineEvaluation struct { + r0 fptower.E2 + r1 fptower.E2 + r2 fptower.E2 +} + +// Pair calculates the reduced pairing for a set of points +func Pair(P []G1Affine, Q []G2Affine) (GT, error) { + f, err := MillerLoop(P, Q) + if err != nil { + return GT{}, err + } + return FinalExponentiation(&f), nil +} + +// PairingCheck calculates the reduced pairing for a set of points and returns True if the result is One +func PairingCheck(P []G1Affine, Q []G2Affine) (bool, error) { + f, err := Pair(P, Q) + if err != nil { + return false, err + } + var one GT + one.SetOne() + return f.Equal(&one), nil +} + +// FinalExponentiation computes the final expo x**(p**6-1)(p**2+1)(p**4 - p**2 +1)/r +func FinalExponentiation(z *GT, _z ...*GT) GT { + + var result GT + result.Set(z) + + for _, e := range _z { + result.Mul(&result, e) + } + + // https://eprint.iacr.org/2008/490.pdf + var mt [4]GT // mt[i] is m^(t^i) + + // easy part + mt[0].Set(&result) + var temp GT + temp.Conjugate(&mt[0]) + mt[0].Inverse(&mt[0]) + temp.Mul(&temp, &mt[0]) + mt[0].FrobeniusSquare(&temp). + Mul(&mt[0], &temp) + + // hard part + mt[1].Expt(&mt[0]) + mt[2].Expt(&mt[1]) + mt[3].Expt(&mt[2]) + + var y [7]GT + + y[1].InverseUnitary(&mt[0]) + y[4].Set(&mt[1]) + y[5].InverseUnitary(&mt[2]) + y[6].Set(&mt[3]) + + mt[0].Frobenius(&mt[0]) + mt[1].Frobenius(&mt[1]) + mt[2].Frobenius(&mt[2]) + mt[3].Frobenius(&mt[3]) + + y[0].Set(&mt[0]) + y[3].InverseUnitary(&mt[1]) + y[4].Mul(&y[4], &mt[2]).InverseUnitary(&y[4]) + y[6].Mul(&y[6], &mt[3]).InverseUnitary(&y[6]) + + mt[0].Frobenius(&mt[0]) + mt[2].Frobenius(&mt[2]) + + y[0].Mul(&y[0], &mt[0]) + y[2].Set(&mt[2]) + + mt[0].Frobenius(&mt[0]) + + y[0].Mul(&y[0], &mt[0]) + + // compute addition chain + mt[0].CyclotomicSquare(&y[6]) + mt[0].Mul(&mt[0], &y[4]) + mt[0].Mul(&mt[0], &y[5]) + mt[1].Mul(&y[3], &y[5]) + mt[1].Mul(&mt[1], &mt[0]) + mt[0].Mul(&mt[0], &y[2]) + mt[1].CyclotomicSquare(&mt[1]) + mt[1].Mul(&mt[1], &mt[0]) + mt[1].CyclotomicSquare(&mt[1]) + mt[0].Mul(&mt[1], &y[1]) + mt[1].Mul(&mt[1], &y[0]) + mt[0].CyclotomicSquare(&mt[0]) + result.Mul(&mt[0], &mt[1]) + + return result +} + +// MillerLoop Miller loop +func MillerLoop(P []G1Affine, Q []G2Affine) (GT, error) { + n := len(P) + if n == 0 || n != len(Q) { + return GT{}, errors.New("invalid inputs sizes") + } + + // filter infinity points + p := make([]G1Affine, 0, n) + q := make([]G2Affine, 0, n) + + for k := 0; k < n; k++ { + if P[k].IsInfinity() || Q[k].IsInfinity() { + continue + } + p = append(p, P[k]) + q = append(q, Q[k]) + } + n = len(p) + + // projective points for Q + qProj := make([]g2Proj, n) + qNeg := make([]G2Affine, n) + for k := 0; k < n; k++ { + qProj[k].FromAffine(&q[k]) + qNeg[k].Neg(&q[k]) + } + + var result GT + result.SetOne() + + var l lineEvaluation + + for i := len(loopCounter) - 2; i >= 0; i-- { + result.Square(&result) + + for k := 0; k < n; k++ { + qProj[k].DoubleStep(&l) + // line evaluation + l.r0.MulByElement(&l.r0, &p[k].Y) + l.r1.MulByElement(&l.r1, &p[k].X) + result.MulBy034(&l.r0, &l.r1, &l.r2) + + if loopCounter[i] == 1 { + qProj[k].AddMixedStep(&l, &q[k]) + // line evaluation + l.r0.MulByElement(&l.r0, &p[k].Y) + l.r1.MulByElement(&l.r1, &p[k].X) + result.MulBy034(&l.r0, &l.r1, &l.r2) + + } else if loopCounter[i] == -1 { + qProj[k].AddMixedStep(&l, &qNeg[k]) + // line evaluation + l.r0.MulByElement(&l.r0, &p[k].Y) + l.r1.MulByElement(&l.r1, &p[k].X) + result.MulBy034(&l.r0, &l.r1, &l.r2) + } + } + } + + var Q1, Q2 G2Affine + // cf https://eprint.iacr.org/2010/354.pdf for instance for optimal Ate Pairing + for k := 0; k < n; k++ { + //Q1 = Frob(Q) + Q1.X.Conjugate(&q[k].X).MulByNonResidue1Power2(&Q1.X) + Q1.Y.Conjugate(&q[k].Y).MulByNonResidue1Power3(&Q1.Y) + + // Q2 = -Frob2(Q) + Q2.X.MulByNonResidue2Power2(&q[k].X) + Q2.Y.MulByNonResidue2Power3(&q[k].Y).Neg(&Q2.Y) + + qProj[k].AddMixedStep(&l, &Q1) + // line evaluation + l.r0.MulByElement(&l.r0, &p[k].Y) + l.r1.MulByElement(&l.r1, &p[k].X) + result.MulBy034(&l.r0, &l.r1, &l.r2) + + qProj[k].AddMixedStep(&l, &Q2) + // line evaluation + l.r0.MulByElement(&l.r0, &p[k].Y) + l.r1.MulByElement(&l.r1, &p[k].X) + result.MulBy034(&l.r0, &l.r1, &l.r2) + } + + return result, nil +} + +// DoubleStep doubles a point in Homogenous projective coordinates, and evaluates the line in Miller loop +// https://eprint.iacr.org/2013/722.pdf (Section 4.3) +func (p *g2Proj) DoubleStep(evaluations *lineEvaluation) { + + // get some Element from our pool + var t0, t1, A, B, C, D, E, EE, F, G, H, I, J, K fptower.E2 + t0.Mul(&p.x, &p.y) + A.MulByElement(&t0, &twoInv) + B.Square(&p.y) + C.Square(&p.z) + D.Double(&C). + Add(&D, &C) + E.Mul(&D, &bTwistCurveCoeff) + F.Double(&E). + Add(&F, &E) + G.Add(&B, &F) + G.MulByElement(&G, &twoInv) + H.Add(&p.y, &p.z). + Square(&H) + t1.Add(&B, &C) + H.Sub(&H, &t1) + I.Sub(&E, &B) + J.Square(&p.x) + EE.Square(&E) + K.Double(&EE). + Add(&K, &EE) + + // X, Y, Z + p.x.Sub(&B, &F). + Mul(&p.x, &A) + p.y.Square(&G). + Sub(&p.y, &K) + p.z.Mul(&B, &H) + + // Line evaluation + evaluations.r0.Neg(&H) + evaluations.r1.Double(&J). + Add(&evaluations.r1, &J) + evaluations.r2.Set(&I) +} + +// AddMixedStep point addition in Mixed Homogenous projective and Affine coordinates +// https://eprint.iacr.org/2013/722.pdf (Section 4.3) +func (p *g2Proj) AddMixedStep(evaluations *lineEvaluation, a *G2Affine) { + + // get some Element from our pool + var Y2Z1, X2Z1, O, L, C, D, E, F, G, H, t0, t1, t2, J fptower.E2 + Y2Z1.Mul(&a.Y, &p.z) + O.Sub(&p.y, &Y2Z1) + X2Z1.Mul(&a.X, &p.z) + L.Sub(&p.x, &X2Z1) + C.Square(&O) + D.Square(&L) + E.Mul(&L, &D) + F.Mul(&p.z, &C) + G.Mul(&p.x, &D) + t0.Double(&G) + H.Add(&E, &F). + Sub(&H, &t0) + t1.Mul(&p.y, &E) + + // X, Y, Z + p.x.Mul(&L, &H) + p.y.Sub(&G, &H). + Mul(&p.y, &O). + Sub(&p.y, &t1) + p.z.Mul(&E, &p.z) + + t2.Mul(&L, &a.Y) + J.Mul(&a.X, &O). + Sub(&J, &t2) + + // Line evaluation + evaluations.r0.Set(&L) + evaluations.r1.Neg(&O) + evaluations.r2.Set(&J) +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/ecc.go b/vendor/github.com/consensys/gnark-crypto/ecc/ecc.go new file mode 100644 index 00000000000..f6afa3159c6 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/ecc.go @@ -0,0 +1,46 @@ +/* +Copyright © 2020 ConsenSys + +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. +*/ + +// Package ecc is an elliptic curve (+pairing) library. +// Provides implementation for bls12-381, bls12-377, bn254, bw6-761 and their twisted edwards "companion curves" +package ecc + +// do not modify the order of this enum +const ( + UNKNOWN ID = iota + BN254 + BLS12_377 + BLS12_381 + BW6_761 +) + +// ID represent a unique ID for a curve +type ID uint16 + +func (id ID) String() string { + switch id { + case BLS12_377: + return "bls12_377" + case BLS12_381: + return "bls12_381" + case BN254: + return "bn254" + case BW6_761: + return "bw6_761" + default: + panic("unimplemented ecc ID") + } +} diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/ecc.md b/vendor/github.com/consensys/gnark-crypto/ecc/ecc.md new file mode 100644 index 00000000000..11aec026988 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/ecc.md @@ -0,0 +1,13 @@ +## Supported curves + +* BLS12-381 (Zcash) +* BN254 (Ethereum) +* BLS12-377 (ZEXE) +* BW6-761 (EC supporting pairing on BLS12-377 field of definition) + +### Twisted edwards curves + +Each of these curve has a `twistededwards` sub-package with its companion curve. Also known as [Jubjub](https://z.cash/technology/jubjub/) (BLS12-381) or [Baby-Jubjub](https://iden3-docs.readthedocs.io/en/latest/_downloads/33717d75ab84e11313cc0d8a090b636f/Baby-Jubjub.pdf) (BN254). + +They are of particular interest as they allow efficient elliptic curve cryptography inside zkSNARK circuits. + diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/utils.go b/vendor/github.com/consensys/gnark-crypto/ecc/utils.go new file mode 100644 index 00000000000..44ecf200c38 --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/ecc/utils.go @@ -0,0 +1,251 @@ +package ecc + +import ( + "crypto/sha256" + "errors" + "math/big" +) + +//------------------------------------------------------- +// Ate loop counter (not used for each curve) + +// NafDecomposition gets the naf decomposition of a big number +func NafDecomposition(a *big.Int, result []int8) int { + + var zero, one, two, three big.Int + + one.SetUint64(1) + two.SetUint64(2) + three.SetUint64(3) + + length := 0 + + // some buffers + var buf, aCopy big.Int + aCopy.Set(a) + + for aCopy.Cmp(&zero) != 0 { + + // if aCopy % 2 == 0 + buf.And(&aCopy, &one) + + // aCopy even + if buf.Cmp(&zero) == 0 { + result[length] = 0 + } else { // aCopy odd + buf.And(&aCopy, &three) + if buf.Cmp(&three) == 0 { + result[length] = -1 + aCopy.Add(&aCopy, &one) + } else { + result[length] = 1 + } + } + aCopy.Rsh(&aCopy, 1) + length++ + } + return length +} + +//------------------------------------------------------- +// GLV utils + +// Lattice represents a Z module spanned by V1, V2. +// det is the associated determinant. +type Lattice struct { + V1, V2 [2]big.Int + Det big.Int +} + +// PrecomputeLattice res such that res.V1, res.V2 +// are short vectors satisfying v11+v12lambda=v21+v22lambda=0[r]. +// cf https://www.iacr.org/archive/crypto2001/21390189.pdf +func PrecomputeLattice(r, lambda *big.Int, res *Lattice) { + + var rst [2][3]big.Int + var tmp [3]big.Int + var quotient, remainder, sqroot, _r, _t big.Int + + rst[0][0].Set(r) + rst[0][1].SetUint64(1) + rst[0][2].SetUint64(0) + + rst[1][0].Set(lambda) + rst[1][1].SetUint64(0) + rst[1][2].SetUint64(1) + + sqroot.Sqrt(r) + + var one big.Int + one.SetUint64(1) + + // r_i+1 = r_i-1 - q_i.r_i + // s_i+1 = s_i-1 - q_i.s_i + // t_i+1 = t_i-1 - q_i.s_i + for rst[1][0].Cmp(&sqroot) >= 1 { + + quotient.Div(&rst[0][0], &rst[1][0]) + remainder.Mod(&rst[0][0], &rst[1][0]) + + tmp[0].Set(&rst[1][0]) + tmp[1].Set(&rst[1][1]) + tmp[2].Set(&rst[1][2]) + + rst[1][0].Set(&remainder) + rst[1][1].Mul(&rst[1][1], "ient).Sub(&rst[0][1], &rst[1][1]) + rst[1][2].Mul(&rst[1][2], "ient).Sub(&rst[0][2], &rst[1][2]) + + rst[0][0].Set(&tmp[0]) + rst[0][1].Set(&tmp[1]) + rst[0][2].Set(&tmp[2]) + } + + quotient.Div(&rst[0][0], &rst[1][0]) + remainder.Mod(&rst[0][0], &rst[1][0]) + _r.Set(&remainder) + _t.Mul(&rst[1][2], "ient).Sub(&rst[0][2], &_t) + + res.V1[0].Set(&rst[1][0]) + res.V1[1].Neg(&rst[1][2]) + + // take the shorter of [rst[0][0], rst[0][2]], [_r, _t] + tmp[1].Mul(&rst[0][2], &rst[0][2]) + tmp[0].Mul(&rst[0][0], &rst[0][0]).Add(&tmp[1], &tmp[0]) + tmp[2].Mul(&_r, &_r) + tmp[1].Mul(&_t, &_t).Add(&tmp[2], &tmp[1]) + if tmp[0].Cmp(&tmp[1]) == 1 { + res.V2[0].Set(&_r) + res.V2[1].Neg(&_t) + } else { + res.V2[0].Set(&rst[0][0]) + res.V2[1].Neg(&rst[0][2]) + } + + // sets determinant + tmp[0].Mul(&res.V1[1], &res.V2[0]) + res.Det.Mul(&res.V1[0], &res.V2[1]).Sub(&res.Det, &tmp[0]) + +} + +// SplitScalar outputs u,v such that u+vlambda=s[r]. +// The method is to view s as (s,0) in ZxZ, and find a close +// vector w of (s,0) in , where l is a sub Z-module of +// ker((a,b)->a+blambda[r]): then (u,v)=w-(s,0), and +// u+vlambda=s[r]. +// cf https://www.iacr.org/archive/crypto2001/21390189.pdf +func SplitScalar(s *big.Int, l *Lattice) [2]big.Int { + + var k1, k2 big.Int + k1.Mul(s, &l.V2[1]) + k2.Mul(s, &l.V1[1]).Neg(&k2) + rounding(&k1, &l.Det, &k1) + rounding(&k2, &l.Det, &k2) + v := getVector(l, &k1, &k2) + v[0].Sub(s, &v[0]) + v[1].Neg(&v[1]) + return v +} + +// sets res to the closest integer from n/d +func rounding(n, d, res *big.Int) { + var dshift, r, one big.Int + one.SetUint64(1) + dshift.Rsh(d, 1) + r.Mod(n, d) + res.Div(n, d) + if r.Cmp(&dshift) == 1 { + res.Add(res, &one) + } +} + +// getVector returns axV1 + bxV2 +func getVector(l *Lattice, a, b *big.Int) [2]big.Int { + var res [2]big.Int + var tmp big.Int + tmp.Mul(b, &l.V2[0]) + res[0].Mul(a, &l.V1[0]).Add(&res[0], &tmp) + tmp.Mul(b, &l.V2[1]) + res[1].Mul(a, &l.V1[1]).Add(&res[1], &tmp) + return res +} + +// ExpandMsgXmd expands msg to a slice of lenInBytes bytes. +// https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-06#section-5 +// https://tools.ietf.org/html/rfc8017#section-4.1 (I2OSP/O2ISP) +func ExpandMsgXmd(msg, dst []byte, lenInBytes int) ([]byte, error) { + + h := sha256.New() + ell := (lenInBytes + h.Size() - 1) / h.Size() // ceil(len_in_bytes / b_in_bytes) + if ell > 255 { + return nil, errors.New("invalid lenInBytes") + } + if len(dst) > 255 { + return nil, errors.New("invalid domain size (>255 bytes)") + } + sizeDomain := uint8(len(dst)) + + // Z_pad = I2OSP(0, r_in_bytes) + // l_i_b_str = I2OSP(len_in_bytes, 2) + // DST_prime = I2OSP(len(DST), 1) || DST + // b_0 = H(Z_pad || msg || l_i_b_str || I2OSP(0, 1) || DST_prime) + h.Reset() + if _, err := h.Write(make([]byte, h.BlockSize())); err != nil { + return nil, err + } + if _, err := h.Write(msg); err != nil { + return nil, err + } + if _, err := h.Write([]byte{uint8(lenInBytes >> 8), uint8(lenInBytes), uint8(0)}); err != nil { + return nil, err + } + if _, err := h.Write(dst); err != nil { + return nil, err + } + if _, err := h.Write([]byte{sizeDomain}); err != nil { + return nil, err + } + b0 := h.Sum(nil) + + // b_1 = H(b_0 || I2OSP(1, 1) || DST_prime) + h.Reset() + if _, err := h.Write(b0); err != nil { + return nil, err + } + if _, err := h.Write([]byte{uint8(1)}); err != nil { + return nil, err + } + if _, err := h.Write(dst); err != nil { + return nil, err + } + if _, err := h.Write([]byte{sizeDomain}); err != nil { + return nil, err + } + b1 := h.Sum(nil) + + res := make([]byte, lenInBytes) + copy(res[:h.Size()], b1) + + for i := 2; i <= ell; i++ { + // b_i = H(strxor(b_0, b_(i - 1)) || I2OSP(i, 1) || DST_prime) + h.Reset() + strxor := make([]byte, h.Size()) + for j := 0; j < h.Size(); j++ { + strxor[j] = b0[j] ^ b1[j] + } + if _, err := h.Write(strxor); err != nil { + return nil, err + } + if _, err := h.Write([]byte{uint8(i)}); err != nil { + return nil, err + } + if _, err := h.Write(dst); err != nil { + return nil, err + } + if _, err := h.Write([]byte{sizeDomain}); err != nil { + return nil, err + } + b1 = h.Sum(nil) + copy(res[h.Size()*(i-1):h.Size()*i], b1) + } + return res, nil +} diff --git a/vendor/github.com/consensys/gnark-crypto/internal/parallel/execute.go b/vendor/github.com/consensys/gnark-crypto/internal/parallel/execute.go new file mode 100644 index 00000000000..803de3c1b1d --- /dev/null +++ b/vendor/github.com/consensys/gnark-crypto/internal/parallel/execute.go @@ -0,0 +1,44 @@ +package parallel + +import ( + "runtime" + "sync" +) + +// Execute process in parallel the work function +func Execute(nbIterations int, work func(int, int), maxCpus ...int) { + + nbTasks := runtime.NumCPU() + if len(maxCpus) == 1 { + nbTasks = maxCpus[0] + } + nbIterationsPerCpus := nbIterations / nbTasks + + // more CPUs than tasks: a CPU will work on exactly one iteration + if nbIterationsPerCpus < 1 { + nbIterationsPerCpus = 1 + nbTasks = nbIterations + } + + var wg sync.WaitGroup + + extraTasks := nbIterations - (nbTasks * nbIterationsPerCpus) + extraTasksOffset := 0 + + for i := 0; i < nbTasks; i++ { + wg.Add(1) + _start := i*nbIterationsPerCpus + extraTasksOffset + _end := _start + nbIterationsPerCpus + if extraTasks > 0 { + _end++ + extraTasks-- + extraTasksOffset++ + } + go func() { + work(_start, _end) + wg.Done() + }() + } + + wg.Wait() +} diff --git a/vendor/github.com/hyperledger/fabric-amcl/core/AES.go b/vendor/github.com/hyperledger/fabric-amcl/core/AES.go new file mode 100644 index 00000000000..5767e6666ff --- /dev/null +++ b/vendor/github.com/hyperledger/fabric-amcl/core/AES.go @@ -0,0 +1,835 @@ +/* + * Copyright (c) 2012-2020 MIRACL UK Ltd. + * + * This file is part of MIRACL Core + * (see https://github.com/miracl/core). + * + * 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. + */ + +/* AES Encryption */ + +package core + +//import "fmt" + +const AES_ECB int = 0 +const AES_CBC int = 1 +const AES_CFB1 int = 2 +const AES_CFB2 int = 3 +const AES_CFB4 int = 5 +const AES_OFB1 int = 14 +const AES_OFB2 int = 15 +const AES_OFB4 int = 17 +const AES_OFB8 int = 21 +const AES_OFB16 int = 29 +const AES_CTR1 int = 30 +const AES_CTR2 int = 31 +const AES_CTR4 int = 33 +const AES_CTR8 int = 37 +const AES_CTR16 int = 45 + +var aes_InCo = [...]byte{0xB, 0xD, 0x9, 0xE} /* Inverse Coefficients */ + +var aes_ptab = [...]byte{ + 1, 3, 5, 15, 17, 51, 85, 255, 26, 46, 114, 150, 161, 248, 19, 53, + 95, 225, 56, 72, 216, 115, 149, 164, 247, 2, 6, 10, 30, 34, 102, 170, + 229, 52, 92, 228, 55, 89, 235, 38, 106, 190, 217, 112, 144, 171, 230, 49, + 83, 245, 4, 12, 20, 60, 68, 204, 79, 209, 104, 184, 211, 110, 178, 205, + 76, 212, 103, 169, 224, 59, 77, 215, 98, 166, 241, 8, 24, 40, 120, 136, + 131, 158, 185, 208, 107, 189, 220, 127, 129, 152, 179, 206, 73, 219, 118, 154, + 181, 196, 87, 249, 16, 48, 80, 240, 11, 29, 39, 105, 187, 214, 97, 163, + 254, 25, 43, 125, 135, 146, 173, 236, 47, 113, 147, 174, 233, 32, 96, 160, + 251, 22, 58, 78, 210, 109, 183, 194, 93, 231, 50, 86, 250, 21, 63, 65, + 195, 94, 226, 61, 71, 201, 64, 192, 91, 237, 44, 116, 156, 191, 218, 117, + 159, 186, 213, 100, 172, 239, 42, 126, 130, 157, 188, 223, 122, 142, 137, 128, + 155, 182, 193, 88, 232, 35, 101, 175, 234, 37, 111, 177, 200, 67, 197, 84, + 252, 31, 33, 99, 165, 244, 7, 9, 27, 45, 119, 153, 176, 203, 70, 202, + 69, 207, 74, 222, 121, 139, 134, 145, 168, 227, 62, 66, 198, 81, 243, 14, + 18, 54, 90, 238, 41, 123, 141, 140, 143, 138, 133, 148, 167, 242, 13, 23, + 57, 75, 221, 124, 132, 151, 162, 253, 28, 36, 108, 180, 199, 82, 246, 1} + +var aes_ltab = [...]byte{ + 0, 255, 25, 1, 50, 2, 26, 198, 75, 199, 27, 104, 51, 238, 223, 3, + 100, 4, 224, 14, 52, 141, 129, 239, 76, 113, 8, 200, 248, 105, 28, 193, + 125, 194, 29, 181, 249, 185, 39, 106, 77, 228, 166, 114, 154, 201, 9, 120, + 101, 47, 138, 5, 33, 15, 225, 36, 18, 240, 130, 69, 53, 147, 218, 142, + 150, 143, 219, 189, 54, 208, 206, 148, 19, 92, 210, 241, 64, 70, 131, 56, + 102, 221, 253, 48, 191, 6, 139, 98, 179, 37, 226, 152, 34, 136, 145, 16, + 126, 110, 72, 195, 163, 182, 30, 66, 58, 107, 40, 84, 250, 133, 61, 186, + 43, 121, 10, 21, 155, 159, 94, 202, 78, 212, 172, 229, 243, 115, 167, 87, + 175, 88, 168, 80, 244, 234, 214, 116, 79, 174, 233, 213, 231, 230, 173, 232, + 44, 215, 117, 122, 235, 22, 11, 245, 89, 203, 95, 176, 156, 169, 81, 160, + 127, 12, 246, 111, 23, 196, 73, 236, 216, 67, 31, 45, 164, 118, 123, 183, + 204, 187, 62, 90, 251, 96, 177, 134, 59, 82, 161, 108, 170, 85, 41, 157, + 151, 178, 135, 144, 97, 190, 220, 252, 188, 149, 207, 205, 55, 63, 91, 209, + 83, 57, 132, 60, 65, 162, 109, 71, 20, 42, 158, 93, 86, 242, 211, 171, + 68, 17, 146, 217, 35, 32, 46, 137, 180, 124, 184, 38, 119, 153, 227, 165, + 103, 74, 237, 222, 197, 49, 254, 24, 13, 99, 140, 128, 192, 247, 112, 7} + +var aes_fbsub = [...]byte{ + 99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118, + 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192, + 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21, + 4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117, + 9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132, + 83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207, + 208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168, + 81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 255, 243, 210, + 205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115, + 96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219, + 224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121, + 231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8, + 186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138, + 112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158, + 225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223, + 140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22} + +var aes_rbsub = [...]byte{ + 82, 9, 106, 213, 48, 54, 165, 56, 191, 64, 163, 158, 129, 243, 215, 251, + 124, 227, 57, 130, 155, 47, 255, 135, 52, 142, 67, 68, 196, 222, 233, 203, + 84, 123, 148, 50, 166, 194, 35, 61, 238, 76, 149, 11, 66, 250, 195, 78, + 8, 46, 161, 102, 40, 217, 36, 178, 118, 91, 162, 73, 109, 139, 209, 37, + 114, 248, 246, 100, 134, 104, 152, 22, 212, 164, 92, 204, 93, 101, 182, 146, + 108, 112, 72, 80, 253, 237, 185, 218, 94, 21, 70, 87, 167, 141, 157, 132, + 144, 216, 171, 0, 140, 188, 211, 10, 247, 228, 88, 5, 184, 179, 69, 6, + 208, 44, 30, 143, 202, 63, 15, 2, 193, 175, 189, 3, 1, 19, 138, 107, + 58, 145, 17, 65, 79, 103, 220, 234, 151, 242, 207, 206, 240, 180, 230, 115, + 150, 172, 116, 34, 231, 173, 53, 133, 226, 249, 55, 232, 28, 117, 223, 110, + 71, 241, 26, 113, 29, 41, 197, 137, 111, 183, 98, 14, 170, 24, 190, 27, + 252, 86, 62, 75, 198, 210, 121, 32, 154, 219, 192, 254, 120, 205, 90, 244, + 31, 221, 168, 51, 136, 7, 199, 49, 177, 18, 16, 89, 39, 128, 236, 95, + 96, 81, 127, 169, 25, 181, 74, 13, 45, 229, 122, 159, 147, 201, 156, 239, + 160, 224, 59, 77, 174, 42, 245, 176, 200, 235, 187, 60, 131, 83, 153, 97, + 23, 43, 4, 126, 186, 119, 214, 38, 225, 105, 20, 99, 85, 33, 12, 125} + +var aes_rco = [...]byte{1, 2, 4, 8, 16, 32, 64, 128, 27, 54, 108, 216, 171, 77, 154, 47} + +var aes_ftable = [...]uint32{ + 0xa56363c6, 0x847c7cf8, 0x997777ee, 0x8d7b7bf6, 0xdf2f2ff, 0xbd6b6bd6, + 0xb16f6fde, 0x54c5c591, 0x50303060, 0x3010102, 0xa96767ce, 0x7d2b2b56, + 0x19fefee7, 0x62d7d7b5, 0xe6abab4d, 0x9a7676ec, 0x45caca8f, 0x9d82821f, + 0x40c9c989, 0x877d7dfa, 0x15fafaef, 0xeb5959b2, 0xc947478e, 0xbf0f0fb, + 0xecadad41, 0x67d4d4b3, 0xfda2a25f, 0xeaafaf45, 0xbf9c9c23, 0xf7a4a453, + 0x967272e4, 0x5bc0c09b, 0xc2b7b775, 0x1cfdfde1, 0xae93933d, 0x6a26264c, + 0x5a36366c, 0x413f3f7e, 0x2f7f7f5, 0x4fcccc83, 0x5c343468, 0xf4a5a551, + 0x34e5e5d1, 0x8f1f1f9, 0x937171e2, 0x73d8d8ab, 0x53313162, 0x3f15152a, + 0xc040408, 0x52c7c795, 0x65232346, 0x5ec3c39d, 0x28181830, 0xa1969637, + 0xf05050a, 0xb59a9a2f, 0x907070e, 0x36121224, 0x9b80801b, 0x3de2e2df, + 0x26ebebcd, 0x6927274e, 0xcdb2b27f, 0x9f7575ea, 0x1b090912, 0x9e83831d, + 0x742c2c58, 0x2e1a1a34, 0x2d1b1b36, 0xb26e6edc, 0xee5a5ab4, 0xfba0a05b, + 0xf65252a4, 0x4d3b3b76, 0x61d6d6b7, 0xceb3b37d, 0x7b292952, 0x3ee3e3dd, + 0x712f2f5e, 0x97848413, 0xf55353a6, 0x68d1d1b9, 0x0, 0x2cededc1, + 0x60202040, 0x1ffcfce3, 0xc8b1b179, 0xed5b5bb6, 0xbe6a6ad4, 0x46cbcb8d, + 0xd9bebe67, 0x4b393972, 0xde4a4a94, 0xd44c4c98, 0xe85858b0, 0x4acfcf85, + 0x6bd0d0bb, 0x2aefefc5, 0xe5aaaa4f, 0x16fbfbed, 0xc5434386, 0xd74d4d9a, + 0x55333366, 0x94858511, 0xcf45458a, 0x10f9f9e9, 0x6020204, 0x817f7ffe, + 0xf05050a0, 0x443c3c78, 0xba9f9f25, 0xe3a8a84b, 0xf35151a2, 0xfea3a35d, + 0xc0404080, 0x8a8f8f05, 0xad92923f, 0xbc9d9d21, 0x48383870, 0x4f5f5f1, + 0xdfbcbc63, 0xc1b6b677, 0x75dadaaf, 0x63212142, 0x30101020, 0x1affffe5, + 0xef3f3fd, 0x6dd2d2bf, 0x4ccdcd81, 0x140c0c18, 0x35131326, 0x2fececc3, + 0xe15f5fbe, 0xa2979735, 0xcc444488, 0x3917172e, 0x57c4c493, 0xf2a7a755, + 0x827e7efc, 0x473d3d7a, 0xac6464c8, 0xe75d5dba, 0x2b191932, 0x957373e6, + 0xa06060c0, 0x98818119, 0xd14f4f9e, 0x7fdcdca3, 0x66222244, 0x7e2a2a54, + 0xab90903b, 0x8388880b, 0xca46468c, 0x29eeeec7, 0xd3b8b86b, 0x3c141428, + 0x79dedea7, 0xe25e5ebc, 0x1d0b0b16, 0x76dbdbad, 0x3be0e0db, 0x56323264, + 0x4e3a3a74, 0x1e0a0a14, 0xdb494992, 0xa06060c, 0x6c242448, 0xe45c5cb8, + 0x5dc2c29f, 0x6ed3d3bd, 0xefacac43, 0xa66262c4, 0xa8919139, 0xa4959531, + 0x37e4e4d3, 0x8b7979f2, 0x32e7e7d5, 0x43c8c88b, 0x5937376e, 0xb76d6dda, + 0x8c8d8d01, 0x64d5d5b1, 0xd24e4e9c, 0xe0a9a949, 0xb46c6cd8, 0xfa5656ac, + 0x7f4f4f3, 0x25eaeacf, 0xaf6565ca, 0x8e7a7af4, 0xe9aeae47, 0x18080810, + 0xd5baba6f, 0x887878f0, 0x6f25254a, 0x722e2e5c, 0x241c1c38, 0xf1a6a657, + 0xc7b4b473, 0x51c6c697, 0x23e8e8cb, 0x7cdddda1, 0x9c7474e8, 0x211f1f3e, + 0xdd4b4b96, 0xdcbdbd61, 0x868b8b0d, 0x858a8a0f, 0x907070e0, 0x423e3e7c, + 0xc4b5b571, 0xaa6666cc, 0xd8484890, 0x5030306, 0x1f6f6f7, 0x120e0e1c, + 0xa36161c2, 0x5f35356a, 0xf95757ae, 0xd0b9b969, 0x91868617, 0x58c1c199, + 0x271d1d3a, 0xb99e9e27, 0x38e1e1d9, 0x13f8f8eb, 0xb398982b, 0x33111122, + 0xbb6969d2, 0x70d9d9a9, 0x898e8e07, 0xa7949433, 0xb69b9b2d, 0x221e1e3c, + 0x92878715, 0x20e9e9c9, 0x49cece87, 0xff5555aa, 0x78282850, 0x7adfdfa5, + 0x8f8c8c03, 0xf8a1a159, 0x80898909, 0x170d0d1a, 0xdabfbf65, 0x31e6e6d7, + 0xc6424284, 0xb86868d0, 0xc3414182, 0xb0999929, 0x772d2d5a, 0x110f0f1e, + 0xcbb0b07b, 0xfc5454a8, 0xd6bbbb6d, 0x3a16162c} + +var aes_rtable = [...]uint32{ + 0x50a7f451, 0x5365417e, 0xc3a4171a, 0x965e273a, 0xcb6bab3b, 0xf1459d1f, + 0xab58faac, 0x9303e34b, 0x55fa3020, 0xf66d76ad, 0x9176cc88, 0x254c02f5, + 0xfcd7e54f, 0xd7cb2ac5, 0x80443526, 0x8fa362b5, 0x495ab1de, 0x671bba25, + 0x980eea45, 0xe1c0fe5d, 0x2752fc3, 0x12f04c81, 0xa397468d, 0xc6f9d36b, + 0xe75f8f03, 0x959c9215, 0xeb7a6dbf, 0xda595295, 0x2d83bed4, 0xd3217458, + 0x2969e049, 0x44c8c98e, 0x6a89c275, 0x78798ef4, 0x6b3e5899, 0xdd71b927, + 0xb64fe1be, 0x17ad88f0, 0x66ac20c9, 0xb43ace7d, 0x184adf63, 0x82311ae5, + 0x60335197, 0x457f5362, 0xe07764b1, 0x84ae6bbb, 0x1ca081fe, 0x942b08f9, + 0x58684870, 0x19fd458f, 0x876cde94, 0xb7f87b52, 0x23d373ab, 0xe2024b72, + 0x578f1fe3, 0x2aab5566, 0x728ebb2, 0x3c2b52f, 0x9a7bc586, 0xa50837d3, + 0xf2872830, 0xb2a5bf23, 0xba6a0302, 0x5c8216ed, 0x2b1ccf8a, 0x92b479a7, + 0xf0f207f3, 0xa1e2694e, 0xcdf4da65, 0xd5be0506, 0x1f6234d1, 0x8afea6c4, + 0x9d532e34, 0xa055f3a2, 0x32e18a05, 0x75ebf6a4, 0x39ec830b, 0xaaef6040, + 0x69f715e, 0x51106ebd, 0xf98a213e, 0x3d06dd96, 0xae053edd, 0x46bde64d, + 0xb58d5491, 0x55dc471, 0x6fd40604, 0xff155060, 0x24fb9819, 0x97e9bdd6, + 0xcc434089, 0x779ed967, 0xbd42e8b0, 0x888b8907, 0x385b19e7, 0xdbeec879, + 0x470a7ca1, 0xe90f427c, 0xc91e84f8, 0x0, 0x83868009, 0x48ed2b32, + 0xac70111e, 0x4e725a6c, 0xfbff0efd, 0x5638850f, 0x1ed5ae3d, 0x27392d36, + 0x64d90f0a, 0x21a65c68, 0xd1545b9b, 0x3a2e3624, 0xb1670a0c, 0xfe75793, + 0xd296eeb4, 0x9e919b1b, 0x4fc5c080, 0xa220dc61, 0x694b775a, 0x161a121c, + 0xaba93e2, 0xe52aa0c0, 0x43e0223c, 0x1d171b12, 0xb0d090e, 0xadc78bf2, + 0xb9a8b62d, 0xc8a91e14, 0x8519f157, 0x4c0775af, 0xbbdd99ee, 0xfd607fa3, + 0x9f2601f7, 0xbcf5725c, 0xc53b6644, 0x347efb5b, 0x7629438b, 0xdcc623cb, + 0x68fcedb6, 0x63f1e4b8, 0xcadc31d7, 0x10856342, 0x40229713, 0x2011c684, + 0x7d244a85, 0xf83dbbd2, 0x1132f9ae, 0x6da129c7, 0x4b2f9e1d, 0xf330b2dc, + 0xec52860d, 0xd0e3c177, 0x6c16b32b, 0x99b970a9, 0xfa489411, 0x2264e947, + 0xc48cfca8, 0x1a3ff0a0, 0xd82c7d56, 0xef903322, 0xc74e4987, 0xc1d138d9, + 0xfea2ca8c, 0x360bd498, 0xcf81f5a6, 0x28de7aa5, 0x268eb7da, 0xa4bfad3f, + 0xe49d3a2c, 0xd927850, 0x9bcc5f6a, 0x62467e54, 0xc2138df6, 0xe8b8d890, + 0x5ef7392e, 0xf5afc382, 0xbe805d9f, 0x7c93d069, 0xa92dd56f, 0xb31225cf, + 0x3b99acc8, 0xa77d1810, 0x6e639ce8, 0x7bbb3bdb, 0x97826cd, 0xf418596e, + 0x1b79aec, 0xa89a4f83, 0x656e95e6, 0x7ee6ffaa, 0x8cfbc21, 0xe6e815ef, + 0xd99be7ba, 0xce366f4a, 0xd4099fea, 0xd67cb029, 0xafb2a431, 0x31233f2a, + 0x3094a5c6, 0xc066a235, 0x37bc4e74, 0xa6ca82fc, 0xb0d090e0, 0x15d8a733, + 0x4a9804f1, 0xf7daec41, 0xe50cd7f, 0x2ff69117, 0x8dd64d76, 0x4db0ef43, + 0x544daacc, 0xdf0496e4, 0xe3b5d19e, 0x1b886a4c, 0xb81f2cc1, 0x7f516546, + 0x4ea5e9d, 0x5d358c01, 0x737487fa, 0x2e410bfb, 0x5a1d67b3, 0x52d2db92, + 0x335610e9, 0x1347d66d, 0x8c61d79a, 0x7a0ca137, 0x8e14f859, 0x893c13eb, + 0xee27a9ce, 0x35c961b7, 0xede51ce1, 0x3cb1477a, 0x59dfd29c, 0x3f73f255, + 0x79ce1418, 0xbf37c773, 0xeacdf753, 0x5baafd5f, 0x146f3ddf, 0x86db4478, + 0x81f3afca, 0x3ec468b9, 0x2c342438, 0x5f40a3c2, 0x72c31d16, 0xc25e2bc, + 0x8b493c28, 0x41950dff, 0x7101a839, 0xdeb30c08, 0x9ce4b4d8, 0x90c15664, + 0x6184cb7b, 0x70b632d5, 0x745c6c48, 0x4257b8d0} + +type AES struct { + Nk int + Nr int + mode int + fkey [60]uint32 + rkey [60]uint32 + f [16]byte +} + +/* Rotates 32-bit word left by 1, 2 or 3 byte */ + +func aes_ROTL8(x uint32) uint32 { + return (((x) << 8) | ((x) >> 24)) +} + +func aes_ROTL16(x uint32) uint32 { + return (((x) << 16) | ((x) >> 16)) +} + +func aes_ROTL24(x uint32) uint32 { + return (((x) << 24) | ((x) >> 8)) +} + +func aes_pack(b [4]byte) uint32 { /* pack bytes into a 32-bit Word */ + return ((uint32(b[3]) & 0xff) << 24) | ((uint32(b[2]) & 0xff) << 16) | ((uint32(b[1]) & 0xff) << 8) | (uint32(b[0]) & 0xff) +} + +func aes_unpack(a uint32) [4]byte { /* unpack bytes from a word */ + var b = [4]byte{byte(a & 0xff), byte((a >> 8) & 0xff), byte((a >> 16) & 0xff), byte((a >> 24) & 0xff)} + return b +} + +func aes_bmul(x byte, y byte) byte { /* x.y= AntiLog(Log(x) + Log(y)) */ + + ix := int(x) & 0xff + iy := int(y) & 0xff + lx := int(aes_ltab[ix]) & 0xff + ly := int(aes_ltab[iy]) & 0xff + + if x != 0 && y != 0 { + return aes_ptab[(lx+ly)%255] + } else { + return byte(0) + } +} + +func aes_SubByte(a uint32) uint32 { + b := aes_unpack(a) + b[0] = aes_fbsub[int(b[0])] + b[1] = aes_fbsub[int(b[1])] + b[2] = aes_fbsub[int(b[2])] + b[3] = aes_fbsub[int(b[3])] + return aes_pack(b) +} + +func aes_product(x uint32, y uint32) byte { /* dot product of two 4-byte arrays */ + xb := aes_unpack(x) + yb := aes_unpack(y) + + return (aes_bmul(xb[0], yb[0]) ^ aes_bmul(xb[1], yb[1]) ^ aes_bmul(xb[2], yb[2]) ^ aes_bmul(xb[3], yb[3])) +} + +func aes_InvMixCol(x uint32) uint32 { /* matrix Multiplication */ + var b [4]byte + m := aes_pack(aes_InCo) + b[3] = aes_product(m, x) + m = aes_ROTL24(m) + b[2] = aes_product(m, x) + m = aes_ROTL24(m) + b[1] = aes_product(m, x) + m = aes_ROTL24(m) + b[0] = aes_product(m, x) + var y = aes_pack(b) + return y +} + +func aes_increment(f []byte) { + for i := 0; i < 16; i++ { + f[i]++ + if f[i] != 0 { + break + } + } +} + +/* reset cipher */ +func (A *AES) Reset(m int, iv []byte) { /* reset mode, or reset iv */ + A.mode = m + for i := 0; i < 16; i++ { + A.f[i] = 0 + } + if (A.mode != AES_ECB) && (iv != nil) { + for i := 0; i < 16; i++ { + A.f[i] = iv[i] + } + } +} + +func (A *AES) Init(m int, nk int, key []byte, iv []byte) bool { + /* Key Scheduler. Create expanded encryption key */ + var CipherKey [8]uint32 + var b [4]byte + nk /= 4 + if nk != 4 && nk != 6 && nk != 8 { + return false + } + nr := 6 + nk + A.Nk = nk + A.Nr = nr + A.Reset(m, iv) + N := 4 * (nr + 1) + + j := 0 + for i := 0; i < nk; i++ { + for k := 0; k < 4; k++ { + b[k] = key[j+k] + } + CipherKey[i] = aes_pack(b) + j += 4 + } + for i := 0; i < nk; i++ { + A.fkey[i] = CipherKey[i] + } + + j = nk + for k := 0; j < N; k++ { + A.fkey[j] = A.fkey[j-nk] ^ aes_SubByte(aes_ROTL24(A.fkey[j-1])) ^ uint32(aes_rco[k]) + if nk <= 6 { + for i := 1; i < nk && (i+j) < N; i++ { + A.fkey[i+j] = A.fkey[i+j-nk] ^ A.fkey[i+j-1] + } + } else { + i := 0 + for i = 1; i < 4 && (i+j) < N; i++ { + A.fkey[i+j] = A.fkey[i+j-nk] ^ A.fkey[i+j-1] + } + if (j + 4) < N { + A.fkey[j+4] = A.fkey[j+4-nk] ^ aes_SubByte(A.fkey[j+3]) + } + for i = 5; i < nk && (i+j) < N; i++ { + A.fkey[i+j] = A.fkey[i+j-nk] ^ A.fkey[i+j-1] + } + } + j += nk + + } + + /* now for the expanded decrypt key in reverse order */ + + for j := 0; j < 4; j++ { + A.rkey[j+N-4] = A.fkey[j] + } + for i := 4; i < N-4; i += 4 { + k := N - 4 - i + for j := 0; j < 4; j++ { + A.rkey[k+j] = aes_InvMixCol(A.fkey[i+j]) + } + } + for j := N - 4; j < N; j++ { + A.rkey[j-N+4] = A.fkey[j] + } + return true +} + +func NewAES() *AES { + var A = new(AES) + return A +} + +func (A *AES) Getreg() [16]byte { + var ir [16]byte + for i := 0; i < 16; i++ { + ir[i] = A.f[i] + } + return ir +} + +/* Encrypt a single block */ +func (A *AES) ecb_encrypt(buff []byte) { + var b [4]byte + var p [4]uint32 + var q [4]uint32 + + j := 0 + for i := 0; i < 4; i++ { + for k := 0; k < 4; k++ { + b[k] = buff[j+k] + } + p[i] = aes_pack(b) + p[i] ^= A.fkey[i] + j += 4 + } + + k := 4 + + /* State alternates between p and q */ + for i := 1; i < A.Nr; i++ { + q[0] = A.fkey[k] ^ aes_ftable[int(p[0]&0xff)] ^ aes_ROTL8(aes_ftable[int((p[1]>>8)&0xff)]) ^ aes_ROTL16(aes_ftable[int((p[2]>>16)&0xff)]) ^ aes_ROTL24(aes_ftable[int((p[3]>>24)&0xff)]) + + q[1] = A.fkey[k+1] ^ aes_ftable[int(p[1]&0xff)] ^ aes_ROTL8(aes_ftable[int((p[2]>>8)&0xff)]) ^ aes_ROTL16(aes_ftable[int((p[3]>>16)&0xff)]) ^ aes_ROTL24(aes_ftable[int((p[0]>>24)&0xff)]) + + q[2] = A.fkey[k+2] ^ aes_ftable[int(p[2]&0xff)] ^ aes_ROTL8(aes_ftable[int((p[3]>>8)&0xff)]) ^ aes_ROTL16(aes_ftable[int((p[0]>>16)&0xff)]) ^ aes_ROTL24(aes_ftable[int((p[1]>>24)&0xff)]) + + q[3] = A.fkey[k+3] ^ aes_ftable[int(p[3]&0xff)] ^ aes_ROTL8(aes_ftable[int((p[0]>>8)&0xff)]) ^ aes_ROTL16(aes_ftable[int((p[1]>>16)&0xff)]) ^ aes_ROTL24(aes_ftable[int((p[2]>>24)&0xff)]) + + k += 4 + for j = 0; j < 4; j++ { + t := p[j] + p[j] = q[j] + q[j] = t + } + } + + /* Last Round */ + + q[0] = A.fkey[k] ^ uint32(aes_fbsub[int(p[0]&0xff)]) ^ aes_ROTL8(uint32(aes_fbsub[int((p[1]>>8)&0xff)])) ^ aes_ROTL16(uint32(aes_fbsub[int((p[2]>>16)&0xff)])) ^ aes_ROTL24(uint32(aes_fbsub[int((p[3]>>24)&0xff)])) + + q[1] = A.fkey[k+1] ^ uint32(aes_fbsub[int(p[1]&0xff)]) ^ aes_ROTL8(uint32(aes_fbsub[int((p[2]>>8)&0xff)])) ^ aes_ROTL16(uint32(aes_fbsub[int((p[3]>>16)&0xff)])) ^ aes_ROTL24(uint32(aes_fbsub[int((p[0]>>24)&0xff)])) + + q[2] = A.fkey[k+2] ^ uint32(aes_fbsub[int(p[2]&0xff)]) ^ aes_ROTL8(uint32(aes_fbsub[int((p[3]>>8)&0xff)])) ^ aes_ROTL16(uint32(aes_fbsub[int((p[0]>>16)&0xff)])) ^ aes_ROTL24(uint32(aes_fbsub[int((p[1]>>24)&0xff)])) + + q[3] = A.fkey[k+3] ^ uint32(aes_fbsub[int(p[3]&0xff)]) ^ aes_ROTL8(uint32(aes_fbsub[int((p[0]>>8)&0xff)])) ^ aes_ROTL16(uint32(aes_fbsub[int((p[1]>>16)&0xff)])) ^ aes_ROTL24(uint32(aes_fbsub[int((p[2]>>24)&0xff)])) + + j = 0 + for i := 0; i < 4; i++ { + b = aes_unpack(q[i]) + for k = 0; k < 4; k++ { + buff[j+k] = b[k] + } + j += 4 + } +} + +/* Decrypt a single block */ +func (A *AES) ecb_decrypt(buff []byte) { + var b [4]byte + var p [4]uint32 + var q [4]uint32 + + j := 0 + for i := 0; i < 4; i++ { + for k := 0; k < 4; k++ { + b[k] = buff[j+k] + } + p[i] = aes_pack(b) + p[i] ^= A.rkey[i] + j += 4 + } + + k := 4 + + /* State alternates between p and q */ + for i := 1; i < A.Nr; i++ { + + q[0] = A.rkey[k] ^ aes_rtable[int(p[0]&0xff)] ^ aes_ROTL8(aes_rtable[int((p[3]>>8)&0xff)]) ^ aes_ROTL16(aes_rtable[int((p[2]>>16)&0xff)]) ^ aes_ROTL24(aes_rtable[int((p[1]>>24)&0xff)]) + + q[1] = A.rkey[k+1] ^ aes_rtable[int(p[1]&0xff)] ^ aes_ROTL8(aes_rtable[int((p[0]>>8)&0xff)]) ^ aes_ROTL16(aes_rtable[int((p[3]>>16)&0xff)]) ^ aes_ROTL24(aes_rtable[int((p[2]>>24)&0xff)]) + + q[2] = A.rkey[k+2] ^ aes_rtable[int(p[2]&0xff)] ^ aes_ROTL8(aes_rtable[int((p[1]>>8)&0xff)]) ^ aes_ROTL16(aes_rtable[int((p[0]>>16)&0xff)]) ^ aes_ROTL24(aes_rtable[int((p[3]>>24)&0xff)]) + + q[3] = A.rkey[k+3] ^ aes_rtable[int(p[3]&0xff)] ^ aes_ROTL8(aes_rtable[int((p[2]>>8)&0xff)]) ^ aes_ROTL16(aes_rtable[int((p[1]>>16)&0xff)]) ^ aes_ROTL24(aes_rtable[int((p[0]>>24)&0xff)]) + + k += 4 + for j := 0; j < 4; j++ { + t := p[j] + p[j] = q[j] + q[j] = t + } + } + + /* Last Round */ + + q[0] = A.rkey[k] ^ uint32(aes_rbsub[int(p[0]&0xff)]) ^ aes_ROTL8(uint32(aes_rbsub[int((p[3]>>8)&0xff)])) ^ aes_ROTL16(uint32(aes_rbsub[int((p[2]>>16)&0xff)])) ^ aes_ROTL24(uint32(aes_rbsub[int((p[1]>>24)&0xff)])) + + q[1] = A.rkey[k+1] ^ uint32(aes_rbsub[int(p[1]&0xff)]) ^ aes_ROTL8(uint32(aes_rbsub[int((p[0]>>8)&0xff)])) ^ aes_ROTL16(uint32(aes_rbsub[int((p[3]>>16)&0xff)])) ^ aes_ROTL24(uint32(aes_rbsub[int((p[2]>>24)&0xff)])) + + q[2] = A.rkey[k+2] ^ uint32(aes_rbsub[int(p[2]&0xff)]) ^ aes_ROTL8(uint32(aes_rbsub[int((p[1]>>8)&0xff)])) ^ aes_ROTL16(uint32(aes_rbsub[int((p[0]>>16)&0xff)])) ^ aes_ROTL24(uint32(aes_rbsub[int((p[3]>>24)&0xff)])) + + q[3] = A.rkey[k+3] ^ uint32(aes_rbsub[int((p[3])&0xff)]) ^ aes_ROTL8(uint32(aes_rbsub[int((p[2]>>8)&0xff)])) ^ aes_ROTL16(uint32(aes_rbsub[int((p[1]>>16)&0xff)])) ^ aes_ROTL24(uint32(aes_rbsub[int((p[0]>>24)&0xff)])) + + j = 0 + for i := 0; i < 4; i++ { + b = aes_unpack(q[i]) + for k := 0; k < 4; k++ { + buff[j+k] = b[k] + } + j += 4 + } +} + +/* Encrypt using selected mode of operation */ +func (A *AES) Encrypt(buff []byte) uint32 { + var st [16]byte + + // Supported Modes of Operation + + var fell_off uint32 = 0 + switch A.mode { + case AES_ECB: + A.ecb_encrypt(buff) + return 0 + case AES_CBC: + for j := 0; j < 16; j++ { + buff[j] ^= A.f[j] + } + A.ecb_encrypt(buff) + for j := 0; j < 16; j++ { + A.f[j] = buff[j] + } + return 0 + + case AES_CFB1: + fallthrough + case AES_CFB2: + fallthrough + case AES_CFB4: + bytes := A.mode - AES_CFB1 + 1 + for j := 0; j < bytes; j++ { + fell_off = (fell_off << 8) | uint32(A.f[j]) + } + for j := 0; j < 16; j++ { + st[j] = A.f[j] + } + for j := bytes; j < 16; j++ { + A.f[j-bytes] = A.f[j] + } + A.ecb_encrypt(st[:]) + for j := 0; j < bytes; j++ { + buff[j] ^= st[j] + A.f[16-bytes+j] = buff[j] + } + return fell_off + + case AES_OFB1: + fallthrough + case AES_OFB2: + fallthrough + case AES_OFB4: + fallthrough + case AES_OFB8: + fallthrough + case AES_OFB16: + + bytes := A.mode - AES_OFB1 + 1 + A.ecb_encrypt(A.f[:]) + for j := 0; j < bytes; j++ { + buff[j] ^= A.f[j] + } + return 0 + + case AES_CTR1: + fallthrough + case AES_CTR2: + fallthrough + case AES_CTR4: + fallthrough + case AES_CTR8: + fallthrough + case AES_CTR16: + bytes := A.mode - AES_CTR1 + 1 + for j := 0; j < 16; j++ { + st[j] = A.f[j] + } + A.ecb_encrypt(st[:]) + for j := 0; j < bytes; j++ { + buff[j] ^= st[j] + } + aes_increment(A.f[:]) + return 0 + + default: + return 0 + } +} + +/* Decrypt using selected mode of operation */ +func (A *AES) Decrypt(buff []byte) uint32 { + + var st [16]byte + + // Supported Modes of Operation + + var fell_off uint32 = 0 + switch A.mode { + case AES_ECB: + A.ecb_decrypt(buff) + return 0 + case AES_CBC: + for j := 0; j < 16; j++ { + st[j] = A.f[j] + A.f[j] = buff[j] + } + A.ecb_decrypt(buff) + for j := 0; j < 16; j++ { + buff[j] ^= st[j] + st[j] = 0 + } + return 0 + case AES_CFB1: + fallthrough + case AES_CFB2: + fallthrough + case AES_CFB4: + bytes := A.mode - AES_CFB1 + 1 + for j := 0; j < bytes; j++ { + fell_off = (fell_off << 8) | uint32(A.f[j]) + } + for j := 0; j < 16; j++ { + st[j] = A.f[j] + } + for j := bytes; j < 16; j++ { + A.f[j-bytes] = A.f[j] + } + A.ecb_encrypt(st[:]) + for j := 0; j < bytes; j++ { + A.f[16-bytes+j] = buff[j] + buff[j] ^= st[j] + } + return fell_off + case AES_OFB1: + fallthrough + case AES_OFB2: + fallthrough + case AES_OFB4: + fallthrough + case AES_OFB8: + fallthrough + case AES_OFB16: + bytes := A.mode - AES_OFB1 + 1 + A.ecb_encrypt(A.f[:]) + for j := 0; j < bytes; j++ { + buff[j] ^= A.f[j] + } + return 0 + + case AES_CTR1: + fallthrough + case AES_CTR2: + fallthrough + case AES_CTR4: + fallthrough + case AES_CTR8: + fallthrough + case AES_CTR16: + bytes := A.mode - AES_CTR1 + 1 + for j := 0; j < 16; j++ { + st[j] = A.f[j] + } + A.ecb_encrypt(st[:]) + for j := 0; j < bytes; j++ { + buff[j] ^= st[j] + } + aes_increment(A.f[:]) + return 0 + + default: + return 0 + } +} + +/* Clean up and delete left-overs */ +func (A *AES) End() { // clean up + for i := 0; i < 4*(A.Nr+1); i++ { + A.fkey[i] = 0 + A.rkey[i] = 0 + } + for i := 0; i < 16; i++ { + A.f[i] = 0 + } +} + +/* AES encryption/decryption. Encrypt byte array M using key K and returns ciphertext */ +func AES_CBC_IV0_ENCRYPT(K []byte, M []byte) []byte { /* AES CBC encryption, with Null IV and key K */ + /* Input is from an octet string M, output is to an octet string C */ + /* Input is padded as necessary to make up a full final block */ + a := NewAES() + fin := false + + var buff [16]byte + var C []byte + + a.Init(AES_CBC, len(K), K, nil) + + ipt := 0 //opt:=0 + var i int + for true { + for i = 0; i < 16; i++ { + if ipt < len(M) { + buff[i] = M[ipt] + ipt++ + } else { + fin = true + break + } + } + if fin { + break + } + a.Encrypt(buff[:]) + for i = 0; i < 16; i++ { + C = append(C, buff[i]) + } + } + + /* last block, filled up to i-th index */ + + padlen := 16 - i + for j := i; j < 16; j++ { + buff[j] = byte(padlen) + } + + a.Encrypt(buff[:]) + + for i = 0; i < 16; i++ { + C = append(C, buff[i]) + } + a.End() + return C +} + +/* returns plaintext if all consistent, else returns null string */ +func AES_CBC_IV0_DECRYPT(K []byte, C []byte) []byte { /* padding is removed */ + a := NewAES() + var buff [16]byte + var MM []byte + var M []byte + + var i int + ipt := 0 + opt := 0 + + a.Init(AES_CBC, len(K), K, nil) + + if len(C) == 0 { + return nil + } + ch := C[ipt] + ipt++ + + fin := false + + for true { + for i = 0; i < 16; i++ { + buff[i] = ch + if ipt >= len(C) { + fin = true + break + } else { + ch = C[ipt] + ipt++ + } + } + a.Decrypt(buff[:]) + if fin { + break + } + for i = 0; i < 16; i++ { + MM = append(MM, buff[i]) + opt++ + } + } + + a.End() + bad := false + padlen := int(buff[15]) + if i != 15 || padlen < 1 || padlen > 16 { + bad = true + } + if padlen >= 2 && padlen <= 16 { + for i = 16 - padlen; i < 16; i++ { + if buff[i] != byte(padlen) { + bad = true + } + } + } + + if !bad { + for i = 0; i < 16-padlen; i++ { + MM = append(MM, buff[i]) + opt++ + } + } + + if bad { + return nil + } + + for i = 0; i < opt; i++ { + M = append(M, MM[i]) + } + + return M +} + +/* +func main() { + var key [32]byte + var block [16]byte + var iv [16]byte + + for i:=0;i<32;i++ {key[i]=0} + key[0]=1 + for i:=0;i<16;i++ {iv[i]=byte(i)} + for i:=0;i<16;i++ {block[i]=byte(i)} + + a:=NewAES() + + a.Init(AES_CTR16,32,key[:],iv[:]) + fmt.Printf("Plain= \n") + for i:=0;i<16;i++ {fmt.Printf("%02X ", block[i]&0xff)} + fmt.Printf("\n") + + a.Encrypt(block[:]) + + fmt.Printf("Encrypt= \n") + for i:=0;i<16;i++ {fmt.Printf("%02X ", block[i]&0xff)} + fmt.Printf("\n") + + a.Reset(AES_CTR16,iv[:]) + a.Decrypt(block[:]) + + fmt.Printf("Decrypt= \n") + for i:=0;i<16;i++ {fmt.Printf("%02X ", block[i]&0xff)} + fmt.Printf("\n") + + a.End(); +} +*/ diff --git a/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/ARCH.go b/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/ARCH.go new file mode 100644 index 00000000000..ac4c60d35d7 --- /dev/null +++ b/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/ARCH.go @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2012-2020 MIRACL UK Ltd. + * + * This file is part of MIRACL Core + * (see https://github.com/miracl/core). + * + * 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. + */ + +/* core BIG number class */ + +package FP256BN + +type Chunk int64 + +const CHUNK int = 64 /* Set word size */ diff --git a/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/BIG.go b/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/BIG.go new file mode 100644 index 00000000000..b81fadc84c6 --- /dev/null +++ b/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/BIG.go @@ -0,0 +1,938 @@ +/* + * Copyright (c) 2012-2020 MIRACL UK Ltd. + * + * This file is part of MIRACL Core + * (see https://github.com/miracl/core). + * + * 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. + */ + +/* core BIG number class */ + +package FP256BN + +import "strconv" +import "math/bits" +import "github.com/hyperledger/fabric-amcl/core" + + + +type BIG struct { + w [NLEN]Chunk +} + +type DBIG struct { + w [2 * NLEN]Chunk +} + +/***************** 64-bit specific code ****************/ + +/* First the 32/64-bit dependent BIG code */ +/* Note that because of the lack of a 128-bit integer, 32 and 64-bit code needs to be done differently */ + +/* return a*b as DBIG */ +func mul(a *BIG, b *BIG) *DBIG { + c := NewDBIG() + carry := Chunk(0) + + for i := 0; i < NLEN; i++ { + carry = 0 + for j := 0; j < NLEN; j++ { + carry, c.w[i+j] = muladd(a.w[i], b.w[j], carry, c.w[i+j]) + } + c.w[NLEN+i] = carry + } + + return c +} + +/* return a^2 as DBIG */ +func sqr(a *BIG) *DBIG { + c := NewDBIG() + carry := Chunk(0) + + for i := 0; i < NLEN; i++ { + carry = 0 + for j := i + 1; j < NLEN; j++ { +//if a.w[i]<0 {fmt.Printf("Negative m i in sqr\n")} +//if a.w[j]<0 {fmt.Printf("Negative m j in sqr\n")} + carry, c.w[i+j] = muladd(2*a.w[i], a.w[j], carry, c.w[i+j]) + } + c.w[NLEN+i] = carry + } + + for i := 0; i < NLEN; i++ { +//if a.w[i]<0 {fmt.Printf("Negative m s in sqr\n")} + top, bot := muladd(a.w[i], a.w[i], 0, c.w[2*i]) + + c.w[2*i] = bot + c.w[2*i+1] += top + } + c.norm() + return c +} + +func monty(md *BIG, mc Chunk, d *DBIG) *BIG { + carry := Chunk(0) + m := Chunk(0) + for i := 0; i < NLEN; i++ { + if mc == -1 { + m = (-d.w[i]) & BMASK + } else { + if mc == 1 { + m = d.w[i] + } else { + m = (mc * d.w[i]) & BMASK + } + } + + carry = 0 + for j := 0; j < NLEN; j++ { + carry, d.w[i+j] = muladd(m, md.w[j], carry, d.w[i+j]) +//if m<0 {fmt.Printf("Negative m in monty\n")} +//if md.w[j]<0 {fmt.Printf("Negative m in monty\n")} + } + d.w[NLEN+i] += carry + } + + b := NewBIG() + for i := 0; i < NLEN; i++ { + b.w[i] = d.w[NLEN+i] + } + b.norm() + return b +} + +/* set this[i]+=x*y+c, and return high part */ +func muladd(a Chunk, b Chunk, c Chunk, r Chunk) (Chunk, Chunk) { + + tp,bt := bits.Mul64(uint64(a),uint64(b)) // use math/bits intrinsic + bot := Chunk(bt&uint64(BMASK)) + top := Chunk((tp << (64-BASEBITS)) | (bt >> BASEBITS)) + bot += c; bot += r + carry := bot>>BASEBITS + bot &= BMASK + top+=carry + return top, bot + +} + +/************************************************************/ + +func (r *BIG) get(i int) Chunk { + return r.w[i] +} + +func (r *BIG) set(i int, x Chunk) { + r.w[i] = x +} + +func (r *BIG) xortop(x Chunk) { + r.w[NLEN-1] ^= x +} + +/* normalise BIG - force all digits < 2^BASEBITS */ +func (r *BIG) norm() Chunk { + carry := Chunk(0) + for i := 0; i < NLEN-1; i++ { + d := r.w[i] + carry + r.w[i] = d & BMASK + carry = d >> BASEBITS + } + r.w[NLEN-1] = (r.w[NLEN-1] + carry) + return (r.w[NLEN-1] >> ((8 * MODBYTES) % BASEBITS)) +} + +/* Shift right by less than a word */ +func (r *BIG) fshr(k uint) int { + w := r.w[0] & ((Chunk(1) << k) - 1) /* shifted out part */ + for i := 0; i < NLEN-1; i++ { + r.w[i] = (r.w[i] >> k) | ((r.w[i+1] << (BASEBITS - k)) & BMASK) + } + r.w[NLEN-1] = r.w[NLEN-1] >> k + return int(w) +} + +/* Shift right by less than a word */ +func (r *BIG) fshl(k uint) int { + r.w[NLEN-1] = (r.w[NLEN-1] << k) | (r.w[NLEN-2] >> (BASEBITS - k)) + for i := NLEN - 2; i > 0; i-- { + r.w[i] = ((r.w[i] << k) & BMASK) | (r.w[i-1] >> (BASEBITS - k)) + } + r.w[0] = (r.w[0] << k) & BMASK + return int(r.w[NLEN-1] >> ((8 * MODBYTES) % BASEBITS)) /* return excess - only used in ff.c */ +} + +func NewBIG() *BIG { + b := new(BIG) + for i := 0; i < NLEN; i++ { + b.w[i] = 0 + } + return b +} + +func NewBIGints(x [NLEN]Chunk) *BIG { + b := new(BIG) + for i := 0; i < NLEN; i++ { + b.w[i] = x[i] + } + return b +} + +func NewBIGint(x int) *BIG { + b := new(BIG) + b.w[0] = Chunk(x) + for i := 1; i < NLEN; i++ { + b.w[i] = 0 + } + return b +} + +func NewBIGcopy(x *BIG) *BIG { + b := new(BIG) + for i := 0; i < NLEN; i++ { + b.w[i] = x.w[i] + } + return b +} + +func NewBIGdcopy(x *DBIG) *BIG { + b := new(BIG) + for i := 0; i < NLEN; i++ { + b.w[i] = x.w[i] + } + return b +} + +/* test for zero */ +func (r *BIG) iszilch() bool { + d:=Chunk(0) + for i := 0; i < NLEN; i++ { + d|=r.w[i] + } + return (1 & ((d-1)>>BASEBITS)) != 0 +} + +/* set to zero */ +func (r *BIG) zero() { + for i := 0; i < NLEN; i++ { + r.w[i] = 0 + } +} + +/* Test for equal to one */ +func (r *BIG) isunity() bool { + d:=Chunk(0) + for i := 1; i < NLEN; i++ { + d|=r.w[i] + } + return (1 & ((d-1)>>BASEBITS) & (((r.w[0]^1)-1)>>BASEBITS)) != 0 +} + +/* set to one */ +func (r *BIG) one() { + r.w[0] = 1 + for i := 1; i < NLEN; i++ { + r.w[i] = 0 + } +} + +/* Copy from another BIG */ +func (r *BIG) copy(x *BIG) { + for i := 0; i < NLEN; i++ { + r.w[i] = x.w[i] + } +} + +/* Copy from another DBIG */ +func (r *BIG) dcopy(x *DBIG) { + for i := 0; i < NLEN; i++ { + r.w[i] = x.w[i] + } +} + +/* Conditional swap of two bigs depending on d using XOR - no branches */ +func (r *BIG) cswap(b *BIG, d int) { + c := Chunk(d) + c = ^(c - 1) + + for i := 0; i < NLEN; i++ { + t := c & (r.w[i] ^ b.w[i]) + r.w[i] ^= t + b.w[i] ^= t + } +} + +func (r *BIG) cmove(g *BIG, d int) { + b := Chunk(-d) + + for i := 0; i < NLEN; i++ { + r.w[i] ^= (r.w[i] ^ g.w[i]) & b + } +} + +/* general shift right */ +func (r *BIG) shr(k uint) { + n := (k % BASEBITS) + m := int(k / BASEBITS) + for i := 0; i < NLEN-m-1; i++ { + r.w[i] = (r.w[m+i] >> n) | ((r.w[m+i+1] << (BASEBITS - n)) & BMASK) + } + r.w[NLEN-m-1] = r.w[NLEN-1] >> n + for i := NLEN - m; i < NLEN; i++ { + r.w[i] = 0 + } +} + +/* general shift left */ +func (r *BIG) shl(k uint) { + n := k % BASEBITS + m := int(k / BASEBITS) + + r.w[NLEN-1] = (r.w[NLEN-1-m] << n) + if NLEN >= m+2 { + r.w[NLEN-1] |= (r.w[NLEN-m-2] >> (BASEBITS - n)) + } + for i := NLEN - 2; i > m; i-- { + r.w[i] = ((r.w[i-m] << n) & BMASK) | (r.w[i-m-1] >> (BASEBITS - n)) + } + r.w[m] = (r.w[0] << n) & BMASK + for i := 0; i < m; i++ { + r.w[i] = 0 + } +} + +/* return number of bits */ +func (r *BIG) nbits() int { + t := NewBIGcopy(r) + k := NLEN - 1 + t.norm() + for k >= 0 && t.w[k] == 0 { + k-- + } + if k < 0 { + return 0 + } + bts := int(BASEBITS) * k + c := t.w[k] + for c != 0 { + c /= 2 + bts++ + } + return bts +} + +func (r *BIG) Nbits() int { + return r.nbits() +} + +/* Convert to Hex String */ +func (r *BIG) ToString() string { + s := "" + len := r.nbits() + + if len%4 == 0 { + len /= 4 + } else { + len /= 4 + len++ + + } + MB := int(MODBYTES * 2) + if len < MB { + len = MB + } + + for i := len - 1; i >= 0; i-- { + b := NewBIGcopy(r) + + b.shr(uint(i * 4)) + s += strconv.FormatInt(int64(b.w[0]&15), 16) + } + return s +} + +func (r *BIG) add(x *BIG) { + for i := 0; i < NLEN; i++ { + r.w[i] = r.w[i] + x.w[i] + } +} + +func (r *BIG) or(x *BIG) { + for i := 0; i < NLEN; i++ { + r.w[i] = r.w[i] | x.w[i] + } +} + +/* return this+x */ +func (r *BIG) Plus(x *BIG) *BIG { + s := new(BIG) + for i := 0; i < NLEN; i++ { + s.w[i] = r.w[i] + x.w[i] + } + s.norm() + return s +} + +/* this+=x, where x is int */ +func (r *BIG) inc(x int) { + r.norm() + r.w[0] += Chunk(x) +} + +/* this*=c and catch overflow in DBIG */ +func (r *BIG) pxmul(c int) *DBIG { + m := NewDBIG() + carry := Chunk(0) + for j := 0; j < NLEN; j++ { + carry, m.w[j] = muladd(r.w[j], Chunk(c), carry, m.w[j]) +//if c<0 {fmt.Printf("Negative c in pxmul\n")} +//if r.w[j]<0 {fmt.Printf("Negative c in pxmul\n")} + } + m.w[NLEN] = carry + return m +} + +/* return this-x */ +func (r *BIG) Minus(x *BIG) *BIG { + d := new(BIG) + for i := 0; i < NLEN; i++ { + d.w[i] = r.w[i] - x.w[i] + } + return d +} + +/* this-=x */ +func (r *BIG) sub(x *BIG) { + for i := 0; i < NLEN; i++ { + r.w[i] = r.w[i] - x.w[i] + } +} + +/* reverse subtract this=x-this */ +func (r *BIG) rsub(x *BIG) { + for i := 0; i < NLEN; i++ { + r.w[i] = x.w[i] - r.w[i] + } +} + +/* this-=x, where x is int */ +func (r *BIG) dec(x int) { + r.norm() + r.w[0] -= Chunk(x) +} + +/* this*=x, where x is small intNEXCESS */ +func (r *BIG) pmul(c int) Chunk { + carry := Chunk(0) + // r.norm(); + for i := 0; i < NLEN; i++ { + ak := r.w[i] + r.w[i] = 0 + carry, r.w[i] = muladd(ak, Chunk(c), carry, r.w[i]) +//if c<0 {fmt.Printf("Negative c in pmul\n")} +//if ak<0 {fmt.Printf("Negative c in pmul\n")} + } + return carry +} + +/* convert this BIG to byte array */ +func (r *BIG) tobytearray(b []byte, n int) { + //r.norm(); + c := NewBIGcopy(r) + c.norm() + + for i := int(MODBYTES) - 1; i >= 0; i-- { + b[i+n] = byte(c.w[0]) + c.fshr(8) + } +} + +/* convert from byte array to BIG */ +func frombytearray(b []byte, n int) *BIG { + m := NewBIG() + l := len(b) + for i := 0; i < int(MODBYTES); i++ { + m.fshl(8) + if i < l { + m.w[0] += Chunk(int(b[i+n] & 0xff)) + } else { + m.w[0] += Chunk(int(0 & 0xff)) + } + } + return m +} + +func (r *BIG) ToBytes(b []byte) { + r.tobytearray(b, 0) +} + +func FromBytes(b []byte) *BIG { + return frombytearray(b, 0) +} + +/* divide by 3 */ +func (r *BIG) div3() int { + carry := Chunk(0) + r.norm() + base := (Chunk(1) << BASEBITS) + for i := NLEN - 1; i >= 0; i-- { + ak := (carry*base + r.w[i]) + r.w[i] = ak / 3 + carry = ak % 3 + } + return int(carry) +} + +/* return a*b where result fits in a BIG */ +func smul(a *BIG, b *BIG) *BIG { + carry := Chunk(0) + c := NewBIG() + for i := 0; i < NLEN; i++ { + carry = 0 + for j := 0; j < NLEN; j++ { + if i+j < NLEN { + carry, c.w[i+j] = muladd(a.w[i], b.w[j], carry, c.w[i+j]) + } + } + } + return c +} + +/* Compare a and b, return 0 if a==b, -1 if ab. Inputs must be normalised */ +func Comp(a *BIG, b *BIG) int { + gt:=Chunk(0) + eq:=Chunk(1) + for i := NLEN - 1; i >= 0; i-- { + gt |= ((b.w[i]-a.w[i]) >> BASEBITS) & eq + eq &= ((b.w[i]^a.w[i])-1) >> BASEBITS + } + return int(gt+gt+eq-1) +} + +/* return parity */ +func (r *BIG) parity() int { + return int(r.w[0] % 2) +} + +/* return n-th bit */ +func (r *BIG) bit(n int) int { + if (r.w[n/int(BASEBITS)] & (Chunk(1) << (uint(n) % BASEBITS))) > 0 { + return 1 + } + return 0 +} + +/* return n last bits */ +func (r *BIG) lastbits(n int) int { + msk := (1 << uint(n)) - 1 + r.norm() + return (int(r.w[0])) & msk +} + +/* set x = x mod 2^m */ +func (r *BIG) mod2m(m uint) { + wd := int(m / BASEBITS) + bt := m % BASEBITS + msk := (Chunk(1) << bt) - 1 + r.w[wd] &= msk + for i := wd + 1; i < NLEN; i++ { + r.w[i] = 0 + } +} + +/* a=1/a mod 2^256. This is very fast! */ +func (r *BIG) invmod2m() { + U := NewBIG() + b := NewBIG() + c := NewBIG() + + U.inc(invmod256(r.lastbits(8))) + + for i := 8; i < BIGBITS; i <<= 1 { + U.norm() + ui := uint(i) + b.copy(r) + b.mod2m(ui) + t1 := smul(U, b) + t1.shr(ui) + c.copy(r) + c.shr(ui) + c.mod2m(ui) + + t2 := smul(U, c) + t2.mod2m(ui) + t1.add(t2) + t1.norm() + b = smul(t1, U) + t1.copy(b) + t1.mod2m(ui) + + t2.one() + t2.shl(ui) + t1.rsub(t2) + t1.norm() + t1.shl(ui) + U.add(t1) + } + U.mod2m(8 * MODBYTES) + r.copy(U) + r.norm() +} + +/* reduce this mod m */ +func (r *BIG) Mod(m1 *BIG) { + m := NewBIGcopy(m1) + sr := NewBIG() + r.norm() + if Comp(r, m) < 0 { + return + } + + m.fshl(1) + k := 1 + + for Comp(r, m) >= 0 { + m.fshl(1) + k++ + } + + for k > 0 { + m.fshr(1) + sr.copy(r) + sr.sub(m) + sr.norm() + r.cmove(sr, int(1-((sr.w[NLEN-1]>>uint(CHUNK-1))&1))) + + k-- + } +} + +/* divide this by m */ +func (r *BIG) div(m1 *BIG) { + m := NewBIGcopy(m1) + var d int + k := 0 + r.norm() + sr := NewBIG() + e := NewBIGint(1) + b := NewBIGcopy(r) + r.zero() + + for Comp(b, m) >= 0 { + e.fshl(1) + m.fshl(1) + k++ + } + + for k > 0 { + m.fshr(1) + e.fshr(1) + + sr.copy(b) + sr.sub(m) + sr.norm() + d = int(1 - ((sr.w[NLEN-1] >> uint(CHUNK-1)) & 1)) + b.cmove(sr, d) + sr.copy(r) + sr.add(e) + sr.norm() + r.cmove(sr, d) + + k-- + } +} + +/* get 8*MODBYTES size random number */ +func random(rng *core.RAND) *BIG { + m := NewBIG() + var j int = 0 + var r byte = 0 + /* generate random BIG */ + for i := 0; i < 8*int(MODBYTES); i++ { + if j == 0 { + r = rng.GetByte() + } else { + r >>= 1 + } + + b := Chunk(int(r & 1)) + m.shl(1) + m.w[0] += b + j++ + j &= 7 + } + return m +} + +/* Create random BIG in portable way, one bit at a time */ +func Randomnum(q *BIG, rng *core.RAND) *BIG { + d := NewDBIG() + var j int = 0 + var r byte = 0 + for i := 0; i < 2*q.nbits(); i++ { + if j == 0 { + r = rng.GetByte() + } else { + r >>= 1 + } + + b := Chunk(int(r & 1)) + d.shl(1) + d.w[0] += b + j++ + j &= 7 + } + m := d.Mod(q) + return m +} + +func Randtrunc(q *BIG, trunc int, rng *core.RAND) *BIG { + m := Randomnum(q, rng) + if q.nbits() > trunc { + m.mod2m(uint(trunc)) + } + return m +} + +/* return a*b mod m */ +func Modmul(a1, b1, m *BIG) *BIG { + a := NewBIGcopy(a1) + b := NewBIGcopy(b1) + a.Mod(m) + b.Mod(m) + d := mul(a, b) + return d.Mod(m) +} + +/* return a^2 mod m */ +func Modsqr(a1, m *BIG) *BIG { + a := NewBIGcopy(a1) + a.Mod(m) + d := sqr(a) + return d.Mod(m) +} + +/* return -a mod m */ +func Modneg(a1, m *BIG) *BIG { + a := NewBIGcopy(a1) + a.Mod(m) + a.rsub(m) + a.Mod(m) + return a +} + +/* return a+b mod m */ +func Modadd(a1, b1, m *BIG) *BIG { + a := NewBIGcopy(a1) + b := NewBIGcopy(b1) + a.Mod(m) + b.Mod(m) + a.add(b); a.norm() + a.Mod(m) + return a +} + +/* Jacobi Symbol (this/p). Returns 0, 1 or -1 */ +func (r *BIG) Jacobi(p *BIG) int { + m := 0 + t := NewBIGint(0) + x := NewBIGint(0) + n := NewBIGint(0) + zilch := NewBIGint(0) + one := NewBIGint(1) + if p.parity() == 0 || Comp(r, zilch) == 0 || Comp(p, one) <= 0 { + return 0 + } + r.norm() + x.copy(r) + n.copy(p) + x.Mod(p) + + for Comp(n, one) > 0 { + if Comp(x, zilch) == 0 { + return 0 + } + n8 := n.lastbits(3) + k := 0 + for x.parity() == 0 { + k++ + x.shr(1) + } + if k%2 == 1 { + m += (n8*n8 - 1) / 8 + } + m += (n8 - 1) * (x.lastbits(2) - 1) / 4 + t.copy(n) + t.Mod(x) + n.copy(x) + x.copy(t) + m %= 2 + + } + if m == 0 { + return 1 + } + return -1 +} + +/* this=1/this mod p. Binary method */ +func (r *BIG) Invmodp(p *BIG) { + r.Mod(p) + if r.iszilch() { + return + } + u := NewBIGcopy(r) + v := NewBIGcopy(p) + x1 := NewBIGint(1) + x2 := NewBIGint(0) + t := NewBIGint(0) + one := NewBIGint(1) + for Comp(u, one) != 0 && Comp(v, one) != 0 { + for u.parity() == 0 { + u.fshr(1) + t.copy(x1) + t.add(p) + x1.cmove(t,x1.parity()) + x1.norm() + x1.fshr(1) + } + for v.parity() == 0 { + v.fshr(1) + t.copy(x2) + t.add(p) + x2.cmove(t,x2.parity()) + x2.norm() + x2.fshr(1) + } + if Comp(u, v) >= 0 { + u.sub(v) + u.norm() + t.copy(x1) + t.add(p) + x1.cmove(t,(Comp(x1,x2)>>1)&1) + x1.sub(x2) + x1.norm() + } else { + v.sub(u) + v.norm() + t.copy(x2) + t.add(p) + x2.cmove(t,(Comp(x2,x1)>>1)&1) + x2.sub(x1) + x2.norm() + } + } + r.copy(x1) + r.cmove(x2,Comp(u,one)&1) +} + +/* return this^e mod m */ +func (r *BIG) Powmod(e1 *BIG, m *BIG) *BIG { + e := NewBIGcopy(e1) + r.norm() + e.norm() + a := NewBIGint(1) + z := NewBIGcopy(e) + s := NewBIGcopy(r) + for true { + bt := z.parity() + z.fshr(1) + if bt == 1 { + a = Modmul(a, s, m) + } + if z.iszilch() { + break + } + s = Modsqr(s, m) + } + return a +} + +/* Arazi and Qi inversion mod 256 */ +func invmod256(a int) int { + var t1 int = 0 + c := (a >> 1) & 1 + t1 += c + t1 &= 1 + t1 = 2 - t1 + t1 <<= 1 + U := t1 + 1 + + // i=2 + b := a & 3 + t1 = U * b + t1 >>= 2 + c = (a >> 2) & 3 + t2 := (U * c) & 3 + t1 += t2 + t1 *= U + t1 &= 3 + t1 = 4 - t1 + t1 <<= 2 + U += t1 + + // i=4 + b = a & 15 + t1 = U * b + t1 >>= 4 + c = (a >> 4) & 15 + t2 = (U * c) & 15 + t1 += t2 + t1 *= U + t1 &= 15 + t1 = 16 - t1 + t1 <<= 4 + U += t1 + + return U +} + +func logb2(w uint32) uint { + v := w + v |= (v >> 1) + v |= (v >> 2) + v |= (v >> 4) + v |= (v >> 8) + v |= (v >> 16) + + v = v - ((v >> 1) & 0x55555555) + v = (v & 0x33333333) + ((v >> 2) & 0x33333333) + r := uint((((v + (v >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24) + return (r) +} + +// Optimized combined shift, subtract and norm +func ssn(r *BIG, a *BIG, m *BIG) int { + n := NLEN - 1 + m.w[0] = (m.w[0] >> 1) | ((m.w[1] << (BASEBITS - 1)) & BMASK) + r.w[0] = a.w[0] - m.w[0] + carry := r.w[0] >> BASEBITS + r.w[0] &= BMASK + for i := 1; i < n; i++ { + m.w[i] = (m.w[i] >> 1) | ((m.w[i+1] << (BASEBITS - 1)) & BMASK) + r.w[i] = a.w[i] - m.w[i] + carry + carry = r.w[i] >> BASEBITS + r.w[i] &= BMASK + } + m.w[n] >>= 1 + r.w[n] = a.w[n] - m.w[n] + carry + return int((r.w[n] >> uint(CHUNK-1)) & 1) +} diff --git a/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/BLS.go b/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/BLS.go new file mode 100644 index 00000000000..7ebb1f73f01 --- /dev/null +++ b/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/BLS.go @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2012-2020 MIRACL UK Ltd. + * + * This file is part of MIRACL Core + * (see https://github.com/miracl/core). + * + * 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. + */ + +/* Boneh-Lynn-Shacham signature 128-bit API Functions */ + +/* Loosely (for now) following https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-bls-signature-02 */ + +// Minimal-signature-size variant + +package FP256BN + +import "github.com/hyperledger/fabric-amcl/core" + + + +const BFS int = int(MODBYTES) +const BGS int = int(MODBYTES) +const BLS_OK int = 0 +const BLS_FAIL int = -1 + +var G2_TAB []*FP4 + +func ceil(a int,b int) int { + return (((a)-1)/(b)+1) +} + +/* output u \in F_p */ +func hash_to_field(hash int,hlen int ,DST []byte,M []byte,ctr int) []*FP { + q := NewBIGints(Modulus) + L := ceil(q.nbits()+AESKEY*8,8) + var u []*FP + var fd =make([]byte,L) + OKM:=core.XMD_Expand(hash,hlen,L*ctr,DST,M) + + for i:=0;i> BASEBITS + + for i := NLEN + 1; i < DNLEN; i++ { + b.w[i] = 0 + } + return b +} + +/* normalise this */ +func (r *DBIG) norm() { + carry := Chunk(0) + for i := 0; i < DNLEN-1; i++ { + d := r.w[i] + carry + r.w[i] = d & BMASK + carry = d >> BASEBITS + } + r.w[DNLEN-1] = (r.w[DNLEN-1] + carry) +} + +/* split DBIG at position n, return higher half, keep lower half */ +func (r *DBIG) split(n uint) *BIG { + t := NewBIG() + m := n % BASEBITS + carry := r.w[DNLEN-1] << (BASEBITS - m) + + for i := DNLEN - 2; i >= NLEN-1; i-- { + nw := (r.w[i] >> m) | carry + carry = (r.w[i] << (BASEBITS - m)) & BMASK + t.set(i-NLEN+1, nw) + } + r.w[NLEN-1] &= ((Chunk(1) << m) - 1) + return t +} + +func (r *DBIG) cmove(g *DBIG, d int) { + var b = Chunk(-d) + + for i := 0; i < DNLEN; i++ { + r.w[i] ^= (r.w[i] ^ g.w[i]) & b + } +} + +/* Compare a and b, return 0 if a==b, -1 if ab. Inputs must be normalised */ +func dcomp(a *DBIG, b *DBIG) int { + gt:=Chunk(0) + eq:=Chunk(1) + for i := DNLEN - 1; i >= 0; i-- { + gt |= ((b.w[i]-a.w[i]) >> BASEBITS) & eq + eq &= ((b.w[i]^a.w[i])-1) >> BASEBITS + } + return int(gt+gt+eq-1) +} + +/* Copy from another DBIG */ +func (r *DBIG) copy(x *DBIG) { + for i := 0; i < DNLEN; i++ { + r.w[i] = x.w[i] + } +} + +/* Copy from another BIG to upper half */ +func (r *DBIG) ucopy(x *BIG) { + for i := 0; i < NLEN; i++ { + r.w[i] = 0 + } + for i := NLEN; i < DNLEN; i++ { + r.w[i] = x.w[i-NLEN] + } +} + +func (r *DBIG) add(x *DBIG) { + for i := 0; i < DNLEN; i++ { + r.w[i] = r.w[i] + x.w[i] + } +} + +/* this-=x */ +func (r *DBIG) sub(x *DBIG) { + for i := 0; i < DNLEN; i++ { + r.w[i] = r.w[i] - x.w[i] + } +} + +/* this-=x */ +func (r *DBIG) rsub(x *DBIG) { + for i := 0; i < DNLEN; i++ { + r.w[i] = x.w[i] - r.w[i] + } +} + +/* general shift left */ +func (r *DBIG) shl(k uint) { + n := k % BASEBITS + m := int(k / BASEBITS) + + r.w[DNLEN-1] = (r.w[DNLEN-1-m] << n) | (r.w[DNLEN-m-2] >> (BASEBITS - n)) + for i := DNLEN - 2; i > m; i-- { + r.w[i] = ((r.w[i-m] << n) & BMASK) | (r.w[i-m-1] >> (BASEBITS - n)) + } + r.w[m] = (r.w[0] << n) & BMASK + for i := 0; i < m; i++ { + r.w[i] = 0 + } +} + +/* general shift right */ +func (r *DBIG) shr(k uint) { + n := (k % BASEBITS) + m := int(k / BASEBITS) + for i := 0; i < DNLEN-m-1; i++ { + r.w[i] = (r.w[m+i] >> n) | ((r.w[m+i+1] << (BASEBITS - n)) & BMASK) + } + r.w[DNLEN-m-1] = r.w[DNLEN-1] >> n + for i := DNLEN - m; i < DNLEN; i++ { + r.w[i] = 0 + } +} + +/* reduces this DBIG mod a BIG, and returns the BIG */ +func (r *DBIG) Mod(c *BIG) *BIG { + r.norm() + m := NewDBIGscopy(c) + dr := NewDBIG() + + if dcomp(r, m) < 0 { + return NewBIGdcopy(r) + } + + m.shl(1) + k := 1 + + for dcomp(r, m) >= 0 { + m.shl(1) + k++ + } + + for k > 0 { + m.shr(1) + + dr.copy(r) + dr.sub(m) + dr.norm() + r.cmove(dr, int(1-((dr.w[DNLEN-1]>>uint(CHUNK-1))&1))) + k-- + } + return NewBIGdcopy(r) +} + +/* return this/c */ +func (r *DBIG) div(c *BIG) *BIG { + var d int + k := 0 + m := NewDBIGscopy(c) + a := NewBIGint(0) + e := NewBIGint(1) + sr := NewBIG() + dr := NewDBIG() + r.norm() + + for dcomp(r, m) >= 0 { + e.fshl(1) + m.shl(1) + k++ + } + + for k > 0 { + m.shr(1) + e.shr(1) + + dr.copy(r) + dr.sub(m) + dr.norm() + d = int(1 - ((dr.w[DNLEN-1] >> uint(CHUNK-1)) & 1)) + r.cmove(dr, d) + sr.copy(a) + sr.add(e) + sr.norm() + a.cmove(sr, d) + + k-- + } + return a +} + +/* Convert to Hex String */ +func (r *DBIG) toString() string { + s := "" + len := r.nbits() + + if len%4 == 0 { + len /= 4 + } else { + len /= 4 + len++ + + } + + for i := len - 1; i >= 0; i-- { + b := NewDBIGcopy(r) + + b.shr(uint(i * 4)) + s += strconv.FormatInt(int64(b.w[0]&15), 16) + } + return s +} + +/* return number of bits */ +func (r *DBIG) nbits() int { + k := DNLEN - 1 + t := NewDBIGcopy(r) + t.norm() + for k >= 0 && t.w[k] == 0 { + k-- + } + if k < 0 { + return 0 + } + bts := int(BASEBITS) * k + c := t.w[k] + for c != 0 { + c /= 2 + bts++ + } + return bts +} + +/* convert from byte array to BIG */ +func DBIG_fromBytes(b []byte) *DBIG { + m := NewDBIG() + for i := 0; i < len(b); i++ { + m.shl(8) + m.w[0] += Chunk(int(b[i] & 0xff)) + } + return m +} diff --git a/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/ECDH.go b/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/ECDH.go new file mode 100644 index 00000000000..5e9b2410aa2 --- /dev/null +++ b/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/ECDH.go @@ -0,0 +1,360 @@ +/* + * Copyright (c) 2012-2020 MIRACL UK Ltd. + * + * This file is part of MIRACL Core + * (see https://github.com/miracl/core). + * + * 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. + */ + +/* ECDH/ECIES/ECDSA API Functions */ + +package FP256BN + + +import "github.com/hyperledger/fabric-amcl/core" + +const INVALID_PUBLIC_KEY int = -2 +const ERROR int = -3 +//const INVALID int = -4 +const EFS int = int(MODBYTES) +const EGS int = int(MODBYTES) + +/* return true if S is in ranger 0 < S < order , else return false */ +func ECDH_IN_RANGE(S []byte) bool { + r := NewBIGints(CURVE_Order) + s := FromBytes(S) + if s.iszilch() { + return false + } + if Comp(s,r)>=0 { + return false + } + return true +} + +/* Calculate a public/private EC GF(p) key pair W,S where W=S.G mod EC(p), + * where S is the secret key and W is the public key + * and G is fixed generator. + * If RNG is NULL then the private key is provided externally in S + * otherwise it is generated randomly internally */ +func ECDH_KEY_PAIR_GENERATE(RNG *core.RAND, S []byte, W []byte) int { + res := 0 + var s *BIG + var G *ECP + + G = ECP_generator() + + r := NewBIGints(CURVE_Order) + + if RNG == nil { + s = FromBytes(S) + s.Mod(r) + } else { + s = Randtrunc(r, 16*AESKEY, RNG) + } + + s.ToBytes(S) + + WP := G.mul(s) + + WP.ToBytes(W, false) // To use point compression on public keys, change to true + + return res +} + +/* validate public key */ +func ECDH_PUBLIC_KEY_VALIDATE(W []byte) int { + WP := ECP_fromBytes(W) + res := 0 + + r := NewBIGints(CURVE_Order) + + if WP.Is_infinity() { + res = INVALID_PUBLIC_KEY + } + if res == 0 { + + q := NewBIGints(Modulus) + nb := q.nbits() + k := NewBIGint(1) + k.shl(uint((nb + 4) / 2)) + k.add(q) + k.div(r) + + for k.parity() == 0 { + k.shr(1) + WP.dbl() + } + + if !k.isunity() { + WP = WP.mul(k) + } + if WP.Is_infinity() { + res = INVALID_PUBLIC_KEY + } + + } + return res +} + +/* IEEE-1363 Diffie-Hellman online calculation Z=S.WD */ +// type = 0 is just x coordinate output +// type = 1 for standard compressed output +// type = 2 for standard uncompress output 04|x|y +func ECDH_ECPSVDP_DH(S []byte, WD []byte, Z []byte,typ int) int { + res := 0 + + s := FromBytes(S) + + W := ECP_fromBytes(WD) + if W.Is_infinity() { + res = ERROR + } + + if res == 0 { + r := NewBIGints(CURVE_Order) + s.Mod(r) + W = W.mul(s) + if W.Is_infinity() { + res = ERROR + } else { + if CURVETYPE != MONTGOMERY { + if typ>0 { + if typ==1 { + W.ToBytes(Z,true) + } else { + W.ToBytes(Z,false) + } + } else { + W.GetX().ToBytes(Z) + } + return res; + } else { + W.GetX().ToBytes(Z) + } + } + } + return res +} + +/* IEEE ECDSA Signature, C and D are signature on F using private key S */ +func ECDH_ECPSP_DSA(sha int, RNG *core.RAND, S []byte, F []byte, C []byte, D []byte) int { + var T [EFS]byte + + B := core.GPhashit(core.MC_SHA2, sha, int(MODBYTES), 0, F, -1, nil ) + G := ECP_generator() + + r := NewBIGints(CURVE_Order) + + s := FromBytes(S) + f := FromBytes(B[:]) + + c := NewBIGint(0) + d := NewBIGint(0) + V := NewECP() + + for d.iszilch() { + u := Randomnum(r, RNG) + w := Randomnum(r, RNG) /* side channel masking */ + V.Copy(G) + V = V.mul(u) + vx := V.GetX() + c.copy(vx) + c.Mod(r) + if c.iszilch() { + continue + } + u.copy(Modmul(u, w, r)) + u.Invmodp(r) + d.copy(Modmul(s, c, r)) + d.add(f) + d.copy(Modmul(d, w, r)) + d.copy(Modmul(u, d, r)) + } + + c.ToBytes(T[:]) + for i := 0; i < EFS; i++ { + C[i] = T[i] + } + d.ToBytes(T[:]) + for i := 0; i < EFS; i++ { + D[i] = T[i] + } + return 0 +} + +/* IEEE1363 ECDSA Signature Verification. Signature C and D on F is verified using public key W */ +func ECDH_ECPVP_DSA(sha int, W []byte, F []byte, C []byte, D []byte) int { + res := 0 + + B := core.GPhashit(core.MC_SHA2, sha, int(MODBYTES), 0, F, -1, nil ) + + G := ECP_generator() + r := NewBIGints(CURVE_Order) + + c := FromBytes(C) + d := FromBytes(D) + f := FromBytes(B[:]) + + if c.iszilch() || Comp(c, r) >= 0 || d.iszilch() || Comp(d, r) >= 0 { + res = ERROR + } + + if res == 0 { + d.Invmodp(r) + f.copy(Modmul(f, d, r)) + h2 := Modmul(c, d, r) + + WP := ECP_fromBytes(W) + if WP.Is_infinity() { + res = ERROR + } else { + P := NewECP() + P.Copy(WP) + + P = P.Mul2(h2, G, f) + + if P.Is_infinity() { + res = ERROR + } else { + d = P.GetX() + d.Mod(r) + + if Comp(d, c) != 0 { + res = ERROR + } + } + } + } + + return res +} + +/* IEEE1363 ECIES encryption. Encryption of plaintext M uses public key W and produces ciphertext V,C,T */ +func ECDH_ECIES_ENCRYPT(sha int, P1 []byte, P2 []byte, RNG *core.RAND, W []byte, M []byte, V []byte, T []byte) []byte { + var Z [EFS]byte + var VZ [3*EFS + 1]byte + var K1 [AESKEY]byte + var K2 [AESKEY]byte + var U [EGS]byte + + if ECDH_KEY_PAIR_GENERATE(RNG, U[:], V) != 0 { + return nil + } + if ECDH_ECPSVDP_DH(U[:], W, Z[:], 0) != 0 { + return nil + } + + for i := 0; i < 2*EFS+1; i++ { + VZ[i] = V[i] + } + for i := 0; i < EFS; i++ { + VZ[2*EFS+1+i] = Z[i] + } + + K := core.KDF2(core.MC_SHA2, sha, VZ[:], P1, 2*AESKEY) + + for i := 0; i < AESKEY; i++ { + K1[i] = K[i] + K2[i] = K[AESKEY+i] + } + + C := core.AES_CBC_IV0_ENCRYPT(K1[:], M) + + L2 := core.InttoBytes(len(P2), 8) + + var AC []byte + + for i := 0; i < len(C); i++ { + AC = append(AC, C[i]) + } + for i := 0; i < len(P2); i++ { + AC = append(AC, P2[i]) + } + for i := 0; i < 8; i++ { + AC = append(AC, L2[i]) + } + + core.HMAC(core.MC_SHA2, sha, T, len(T), K2[:], AC) + + return C +} + +/* constant time n-byte compare */ +func ncomp(T1 []byte, T2 []byte, n int) bool { + res := 0 + for i := 0; i < n; i++ { + res |= int(T1[i] ^ T2[i]) + } + if res == 0 { + return true + } + return false +} + +/* IEEE1363 ECIES decryption. Decryption of ciphertext V,C,T using private key U outputs plaintext M */ +func ECDH_ECIES_DECRYPT(sha int, P1 []byte, P2 []byte, V []byte, C []byte, T []byte, U []byte) []byte { + var Z [EFS]byte + var VZ [3*EFS + 1]byte + var K1 [AESKEY]byte + var K2 [AESKEY]byte + + var TAG []byte = T[:] + + if ECDH_ECPSVDP_DH(U, V, Z[:], 0) != 0 { + return nil + } + + for i := 0; i < 2*EFS+1; i++ { + VZ[i] = V[i] + } + for i := 0; i < EFS; i++ { + VZ[2*EFS+1+i] = Z[i] + } + + K := core.KDF2(core.MC_SHA2, sha, VZ[:], P1, 2*AESKEY) + + for i := 0; i < AESKEY; i++ { + K1[i] = K[i] + K2[i] = K[AESKEY+i] + } + + M := core.AES_CBC_IV0_DECRYPT(K1[:], C) + + if M == nil { + return nil + } + + L2 := core.InttoBytes(len(P2), 8) + + var AC []byte + + for i := 0; i < len(C); i++ { + AC = append(AC, C[i]) + } + for i := 0; i < len(P2); i++ { + AC = append(AC, P2[i]) + } + for i := 0; i < 8; i++ { + AC = append(AC, L2[i]) + } + + core.HMAC(core.MC_SHA2, sha, TAG, len(TAG), K2[:],AC) + + if !ncomp(T, TAG, len(T)) { + return nil + } + + return M +} diff --git a/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/ECP.go b/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/ECP.go new file mode 100644 index 00000000000..840b9e703b3 --- /dev/null +++ b/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/ECP.go @@ -0,0 +1,1725 @@ +/* + * Copyright (c) 2012-2020 MIRACL UK Ltd. + * + * This file is part of MIRACL Core + * (see https://github.com/miracl/core). + * + * 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. + */ + +package FP256BN + +/* Elliptic Curve Point Structure */ + +type ECP struct { + x *FP + y *FP + z *FP +} + +/* Constructors */ +func NewECP() *ECP { + E := new(ECP) + E.x = NewFP() + E.y = NewFPint(1) + if CURVETYPE == EDWARDS { + E.z = NewFPint(1) + } else { + E.z = NewFP() + } + return E +} + +/* set (x,y) from two BIGs */ +func NewECPbigs(ix *BIG, iy *BIG) *ECP { + E := new(ECP) + E.x = NewFPbig(ix) + E.y = NewFPbig(iy) + E.z = NewFPint(1) + E.x.norm() + rhs := RHS(E.x) + + if CURVETYPE == MONTGOMERY { + if rhs.qr(nil) != 1 { + E.inf() + } + } else { + y2 := NewFPcopy(E.y) + y2.sqr() + if !y2.Equals(rhs) { + E.inf() + } + } + return E +} + +/* set (x,y) from BIG and a bit */ +func NewECPbigint(ix *BIG, s int) *ECP { + E := new(ECP) + E.x = NewFPbig(ix) + E.y = NewFP() + E.x.norm() + rhs := RHS(E.x) + E.z = NewFPint(1) + hint := NewFP() + if rhs.qr(hint) == 1 { + ny := rhs.sqrt(hint) + if ny.sign() != s { + ny.neg() + ny.norm() + } + E.y.copy(ny) + } else { + E.inf() + } + return E +} + +/* set from x - calculate y from curve equation */ +func NewECPbig(ix *BIG) *ECP { + E := new(ECP) + E.x = NewFPbig(ix) + E.y = NewFP() + E.x.norm() + rhs := RHS(E.x) + E.z = NewFPint(1) + hint := NewFP() + if rhs.qr(hint) == 1 { + if CURVETYPE != MONTGOMERY { + E.y.copy(rhs.sqrt(hint)) + } + } else { + E.inf() + } + return E +} + +/* test for O point-at-infinity */ +func (E *ECP) Is_infinity() bool { + // if E.INF {return true} + + if CURVETYPE == EDWARDS { + return (E.x.iszilch() && E.y.Equals(E.z)) + } + if CURVETYPE == WEIERSTRASS { + return (E.x.iszilch() && E.z.iszilch()) + } + if CURVETYPE == MONTGOMERY { + return E.z.iszilch() + } + return true +} + +/* Conditional swap of P and Q dependant on d */ +func (E *ECP) cswap(Q *ECP, d int) { + E.x.cswap(Q.x, d) + if CURVETYPE != MONTGOMERY { + E.y.cswap(Q.y, d) + } + E.z.cswap(Q.z, d) +} + +/* Conditional move of Q to P dependant on d */ +func (E *ECP) cmove(Q *ECP, d int) { + E.x.cmove(Q.x, d) + if CURVETYPE != MONTGOMERY { + E.y.cmove(Q.y, d) + } + E.z.cmove(Q.z, d) +} + +/* return 1 if b==c, no branching */ +func teq(b int32, c int32) int { + x := b ^ c + x -= 1 // if x=0, x now -1 + return int((x >> 31) & 1) +} + +/* this=P */ +func (E *ECP) Copy(P *ECP) { + E.x.copy(P.x) + if CURVETYPE != MONTGOMERY { + E.y.copy(P.y) + } + E.z.copy(P.z) +} + +/* this=-this */ +func (E *ECP) Neg() { + if CURVETYPE == WEIERSTRASS { + E.y.neg() + E.y.norm() + } + if CURVETYPE == EDWARDS { + E.x.neg() + E.x.norm() + } + return +} + +/* Constant time select from pre-computed table */ +func (E *ECP) selector(W []*ECP, b int32) { + MP := NewECP() + m := b >> 31 + babs := (b ^ m) - m + + babs = (babs - 1) / 2 + + E.cmove(W[0], teq(babs, 0)) // conditional move + E.cmove(W[1], teq(babs, 1)) + E.cmove(W[2], teq(babs, 2)) + E.cmove(W[3], teq(babs, 3)) + E.cmove(W[4], teq(babs, 4)) + E.cmove(W[5], teq(babs, 5)) + E.cmove(W[6], teq(babs, 6)) + E.cmove(W[7], teq(babs, 7)) + + MP.Copy(E) + MP.Neg() + E.cmove(MP, int(m&1)) +} + +/* set this=O */ +func (E *ECP) inf() { + E.x.zero() + if CURVETYPE != MONTGOMERY { + E.y.one() + } + if CURVETYPE != EDWARDS { + E.z.zero() + } else { + E.z.one() + } +} + +/* Test P == Q */ +func (E *ECP) Equals(Q *ECP) bool { + a := NewFP() + b := NewFP() + a.copy(E.x) + a.mul(Q.z) + a.reduce() + b.copy(Q.x) + b.mul(E.z) + b.reduce() + if !a.Equals(b) { + return false + } + if CURVETYPE != MONTGOMERY { + a.copy(E.y) + a.mul(Q.z) + a.reduce() + b.copy(Q.y) + b.mul(E.z) + b.reduce() + if !a.Equals(b) { + return false + } + } + + return true +} + +/* Calculate RHS of curve equation */ +func RHS(x *FP) *FP { + r := NewFPcopy(x) + r.sqr() + + if CURVETYPE == WEIERSTRASS { // x^3+Ax+B + b := NewFPbig(NewBIGints(CURVE_B)) + r.mul(x) + if CURVE_A == -3 { + cx := NewFPcopy(x) + cx.imul(3) + cx.neg() + cx.norm() + r.add(cx) + } + r.add(b) + } + if CURVETYPE == EDWARDS { // (Ax^2-1)/(Bx^2-1) + b := NewFPbig(NewBIGints(CURVE_B)) + + one := NewFPint(1) + b.mul(r) + b.sub(one) + b.norm() + if CURVE_A == -1 { + r.neg() + } + r.sub(one) + r.norm() + b.inverse(nil) + r.mul(b) + } + if CURVETYPE == MONTGOMERY { // x^3+Ax^2+x + x3 := NewFP() + x3.copy(r) + x3.mul(x) + r.imul(CURVE_A) + r.add(x3) + r.add(x) + } + r.reduce() + return r +} + +/* set to affine - from (x,y,z) to (x,y) */ +func (E *ECP) Affine() { + if E.Is_infinity() { + return + } + one := NewFPint(1) + if E.z.Equals(one) { + return + } + E.z.inverse(nil) + E.x.mul(E.z) + E.x.reduce() + + if CURVETYPE != MONTGOMERY { + E.y.mul(E.z) + E.y.reduce() + } + E.z.copy(one) +} + +/* extract x as a BIG */ +func (E *ECP) GetX() *BIG { + W := NewECP() + W.Copy(E) + W.Affine() + return W.x.redc() +} + +/* extract y as a BIG */ +func (E *ECP) GetY() *BIG { + W := NewECP() + W.Copy(E) + W.Affine() + return W.y.redc() +} + +/* get sign of Y */ +func (E *ECP) GetS() int { + W := NewECP() + W.Copy(E) + W.Affine() + return W.y.sign() +} + +/* extract x as an FP */ +func (E *ECP) getx() *FP { + return E.x +} + +/* extract y as an FP */ +func (E *ECP) gety() *FP { + return E.y +} + +/* extract z as an FP */ +func (E *ECP) getz() *FP { + return E.z +} + +/* convert to byte array */ +func (E *ECP) ToBytes(b []byte, compress bool) { + var t [int(MODBYTES)]byte + MB := int(MODBYTES) + alt:=false + W := NewECP() + W.Copy(E) + W.Affine() + W.x.redc().ToBytes(t[:]) + + if CURVETYPE == MONTGOMERY { + for i := 0; i < MB; i++ { + b[i] = t[i] + } + //b[0] = 0x06 + return + } + + if (MODBITS-1)%8 <= 4 && ALLOW_ALT_COMPRESS { + alt=true + } + + if alt { + for i:=0;i= 0 { + return NewECP() + } + return NewECPbig(px) + } + + if (MODBITS-1)%8 <= 4 && ALLOW_ALT_COMPRESS { + alt=true + } + + if alt { + for i:=0;i>5 + P:=NewECPbigint(px,0) + cmp:=P.y.islarger() + if (sgn==1 && cmp!=1) || (sgn==0 && cmp==1) { + P.Neg() + } + return P + } + } else { + for i := 0; i < MB; i++ { + t[i] = b[i+1] + } + px := FromBytes(t[:]) + if Comp(px, p) >= 0 { + return NewECP() + } + + if b[0] == 0x04 { + for i := 0; i < MB; i++ { + t[i] = b[i+MB+1] + } + py := FromBytes(t[:]) + if Comp(py, p) >= 0 { + return NewECP() + } + return NewECPbigs(px, py) + } + + if b[0] == 0x02 || b[0] == 0x03 { + return NewECPbigint(px, int(b[0]&1)) + } + } + return NewECP() +} + +/* convert to hex string */ +func (E *ECP) ToString() string { + W := NewECP() + W.Copy(E) + W.Affine() + if W.Is_infinity() { + return "infinity" + } + if CURVETYPE == MONTGOMERY { + return "(" + W.x.redc().ToString() + ")" + } else { + return "(" + W.x.redc().ToString() + "," + W.y.redc().ToString() + ")" + } +} + +/* this*=2 */ +func (E *ECP) dbl() { + + if CURVETYPE == WEIERSTRASS { + if CURVE_A == 0 { + t0 := NewFPcopy(E.y) + t0.sqr() + t1 := NewFPcopy(E.y) + t1.mul(E.z) + t2 := NewFPcopy(E.z) + t2.sqr() + + E.z.copy(t0) + E.z.add(t0) + E.z.norm() + E.z.add(E.z) + E.z.add(E.z) + E.z.norm() + t2.imul(3 * CURVE_B_I) + + x3 := NewFPcopy(t2) + x3.mul(E.z) + + y3 := NewFPcopy(t0) + y3.add(t2) + y3.norm() + E.z.mul(t1) + t1.copy(t2) + t1.add(t2) + t2.add(t1) + t0.sub(t2) + t0.norm() + y3.mul(t0) + y3.add(x3) + t1.copy(E.x) + t1.mul(E.y) + E.x.copy(t0) + E.x.norm() + E.x.mul(t1) + E.x.add(E.x) + E.x.norm() + E.y.copy(y3) + E.y.norm() + } else { + t0 := NewFPcopy(E.x) + t1 := NewFPcopy(E.y) + t2 := NewFPcopy(E.z) + t3 := NewFPcopy(E.x) + z3 := NewFPcopy(E.z) + y3 := NewFP() + x3 := NewFP() + b := NewFP() + + if CURVE_B_I == 0 { + b.copy(NewFPbig(NewBIGints(CURVE_B))) + } + + t0.sqr() //1 x^2 + t1.sqr() //2 y^2 + t2.sqr() //3 + + t3.mul(E.y) //4 + t3.add(t3) + t3.norm() //5 + z3.mul(E.x) //6 + z3.add(z3) + z3.norm() //7 + y3.copy(t2) + + if CURVE_B_I == 0 { + y3.mul(b) + } else { + y3.imul(CURVE_B_I) + } + + y3.sub(z3) //9 *** + x3.copy(y3) + x3.add(y3) + x3.norm() //10 + + y3.add(x3) //11 + x3.copy(t1) + x3.sub(y3) + x3.norm() //12 + y3.add(t1) + y3.norm() //13 + y3.mul(x3) //14 + x3.mul(t3) //15 + t3.copy(t2) + t3.add(t2) //16 + t2.add(t3) //17 + + if CURVE_B_I == 0 { + z3.mul(b) + } else { + z3.imul(CURVE_B_I) + } + + z3.sub(t2) //19 + z3.sub(t0) + z3.norm() //20 *** + t3.copy(z3) + t3.add(z3) //21 + + z3.add(t3) + z3.norm() //22 + t3.copy(t0) + t3.add(t0) //23 + t0.add(t3) //24 + t0.sub(t2) + t0.norm() //25 + + t0.mul(z3) //26 + y3.add(t0) //27 + t0.copy(E.y) + t0.mul(E.z) //28 + t0.add(t0) + t0.norm() //29 + z3.mul(t0) //30 + x3.sub(z3) //x3.norm();//31 + t0.add(t0) + t0.norm() //32 + t1.add(t1) + t1.norm() //33 + z3.copy(t0) + z3.mul(t1) //34 + + E.x.copy(x3) + E.x.norm() + E.y.copy(y3) + E.y.norm() + E.z.copy(z3) + E.z.norm() + } + } + + if CURVETYPE == EDWARDS { + C := NewFPcopy(E.x) + D := NewFPcopy(E.y) + H := NewFPcopy(E.z) + J := NewFP() + + E.x.mul(E.y) + E.x.add(E.x) + E.x.norm() + C.sqr() + D.sqr() + if CURVE_A == -1 { + C.neg() + } + E.y.copy(C) + E.y.add(D) + E.y.norm() + + H.sqr() + H.add(H) + E.z.copy(E.y) + J.copy(E.y) + J.sub(H) + J.norm() + E.x.mul(J) + C.sub(D) + C.norm() + E.y.mul(C) + E.z.mul(J) + + } + if CURVETYPE == MONTGOMERY { + A := NewFPcopy(E.x) + B := NewFPcopy(E.x) + AA := NewFP() + BB := NewFP() + C := NewFP() + + A.add(E.z) + A.norm() + AA.copy(A) + AA.sqr() + B.sub(E.z) + B.norm() + BB.copy(B) + BB.sqr() + C.copy(AA) + C.sub(BB) + C.norm() + + E.x.copy(AA) + E.x.mul(BB) + + A.copy(C) + A.imul((CURVE_A + 2) / 4) + + BB.add(A) + BB.norm() + E.z.copy(BB) + E.z.mul(C) + } + return +} + +/* this+=Q */ +func (E *ECP) Add(Q *ECP) { + + if CURVETYPE == WEIERSTRASS { + if CURVE_A == 0 { + b := 3 * CURVE_B_I + t0 := NewFPcopy(E.x) + t0.mul(Q.x) + t1 := NewFPcopy(E.y) + t1.mul(Q.y) + t2 := NewFPcopy(E.z) + t2.mul(Q.z) + t3 := NewFPcopy(E.x) + t3.add(E.y) + t3.norm() + t4 := NewFPcopy(Q.x) + t4.add(Q.y) + t4.norm() + t3.mul(t4) + t4.copy(t0) + t4.add(t1) + + t3.sub(t4) + t3.norm() + t4.copy(E.y) + t4.add(E.z) + t4.norm() + x3 := NewFPcopy(Q.y) + x3.add(Q.z) + x3.norm() + + t4.mul(x3) + x3.copy(t1) + x3.add(t2) + + t4.sub(x3) + t4.norm() + x3.copy(E.x) + x3.add(E.z) + x3.norm() + y3 := NewFPcopy(Q.x) + y3.add(Q.z) + y3.norm() + x3.mul(y3) + y3.copy(t0) + y3.add(t2) + y3.rsub(x3) + y3.norm() + x3.copy(t0) + x3.add(t0) + t0.add(x3) + t0.norm() + t2.imul(b) + + z3 := NewFPcopy(t1) + z3.add(t2) + z3.norm() + t1.sub(t2) + t1.norm() + y3.imul(b) + + x3.copy(y3) + x3.mul(t4) + t2.copy(t3) + t2.mul(t1) + x3.rsub(t2) + y3.mul(t0) + t1.mul(z3) + y3.add(t1) + t0.mul(t3) + z3.mul(t4) + z3.add(t0) + + E.x.copy(x3) + E.x.norm() + E.y.copy(y3) + E.y.norm() + E.z.copy(z3) + E.z.norm() + } else { + + t0 := NewFPcopy(E.x) + t1 := NewFPcopy(E.y) + t2 := NewFPcopy(E.z) + t3 := NewFPcopy(E.x) + t4 := NewFPcopy(Q.x) + z3 := NewFP() + y3 := NewFPcopy(Q.x) + x3 := NewFPcopy(Q.y) + b := NewFP() + + if CURVE_B_I == 0 { + b.copy(NewFPbig(NewBIGints(CURVE_B))) + } + + t0.mul(Q.x) //1 + t1.mul(Q.y) //2 + t2.mul(Q.z) //3 + + t3.add(E.y) + t3.norm() //4 + t4.add(Q.y) + t4.norm() //5 + t3.mul(t4) //6 + t4.copy(t0) + t4.add(t1) //7 + t3.sub(t4) + t3.norm() //8 + t4.copy(E.y) + t4.add(E.z) + t4.norm() //9 + x3.add(Q.z) + x3.norm() //10 + t4.mul(x3) //11 + x3.copy(t1) + x3.add(t2) //12 + + t4.sub(x3) + t4.norm() //13 + x3.copy(E.x) + x3.add(E.z) + x3.norm() //14 + y3.add(Q.z) + y3.norm() //15 + + x3.mul(y3) //16 + y3.copy(t0) + y3.add(t2) //17 + + y3.rsub(x3) + y3.norm() //18 + z3.copy(t2) + + if CURVE_B_I == 0 { + z3.mul(b) + } else { + z3.imul(CURVE_B_I) + } + + x3.copy(y3) + x3.sub(z3) + x3.norm() //20 + z3.copy(x3) + z3.add(x3) //21 + + x3.add(z3) //22 + z3.copy(t1) + z3.sub(x3) + z3.norm() //23 + x3.add(t1) + x3.norm() //24 + + if CURVE_B_I == 0 { + y3.mul(b) + } else { + y3.imul(CURVE_B_I) + } + + t1.copy(t2) + t1.add(t2) //26 + t2.add(t1) //27 + + y3.sub(t2) //28 + + y3.sub(t0) + y3.norm() //29 + t1.copy(y3) + t1.add(y3) //30 + y3.add(t1) + y3.norm() //31 + + t1.copy(t0) + t1.add(t0) //32 + t0.add(t1) //33 + t0.sub(t2) + t0.norm() //34 + t1.copy(t4) + t1.mul(y3) //35 + t2.copy(t0) + t2.mul(y3) //36 + y3.copy(x3) + y3.mul(z3) //37 + y3.add(t2) //38 + x3.mul(t3) //39 + x3.sub(t1) //40 + z3.mul(t4) //41 + t1.copy(t3) + t1.mul(t0) //42 + z3.add(t1) + E.x.copy(x3) + E.x.norm() + E.y.copy(y3) + E.y.norm() + E.z.copy(z3) + E.z.norm() + + } + } + if CURVETYPE == EDWARDS { + b := NewFPbig(NewBIGints(CURVE_B)) + A := NewFPcopy(E.z) + B := NewFP() + C := NewFPcopy(E.x) + D := NewFPcopy(E.y) + EE := NewFP() + F := NewFP() + G := NewFP() + + A.mul(Q.z) + B.copy(A) + B.sqr() + C.mul(Q.x) + D.mul(Q.y) + + EE.copy(C) + EE.mul(D) + EE.mul(b) + F.copy(B) + F.sub(EE) + G.copy(B) + G.add(EE) + + if CURVE_A == 1 { + EE.copy(D) + EE.sub(C) + } + C.add(D) + + B.copy(E.x) + B.add(E.y) + D.copy(Q.x) + D.add(Q.y) + B.norm() + D.norm() + B.mul(D) + B.sub(C) + B.norm() + F.norm() + B.mul(F) + E.x.copy(A) + E.x.mul(B) + G.norm() + if CURVE_A == 1 { + EE.norm() + C.copy(EE) + C.mul(G) + } + if CURVE_A == -1 { + C.norm() + C.mul(G) + } + E.y.copy(A) + E.y.mul(C) + E.z.copy(F) + E.z.mul(G) + } + return +} + +/* Differential Add for Montgomery curves. this+=Q where W is this-Q and is affine. */ +func (E *ECP) dadd(Q *ECP, W *ECP) { + A := NewFPcopy(E.x) + B := NewFPcopy(E.x) + C := NewFPcopy(Q.x) + D := NewFPcopy(Q.x) + DA := NewFP() + CB := NewFP() + + A.add(E.z) + B.sub(E.z) + + C.add(Q.z) + D.sub(Q.z) + A.norm() + D.norm() + + DA.copy(D) + DA.mul(A) + C.norm() + B.norm() + + CB.copy(C) + CB.mul(B) + + A.copy(DA) + A.add(CB) + A.norm() + A.sqr() + B.copy(DA) + B.sub(CB) + B.norm() + B.sqr() + + E.x.copy(A) + E.z.copy(W.x) + E.z.mul(B) + +} + +/* this-=Q */ +func (E *ECP) Sub(Q *ECP) { + NQ := NewECP() + NQ.Copy(Q) + NQ.Neg() + E.Add(NQ) +} + +/* constant time multiply by small integer of length bts - use ladder */ +func (E *ECP) pinmul(e int32, bts int32) *ECP { + if CURVETYPE == MONTGOMERY { + return E.mul(NewBIGint(int(e))) + } else { + P := NewECP() + R0 := NewECP() + R1 := NewECP() + R1.Copy(E) + + for i := bts - 1; i >= 0; i-- { + b := int((e >> uint32(i)) & 1) + P.Copy(R1) + P.Add(R0) + R0.cswap(R1, b) + R1.Copy(P) + R0.dbl() + R0.cswap(R1, b) + } + P.Copy(R0) + return P + } +} + +/* return e.this */ + +func (E *ECP) mul(e *BIG) *ECP { + if e.iszilch() || E.Is_infinity() { + return NewECP() + } + P := NewECP() + if CURVETYPE == MONTGOMERY { + /* use Ladder */ + D := NewECP() + R0 := NewECP() + R0.Copy(E) + R1 := NewECP() + R1.Copy(E) + R1.dbl() + D.Copy(E); D.Affine() + nb := e.nbits() + for i := nb - 2; i >= 0; i-- { + b := int(e.bit(i)) + P.Copy(R1) + P.dadd(R0, D) + R0.cswap(R1, b) + R1.Copy(P) + R0.dbl() + R0.cswap(R1, b) + } + P.Copy(R0) + } else { + // fixed size windows + mt := NewBIG() + t := NewBIG() + Q := NewECP() + C := NewECP() + + var W []*ECP + var w [1 + (NLEN*int(BASEBITS)+3)/4]int8 + + Q.Copy(E) + Q.dbl() + + W = append(W, NewECP()) + W[0].Copy(E) + + for i := 1; i < 8; i++ { + W = append(W, NewECP()) + W[i].Copy(W[i-1]) + W[i].Add(Q) + } + + // make exponent odd - add 2P if even, P if odd + t.copy(e) + s := int(t.parity()) + t.inc(1) + t.norm() + ns := int(t.parity()) + mt.copy(t) + mt.inc(1) + mt.norm() + t.cmove(mt, s) + Q.cmove(E, ns) + C.Copy(Q) + + nb := 1 + (t.nbits()+3)/4 + + // convert exponent to signed 4-bit window + for i := 0; i < nb; i++ { + w[i] = int8(t.lastbits(5) - 16) + t.dec(int(w[i])) + t.norm() + t.fshr(4) + } + w[nb] = int8(t.lastbits(5)) + + P.Copy(W[(int(w[nb])-1)/2]) + for i := nb - 1; i >= 0; i-- { + Q.selector(W, int32(w[i])) + P.dbl() + P.dbl() + P.dbl() + P.dbl() + P.Add(Q) + } + P.Sub(C) /* apply correction */ + } + return P +} + +/* Public version */ +func (E *ECP) Mul(e *BIG) *ECP { + return E.mul(e) +} + +// Generic multi-multiplication, fixed 4-bit window, P=Sigma e_i*X_i +func ECP_muln(n int, X []*ECP, e []*BIG ) *ECP { + P:=NewECP() + R:=NewECP() + S:=NewECP() + var B []*ECP + t := NewBIG() + for i:=0;i<16;i++ { + B = append(B,NewECP()) + } + mt:=NewBIGcopy(e[0]); mt.norm(); + for i:=1;i=0;i-- { + for j:=0;j<16;j++ { + B[j].inf() + } + for j:=0;j=1;j-- { + R.Add(B[j]) + S.Add(R) + } + for j:=0;j<4;j++ { + P.dbl() + } + P.Add(S) + } + return P +} + +/* Return e.this+f.Q */ + +func (E *ECP) Mul2(e *BIG, Q *ECP, f *BIG) *ECP { + te := NewBIG() + tf := NewBIG() + mt := NewBIG() + S := NewECP() + T := NewECP() + C := NewECP() + var W []*ECP + var w [1 + (NLEN*int(BASEBITS)+1)/2]int8 + + te.copy(e) + tf.copy(f) + + // precompute table + for i := 0; i < 8; i++ { + W = append(W, NewECP()) + } + W[1].Copy(E) + W[1].Sub(Q) + W[2].Copy(E) + W[2].Add(Q) + S.Copy(Q) + S.dbl() + W[0].Copy(W[1]) + W[0].Sub(S) + W[3].Copy(W[2]) + W[3].Add(S) + T.Copy(E) + T.dbl() + W[5].Copy(W[1]) + W[5].Add(T) + W[6].Copy(W[2]) + W[6].Add(T) + W[4].Copy(W[5]) + W[4].Sub(S) + W[7].Copy(W[6]) + W[7].Add(S) + + // if multiplier is odd, add 2, else add 1 to multiplier, and add 2P or P to correction + + s := int(te.parity()) + te.inc(1) + te.norm() + ns := int(te.parity()) + mt.copy(te) + mt.inc(1) + mt.norm() + te.cmove(mt, s) + T.cmove(E, ns) + C.Copy(T) + + s = int(tf.parity()) + tf.inc(1) + tf.norm() + ns = int(tf.parity()) + mt.copy(tf) + mt.inc(1) + mt.norm() + tf.cmove(mt, s) + S.cmove(Q, ns) + C.Add(S) + + mt.copy(te) + mt.add(tf) + mt.norm() + nb := 1 + (mt.nbits()+1)/2 + + // convert exponent to signed 2-bit window + for i := 0; i < nb; i++ { + a := (te.lastbits(3) - 4) + te.dec(int(a)) + te.norm() + te.fshr(2) + b := (tf.lastbits(3) - 4) + tf.dec(int(b)) + tf.norm() + tf.fshr(2) + w[i] = int8(4*a + b) + } + w[nb] = int8(4*te.lastbits(3) + tf.lastbits(3)) + S.Copy(W[(w[nb]-1)/2]) + + for i := nb - 1; i >= 0; i-- { + T.selector(W, int32(w[i])) + S.dbl() + S.dbl() + S.Add(T) + } + S.Sub(C) /* apply correction */ + return S +} + +func (E *ECP) Cfp() { + cf := CURVE_Cof_I + if cf == 1 { + return + } + if cf == 4 { + E.dbl() + E.dbl() + return + } + if cf == 8 { + E.dbl() + E.dbl() + E.dbl() + return + } + c := NewBIGints(CURVE_Cof) + E.Copy(E.mul(c)) +} + +/* Hunt and Peck a BIG to a curve point */ +func ECP_hap2point(h *BIG) *ECP { + var P *ECP + x := NewBIGcopy(h) + + + for true { + if CURVETYPE != MONTGOMERY { + P = NewECPbigint(x, 0) + } else { + P = NewECPbig(x) + } + x.inc(1) + x.norm() + if !P.Is_infinity() { + break + } + } + return P +} + +/* Constant time Map to Point */ +func ECP_map2point(h *FP) *ECP { + P := NewECP() + + if CURVETYPE == MONTGOMERY { +// Elligator 2 + X1:=NewFP() + X2:=NewFP() + w:=NewFP() + one:=NewFPint(1) + A:=NewFPint(CURVE_A) + t:=NewFPcopy(h) + N:=NewFP() + D:=NewFP() + hint:=NewFP() + + t.sqr(); + + if PM1D2 == 2 { + t.add(t) + } + if PM1D2 == 1 { + t.neg(); + } + if PM1D2 > 2 { + t.imul(QNRI); + } + + t.norm() + D.copy(t); D.add(one); D.norm() + + X1.copy(A) + X1.neg(); X1.norm() + X2.copy(X1) + X2.mul(t) + + w.copy(X1); w.sqr(); N.copy(w); N.mul(X1) + w.mul(A); w.mul(D); N.add(w) + t.copy(D); t.sqr() + t.mul(X1) + N.add(t); N.norm() + + t.copy(N); t.mul(D) + qres:=t.qr(hint) + w.copy(t); w.inverse(hint) + D.copy(w); D.mul(N) + X1.mul(D) + X2.mul(D) + X1.cmove(X2,1-qres) + + a:=X1.redc() + P.Copy(NewECPbig(a)) + } + if CURVETYPE == EDWARDS { +// Elligator 2 - map to Montgomery, place point, map back + X1:=NewFP() + X2:=NewFP() + t:=NewFPcopy(h) + w:=NewFP() + one:=NewFPint(1) + A:=NewFP() + w1:=NewFP() + w2:=NewFP() + B:=NewFPbig(NewBIGints(CURVE_B)) + Y:=NewFP() + K:=NewFP() + D:=NewFP() + hint:=NewFP() + //Y3:=NewFP() + rfc:=0 + + if MODTYPE != GENERALISED_MERSENNE { + A.copy(B) + + if (CURVE_A==1) { + A.add(one) + B.sub(one) + } else { + A.sub(one) + B.add(one) + } + A.norm(); B.norm() + + A.div2() + B.div2() + B.div2() + + K.copy(B) + K.neg(); K.norm() + //K.inverse(nil) + K.invsqrt(K,w1); + + rfc=RIADZ + if rfc==1 { // RFC7748 + A.mul(K) + K.mul(w1); + //K=K.sqrt(nil) + } else { + B.sqr() + } + } else { + rfc=1 + A.copy(NewFPint(156326)) + } + + t.sqr() + qnr:=0 + if PM1D2 == 2 { + t.add(t) + qnr=2 + } + if PM1D2 == 1 { + t.neg(); + qnr=-1 + } + if PM1D2 > 2 { + t.imul(QNRI); + qnr=QNRI + } + t.norm() + + D.copy(t); D.add(one); D.norm() + X1.copy(A) + X1.neg(); X1.norm() + X2.copy(X1); X2.mul(t) + +// Figure out RHS of Montgomery curve in rational form gx1/d^3 + + w.copy(X1); w.sqr(); w1.copy(w); w1.mul(X1) + w.mul(A); w.mul(D); w1.add(w) + w2.copy(D); w2.sqr() + + if rfc==0 { + w.copy(X1); w.mul(B) + w2.mul(w) + w1.add(w2) + } else { + w2.mul(X1) + w1.add(w2) + } + w1.norm() + + B.copy(w1); B.mul(D) + qres:=B.qr(hint) + w.copy(B); w.inverse(hint) + D.copy(w); D.mul(w1) + X1.mul(D) + X2.mul(D) + D.sqr() + + w1.copy(B); w1.imul(qnr) + w.copy(NewFPbig(NewBIGints(CURVE_HTPC))) + w.mul(hint) + w2.copy(D); w2.mul(h) + + X1.cmove(X2,1-qres) + B.cmove(w1,1-qres) + hint.cmove(w,1-qres) + D.cmove(w2,1-qres) + + Y.copy(B.sqrt(hint)) + Y.mul(D) + +/* + Y.copy(B.sqrt(hint)) + Y.mul(D) + + B.imul(qnr) + w.copy(NewFPbig(NewBIGints(CURVE_HTPC))) + hint.mul(w) + + Y3.copy(B.sqrt(hint)) + D.mul(h) + Y3.mul(D) + + X1.cmove(X2,1-qres) + Y.cmove(Y3,1-qres) +*/ + w.copy(Y); w.neg(); w.norm() + Y.cmove(w,qres^Y.sign()) + + if rfc==0 { + X1.mul(K) + Y.mul(K) + } + + if MODTYPE == GENERALISED_MERSENNE { + t.copy(X1); t.sqr() + w.copy(t); w.add(one); w.norm() + t.sub(one); t.norm() + w1.copy(t); w1.mul(Y) + w1.add(w1); X2.copy(w1); X2.add(w1); X2.norm() + t.sqr() + Y.sqr(); Y.add(Y); Y.add(Y); Y.norm() + B.copy(t); B.add(Y); B.norm() + + w2.copy(Y); w2.sub(t); w2.norm() + w2.mul(X1) + t.mul(X1) + Y.div2() + w1.copy(Y); w1.mul(w) + w1.rsub(t); w1.norm() + + t.copy(X2); t.mul(w1) + P.x.copy(t) + t.copy(w2); t.mul(B) + P.y.copy(t) + t.copy(w1); t.mul(B) + P.z.copy(t) + + return P; + } else { + w1.copy(X1); w1.add(one); w1.norm() + w2.copy(X1); w2.sub(one); w2.norm() + t.copy(w1); t.mul(Y) + X1.mul(w1) + + if rfc==1 { + X1.mul(K) + } + Y.mul(w2) + P.x.copy(X1) + P.y.copy(Y) + P.z.copy(t) + + return P + } + } + if CURVETYPE == WEIERSTRASS { + // swu method + A:=NewFP() + B:=NewFP() + X1:=NewFP() + X2:=NewFP() + X3:=NewFP() + one:=NewFPint(1) + Y:=NewFP() + D:=NewFP() + t:=NewFPcopy(h) + w:=NewFP() + D2:=NewFP() + hint:=NewFP() + GX1:=NewFP() + //Y3:=NewFP() + sgn:=t.sign() + + if CURVE_A != 0 || HTC_ISO != 0{ + if HTC_ISO!=0 { +/* CAHCZS + A.copy(NewFPbig(NewBIGints(CURVE_Ad))) + B.copy(NewFPbig(NewBIGints(CURVE_Bd))) +CAHCZF */ + } else { + A.copy(NewFPint(CURVE_A)) + B.copy(NewFPbig(NewBIGints(CURVE_B))) + } + // SSWU method + t.sqr(); + t.imul(RIADZ) + w.copy(t); w.add(one); w.norm() + + w.mul(t); D.copy(A) + D.mul(w) + + w.add(one); w.norm() + w.mul(B) + w.neg(); w.norm() + + X2.copy(w); + X3.copy(t); X3.mul(X2) + +// x^3+Ad^2x+Bd^3 + GX1.copy(X2); GX1.sqr(); D2.copy(D) + D2.sqr(); w.copy(A); w.mul(D2); GX1.add(w); GX1.norm(); GX1.mul(X2); D2.mul(D);w.copy(B); w.mul(D2); GX1.add(w); GX1.norm() + + w.copy(GX1); w.mul(D) + qr:=w.qr(hint) + D.copy(w); D.inverse(hint) + D.mul(GX1) + X2.mul(D) + X3.mul(D) + t.mul(h) + D2.copy(D); D2.sqr() + + + D.copy(D2); D.mul(t) + t.copy(w); t.imul(RIADZ) + X1.copy(NewFPbig(NewBIGints(CURVE_HTPC))) + X1.mul(hint) + + X2.cmove(X3,1-qr) + D2.cmove(D,1-qr) + w.cmove(t,1-qr) + hint.cmove(X1,1-qr) + + Y.copy(w.sqrt(hint)) + Y.mul(D2) +/* + Y.copy(w.sqrt(hint)) + Y.mul(D2) + + D2.mul(t) + w.imul(RIADZ) + + X1.copy(NewFPbig(NewBIGints(CURVE_HTPC))) + hint.mul(X1) + + Y3.copy(w.sqrt(hint)) + Y3.mul(D2) + + X2.cmove(X3,1-qr) + Y.cmove(Y3,1-qr) +*/ + ne:=Y.sign()^sgn + w.copy(Y); w.neg(); w.norm() + Y.cmove(w,ne) + + if HTC_ISO!=0 { +/* CAHCZS + k:=0 + isox:=HTC_ISO + isoy:=3*(isox-1)/2 + + //xnum + xnum:=NewFPbig(NewBIGints(PC[k])); k+=1 + for i:=0;i> 31 + babs := (b ^ m) - m + + babs = (babs - 1) / 2 + + E.cmove(W[0], teq(babs, 0)) // conditional move + E.cmove(W[1], teq(babs, 1)) + E.cmove(W[2], teq(babs, 2)) + E.cmove(W[3], teq(babs, 3)) + E.cmove(W[4], teq(babs, 4)) + E.cmove(W[5], teq(babs, 5)) + E.cmove(W[6], teq(babs, 6)) + E.cmove(W[7], teq(babs, 7)) + + MP.Copy(E) + MP.neg() + E.cmove(MP, int(m&1)) +} + +/* Test if P == Q */ +func (E *ECP2) Equals(Q *ECP2) bool { + + a := NewFP2copy(E.x) + b := NewFP2copy(Q.x) + a.mul(Q.z) + b.mul(E.z) + + if !a.Equals(b) { + return false + } + a.copy(E.y) + b.copy(Q.y) + a.mul(Q.z) + b.mul(E.z) + if !a.Equals(b) { + return false + } + + return true +} + +/* set to Affine - (x,y,z) to (x,y) */ +func (E *ECP2) Affine() { + if E.Is_infinity() { + return + } + one := NewFP2int(1) + if E.z.Equals(one) { + E.x.reduce() + E.y.reduce() + return + } + E.z.inverse(nil) + + E.x.mul(E.z) + E.x.reduce() + E.y.mul(E.z) + E.y.reduce() + E.z.copy(one) +} + +/* extract affine x as FP2 */ +func (E *ECP2) GetX() *FP2 { + W := NewECP2() + W.Copy(E) + W.Affine() + return W.x +} + +/* extract affine y as FP2 */ +func (E *ECP2) GetY() *FP2 { + W := NewECP2() + W.Copy(E) + W.Affine() + return W.y +} + +/* extract projective x */ +func (E *ECP2) getx() *FP2 { + return E.x +} + +/* extract projective y */ +func (E *ECP2) gety() *FP2 { + return E.y +} + +/* extract projective z */ +func (E *ECP2) getz() *FP2 { + return E.z +} + +/* convert to byte array */ +func (E *ECP2) ToBytes(b []byte,compress bool) { + var t [2*int(MODBYTES)]byte + MB := 2*int(MODBYTES) + alt:=false + W := NewECP2() + W.Copy(E) + W.Affine() + W.x.ToBytes(t[:]) + + if (MODBITS-1)%8 <= 4 && ALLOW_ALT_COMPRESS { + alt=true + } + + if alt { + for i:=0;i>5 + P:=NewECP2fp2(rx,0) + cmp:=P.y.islarger() + if (sgn==1 && cmp!=1) || (sgn==0 && cmp==1) { + P.neg() + } + return P; + } + } else { + for i:=0;i= 0; i-- { + Q.selector(W, int32(w[i])) + P.dbl() + P.dbl() + P.dbl() + P.dbl() + P.Add(Q) + } + P.Sub(C) + return P +} + +/* Public version */ +func (E *ECP2) Mul(e *BIG) *ECP2 { + return E.mul(e) +} + + +/* clear cofactor */ +func (E *ECP2) Cfp() { + var T, K, xQ, x2Q *ECP2 + /* Fast Hashing to G2 - Fuentes-Castaneda, Knapp and Rodriguez-Henriquez */ + Fra := NewBIGints(Fra) + Frb := NewBIGints(Frb) + X := NewFP2bigs(Fra, Frb) + if SEXTIC_TWIST == M_TYPE { + X.inverse(nil) + X.norm() + } + + x := NewBIGints(CURVE_Bnx) + + if CURVE_PAIRING_TYPE == BN { + T = NewECP2() + T.Copy(E) + T = T.mul(x) + if SIGN_OF_X == NEGATIVEX { + T.neg() + } + + K = NewECP2() + K.Copy(T) + K.dbl() + K.Add(T) + + K.frob(X) + E.frob(X) + E.frob(X) + E.frob(X) + E.Add(T) + E.Add(K) + T.frob(X) + T.frob(X) + E.Add(T) + } + if CURVE_PAIRING_TYPE > BN { + xQ = E.mul(x) + x2Q = xQ.mul(x) + + if SIGN_OF_X == NEGATIVEX { + xQ.neg() + } + + x2Q.Sub(xQ) + x2Q.Sub(E) + + xQ.Sub(E) + xQ.frob(X) + + E.dbl() + E.frob(X) + E.frob(X) + + E.Add(x2Q) + E.Add(xQ) + } +} + + +/* P=u0.Q0+u1*Q1+u2*Q2+u3*Q3 */ +// Bos & Costello https://eprint.iacr.org/2013/458.pdf +// Faz-Hernandez & Longa & Sanchez https://eprint.iacr.org/2013/158.pdf +// Side channel attack secure +func mul4(Q []*ECP2, u []*BIG) *ECP2 { + W := NewECP2() + P := NewECP2() + var T []*ECP2 + mt := NewBIG() + var t []*BIG + + var w [NLEN*int(BASEBITS) + 1]int8 + var s [NLEN*int(BASEBITS) + 1]int8 + + for i := 0; i < 4; i++ { + t = append(t, NewBIGcopy(u[i])) + } + + T = append(T, NewECP2()) + T[0].Copy(Q[0]) // Q[0] + T = append(T, NewECP2()) + T[1].Copy(T[0]) + T[1].Add(Q[1]) // Q[0]+Q[1] + T = append(T, NewECP2()) + T[2].Copy(T[0]) + T[2].Add(Q[2]) // Q[0]+Q[2] + T = append(T, NewECP2()) + T[3].Copy(T[1]) + T[3].Add(Q[2]) // Q[0]+Q[1]+Q[2] + T = append(T, NewECP2()) + T[4].Copy(T[0]) + T[4].Add(Q[3]) // Q[0]+Q[3] + T = append(T, NewECP2()) + T[5].Copy(T[1]) + T[5].Add(Q[3]) // Q[0]+Q[1]+Q[3] + T = append(T, NewECP2()) + T[6].Copy(T[2]) + T[6].Add(Q[3]) // Q[0]+Q[2]+Q[3] + T = append(T, NewECP2()) + T[7].Copy(T[3]) + T[7].Add(Q[3]) // Q[0]+Q[1]+Q[2]+Q[3] + + // Make it odd + pb := 1 - t[0].parity() + t[0].inc(pb) + + // Number of bits + mt.zero() + for i := 0; i < 4; i++ { + t[i].norm() + mt.or(t[i]) + } + + nb := 1 + mt.nbits() + + // Sign pivot + s[nb-1] = 1 + for i := 0; i < nb-1; i++ { + t[0].fshr(1) + s[i] = 2*int8(t[0].parity()) - 1 + } + + // Recoded exponent + for i := 0; i < nb; i++ { + w[i] = 0 + k := 1 + for j := 1; j < 4; j++ { + bt := s[i] * int8(t[j].parity()) + t[j].fshr(1) + t[j].dec(int(bt) >> 1) + t[j].norm() + w[i] += bt * int8(k) + k *= 2 + } + } + + // Main loop + P.selector(T, int32(2*w[nb-1]+1)) + for i := nb - 2; i >= 0; i-- { + P.dbl() + W.selector(T, int32(2*w[i]+s[i])) + P.Add(W) + } + + // apply correction + W.Copy(P) + W.Sub(Q[0]) + P.cmove(W, pb) + + return P +} + +/* Hunt and Peck a BIG to a curve point */ +func ECP2_hap2point(h *BIG) *ECP2 { + x := NewBIGcopy(h) + one := NewBIGint(1) + var X *FP2 + var Q *ECP2 + for true { + X = NewFP2bigs(one, x) + Q = NewECP2fp2(X,0) + if !Q.Is_infinity() { + break + } + x.inc(1) + x.norm() + } + return Q +} + +/* Constant time Map to Point */ + func ECP2_map2point(H *FP2) *ECP2 { + // Shallue and van de Woestijne + var Q *ECP2 + NY:=NewFP2int(1) + T:=NewFP2copy(H) /**/ + sgn:=T.sign() /**/ + if HTC_ISO_G2 == 0 { +/* */ + Z:=NewFPint(RIADZG2A); + X1:=NewFP2fp(Z) + X3:=NewFP2copy(X1) + A:=RHS2(X1) + W:=NewFP2copy(A) + if (RIADZG2A==-1 && RIADZG2B==0 && SEXTIC_TWIST==M_TYPE && CURVE_B_I==4) { // special case for BLS12381 + W.copy(NewFP2ints(2,1)) + } else { + W.sqrt(nil) + } + s:=NewFPbig(NewBIGints(SQRTm3)) + Z.mul(s) + + T.sqr() + Y:=NewFP2copy(A); Y.mul(T) + T.copy(NY); T.add(Y); T.norm() + Y.rsub(NY); Y.norm() + NY.copy(T); NY.mul(Y); + + NY.pmul(Z) + NY.inverse(nil) + + W.pmul(Z) + if (W.sign()==1) { + W.neg() + W.norm() + } + W.pmul(Z) + W.mul(H); W.mul(Y); W.mul(NY) + + X1.neg(); X1.norm(); X1.div2() + X2:=NewFP2copy(X1) + X1.sub(W); X1.norm() + X2.add(W); X2.norm() + A.add(A); A.add(A); A.norm() + T.sqr(); T.mul(NY); T.sqr() + A.mul(T) + X3.add(A); X3.norm() + + Y.copy(RHS2(X2)) + X3.cmove(X2,Y.qr(nil)) + Y.copy(RHS2(X1)) + X3.cmove(X1,Y.qr(nil)) + Y.copy(RHS2(X3)) + Y.sqrt(nil) + + ne:=Y.sign()^sgn + W.copy(Y); W.neg(); W.norm() + Y.cmove(W,ne) + + Q=NewECP2fp2s(X3,Y) +/* */ + } else { + +/* CAHCZS + Q=NewECP2() + Ad:=NewFP2bigs(NewBIGints(CURVE_Adr), NewBIGints(CURVE_Adi)) + Bd:=NewFP2bigs(NewBIGints(CURVE_Bdr), NewBIGints(CURVE_Bdi)) + ZZ:=NewFP2ints(RIADZG2A,RIADZG2B) + hint:=NewFP() + + T.sqr() + T.mul(ZZ) + W:=NewFP2copy(T) + W.add(NY); W.norm() + + W.mul(T) + D:=NewFP2copy(Ad) + D.mul(W) + + W.add(NY); W.norm() + W.mul(Bd); + W.neg(); W.norm() + + X2:=NewFP2copy(W) + X3:=NewFP2copy(T) + X3.mul(X2) + + GX1:=NewFP2copy(X2); GX1.sqr() + D2:=NewFP2copy(D); D2.sqr() + + W.copy(Ad); W.mul(D2); GX1.add(W); GX1.norm(); GX1.mul(X2); D2.mul(D); W.copy(Bd); W.mul(D2); GX1.add(W); GX1.norm() // x^3+Ax+b + + W.copy(GX1); W.mul(D) + qr:=W.qr(hint) + D.copy(W); D.inverse(hint) + D.mul(GX1) + X2.mul(D) + X3.mul(D) + T.mul(H) + D2.copy(D); D2.sqr() + + D.copy(D2); D.mul(T) + T.copy(W); T.mul(ZZ) + + s:=NewFPbig(NewBIGints(CURVE_HTPC2)) + s.mul(hint); + + X2.cmove(X3,1-qr) + W.cmove(T,1-qr) + D2.cmove(D,1-qr) + hint.cmove(s,1-qr) + + Y:=NewFP2copy(W); Y.sqrt(hint) + Y.mul(D2) + + ne:=Y.sign()^sgn + W.copy(Y); W.neg(); W.norm() + Y.cmove(W,ne) + + k:=0 + isox:=HTC_ISO_G2 + isoy:=3*(isox-1)/2 + +//xnum + xnum:=NewFP2bigs(NewBIGints(PCR[k]),NewBIGints(PCI[k])); k+=1 + for i:=0;i> TBITS) + (v << (BASEBITS - TBITS)))) + + t.norm() + return t + } + if MODTYPE == MONTGOMERY_FRIENDLY { + for i := 0; i < NLEN; i++ { + top, bot := muladd(d.w[i], MConst-1, d.w[i], d.w[NLEN+i-1]) + d.w[NLEN+i-1] = bot + d.w[NLEN+i] += top + } + b := NewBIG() + + for i := 0; i < NLEN; i++ { + b.w[i] = d.w[NLEN+i] + } + b.norm() + return b + } + + if MODTYPE == GENERALISED_MERSENNE { // GoldiLocks only + t := d.split(MODBITS) + b := NewBIGdcopy(d) + b.add(t) + dd := NewDBIGscopy(t) + dd.shl(MODBITS / 2) + + tt := dd.split(MODBITS) + lo := NewBIGdcopy(dd) + b.add(tt) + b.add(lo) + b.norm() + tt.shl(MODBITS / 2) + b.add(tt) + + carry := b.w[NLEN-1] >> TBITS + b.w[NLEN-1] &= TMASK + b.w[0] += carry + + ix := 224/int(BASEBITS) + b.w[ix] += carry << (224 % BASEBITS) + b.norm() + return b + } + + if MODTYPE == NOT_SPECIAL { + md := NewBIGints(Modulus) + return monty(md, MConst, d) + } + return NewBIG() +} + +// find appoximation to quotient of a/m +// Out by at most 2. +// Note that MAXXES is bounded to be 2-bits less than half a word +func quo(n *BIG, m *BIG) int { + var num Chunk + var den Chunk + hb := uint(CHUNK) / 2 + if TBITS < hb { + sh := hb - TBITS + num = (n.w[NLEN-1] << sh) | (n.w[NLEN-2] >> (BASEBITS - sh)) + den = (m.w[NLEN-1] << sh) | (m.w[NLEN-2] >> (BASEBITS - sh)) + + } else { + num = n.w[NLEN-1] + den = m.w[NLEN-1] + } + return int(num / (den + 1)) +} + +/* reduce this mod Modulus */ +func (F *FP) reduce() { + m := NewBIGints(Modulus) + r := NewBIGints(Modulus) + var sb uint + F.x.norm() + + if F.XES > 16 { + q := quo(F.x, m) + carry := r.pmul(q) + r.w[NLEN-1] += carry << BASEBITS + F.x.sub(r) + F.x.norm() + sb = 2 + } else { + sb = logb2(uint32(F.XES - 1)) + } + + m.fshl(sb) + for sb > 0 { + sr := ssn(r, F.x, m) + F.x.cmove(r, 1-sr) + sb -= 1 + } + + F.XES = 1 +} + +/* test this=0? */ +func (F *FP) iszilch() bool { + W := NewFPcopy(F) + W.reduce() + return W.x.iszilch() +} + +func (F *FP) islarger() int { + if F.iszilch() { + return 0; + } + sx:= NewBIGints(Modulus) + fx:=F.redc(); + sx.sub(fx); sx.norm() + return Comp(fx,sx) +} + +func (F *FP) ToBytes(b []byte) { + F.redc().ToBytes(b) +} + +func FP_fromBytes(b []byte) *FP { + t:=FromBytes(b) + return NewFPbig(t) +} + +func (F *FP) isunity() bool { + W:=NewFPcopy(F) + W.reduce() + return W.redc().isunity() +} + +/* copy from FP b */ +func (F *FP) copy(b *FP) { + F.x.copy(b.x) + F.XES = b.XES +} + +/* set this=0 */ +func (F *FP) zero() { + F.x.zero() + F.XES = 1 +} + +/* set this=1 */ +func (F *FP) one() { + F.x.one() + F.nres() +} + +/* return sign */ +func (F *FP) sign() int { + if BIG_ENDIAN_SIGN { + m := NewBIGints(Modulus) + m.dec(1) + m.fshr(1) + n := NewFPcopy(F); + n.reduce() + w := n.redc() + cp:=Comp(w,m) + return ((cp+1)&2)>>1 + } else { + W:=NewFPcopy(F) + W.reduce() + return W.redc().parity() + } +} + +/* normalise this */ +func (F *FP) norm() { + F.x.norm() +} + +/* swap FPs depending on d */ +func (F *FP) cswap(b *FP, d int) { + c := int32(d) + c = ^(c - 1) + t := c & (F.XES ^ b.XES) + F.XES ^= t + b.XES ^= t + F.x.cswap(b.x, d) +} + +/* copy FPs depending on d */ +func (F *FP) cmove(b *FP, d int) { + F.x.cmove(b.x, d) + c := int32(-d) + F.XES ^= (F.XES ^ b.XES) & c +} + +/* this*=b mod Modulus */ +func (F *FP) mul(b *FP) { + + if int64(F.XES)*int64(b.XES) > int64(FEXCESS) { + F.reduce() + } + + d := mul(F.x, b.x) + F.x.copy(mod(d)) + F.XES = 2 +} + +/* this = -this mod Modulus */ +func (F *FP) neg() { + m := NewBIGints(Modulus) + sb := logb2(uint32(F.XES - 1)) + + m.fshl(sb) + F.x.rsub(m) + + F.XES = (1 << sb) + 1 + if F.XES > FEXCESS { + F.reduce() + } +} + +/* this*=c mod Modulus, where c is a small int */ +func (F *FP) imul(c int) { + // F.norm() + s := false + if c < 0 { + c = -c + s = true + } + + if MODTYPE == PSEUDO_MERSENNE || MODTYPE == GENERALISED_MERSENNE { + d := F.x.pxmul(c) + F.x.copy(mod(d)) + F.XES = 2 + } else { + if F.XES*int32(c) <= FEXCESS { + F.x.pmul(c) + F.XES *= int32(c) + } else { + n := NewFPint(c) + F.mul(n) + } + } + if s { + F.neg() + F.norm() + } +} + +/* this*=this mod Modulus */ +func (F *FP) sqr() { + if int64(F.XES)*int64(F.XES) > int64(FEXCESS) { + F.reduce() + } + d := sqr(F.x) + F.x.copy(mod(d)) + F.XES = 2 +} + +/* this+=b */ +func (F *FP) add(b *FP) { + F.x.add(b.x) + F.XES += b.XES + if F.XES > FEXCESS { + F.reduce() + } +} + +/* this-=b */ +func (F *FP) sub(b *FP) { + n := NewFPcopy(b) + n.neg() + F.add(n) +} + +func (F *FP) rsub(b *FP) { + F.neg() + F.add(b) +} + +/* this/=2 mod Modulus */ +func (F *FP) div2() { + p:=NewBIGints(Modulus) + pr:=F.x.parity() + w:=NewBIGcopy(F.x) + F.x.fshr(1) + w.add(p); w.norm() + w.fshr(1) + F.x.cmove(w,pr) +} + + +/* return jacobi symbol (this/Modulus) */ +func (F *FP) jacobi() int { + w := F.redc() + p := NewBIGints(Modulus) + return w.Jacobi(p) +} + +/* return TRUE if this==a */ +func (F *FP) Equals(a *FP) bool { + f := NewFPcopy(F) + s := NewFPcopy(a) + + s.reduce() + f.reduce() + if Comp(s.x, f.x) == 0 { + return true + } + return false +} + +func (F *FP) pow(e *BIG) *FP { + var tb []*FP + var w [1 + (NLEN*int(BASEBITS)+3)/4]int8 + F.norm() + t := NewBIGcopy(e) + t.norm() + nb := 1 + (t.nbits()+3)/4 + + for i := 0; i < nb; i++ { + lsbs := t.lastbits(4) + t.dec(lsbs) + t.norm() + w[i] = int8(lsbs) + t.fshr(4) + } + tb = append(tb, NewFPint(1)) + tb = append(tb, NewFPcopy(F)) + for i := 2; i < 16; i++ { + tb = append(tb, NewFPcopy(tb[i-1])) + tb[i].mul(F) + } + r := NewFPcopy(tb[w[nb-1]]) + for i := nb - 2; i >= 0; i-- { + r.sqr() + r.sqr() + r.sqr() + r.sqr() + r.mul(tb[w[i]]) + } + r.reduce() + return r +} + +// See https://eprint.iacr.org/2018/1038 +// return this^(p-3)/4 or this^(p-5)/8 +func (F *FP) fpow() *FP { + ac := [11]int{1, 2, 3, 6, 12, 15, 30, 60, 120, 240, 255} + var xp []*FP + // phase 1 + xp = append(xp, NewFPcopy(F)) + xp = append(xp, NewFPcopy(F)) + xp[1].sqr() + xp = append(xp, NewFPcopy(xp[1])) + xp[2].mul(F) + xp = append(xp, NewFPcopy(xp[2])) + xp[3].sqr() + xp = append(xp, NewFPcopy(xp[3])) + xp[4].sqr() + xp = append(xp, NewFPcopy(xp[4])) + xp[5].mul(xp[2]) + xp = append(xp, NewFPcopy(xp[5])) + xp[6].sqr() + xp = append(xp, NewFPcopy(xp[6])) + xp[7].sqr() + xp = append(xp, NewFPcopy(xp[7])) + xp[8].sqr() + xp = append(xp, NewFPcopy(xp[8])) + xp[9].sqr() + xp = append(xp, NewFPcopy(xp[9])) + xp[10].mul(xp[5]) + var n, c int + + e := int(PM1D2) + + n = int(MODBITS) + if MODTYPE == GENERALISED_MERSENNE { // Goldilocks ONLY + n /= 2 + } + + n-=(e+1) + c=(int(MConst)+(1< k { + i-- + } + key.copy(xp[i]) + k -= ac[i] + } + + for k != 0 { + i-- + if ac[i] > k { + continue + } + key.mul(xp[i]) + k -= ac[i] + } + // phase 2 + xp[1].copy(xp[2]) + xp[2].copy(xp[5]) + xp[3].copy(xp[10]) + + j := 3 + m := 8 + nw := n - bw + t := NewFP() + for 2*m < nw { + t.copy(xp[j]) + j++ + for i = 0; i < m; i++ { + t.sqr() + } + xp[j].copy(xp[j-1]) + xp[j].mul(t) + m *= 2 + } + lo := nw - m + r := NewFPcopy(xp[j]) + + for lo != 0 { + m /= 2 + j-- + if lo < m { + continue + } + lo -= m + t.copy(r) + for i = 0; i < m; i++ { + t.sqr() + } + r.copy(t) + r.mul(xp[j]) + } + // phase 3 + if bw != 0 { + for i = 0; i < bw; i++ { + r.sqr() + } + r.mul(key) + } + + if MODTYPE == GENERALISED_MERSENNE { // Goldilocks ONLY + key.copy(r) + r.sqr() + r.mul(F) + for i = 0; i < n+1; i++ { + r.sqr() + } + r.mul(key) + } + for nd>0 { + r.sqr() + nd-- + } + return r +} + +// calculates r=x^(p-1-2^e)/2^{e+1) where 2^e|p-1 +func (F *FP) progen() { + if (MODTYPE == PSEUDO_MERSENNE || MODTYPE == GENERALISED_MERSENNE) { + F.copy(F.fpow()) + return + } + e:=uint(PM1D2) + m := NewBIGints(Modulus) + m.dec(1); + m.shr(e); + m.dec(1); + m.fshr(1); + F.copy(F.pow(m)); +} + +/* this=1/this mod Modulus */ +func (F *FP) inverse(h *FP) { + e:=int(PM1D2) + F.norm() + s:=NewFPcopy(F) + for i:=0;i1;k-- { + for j:=1;j> 31 + babs := (b ^ m) - m + + babs = (babs - 1) / 2 + + F.cmove(g[0], teq(babs, 0)) // conditional move + F.cmove(g[1], teq(babs, 1)) + F.cmove(g[2], teq(babs, 2)) + F.cmove(g[3], teq(babs, 3)) + F.cmove(g[4], teq(babs, 4)) + F.cmove(g[5], teq(babs, 5)) + F.cmove(g[6], teq(babs, 6)) + F.cmove(g[7], teq(babs, 7)) + + invF := NewFP12copy(F) + invF.conj() + F.cmove(invF, int(m&1)) +} + +/* test x==1 ? */ +func (F *FP12) Isunity() bool { + one := NewFP4int(1) + return (F.a.Equals(one) && F.b.iszilch() && F.c.iszilch()) +} + +/* return 1 if x==y, else 0 */ +func (F *FP12) Equals(x *FP12) bool { + return (F.a.Equals(x.a) && F.b.Equals(x.b) && F.c.Equals(x.c)) +} + +/* extract a from this */ +func (F *FP12) geta() *FP4 { + return F.a +} + +/* extract b */ +func (F *FP12) getb() *FP4 { + return F.b +} + +/* extract c */ +func (F *FP12) getc() *FP4 { + return F.c +} + +/* copy this=x */ +func (F *FP12) Copy(x *FP12) { + F.a.copy(x.a) + F.b.copy(x.b) + F.c.copy(x.c) + F.stype = x.stype +} + +/* set this=1 */ +func (F *FP12) one() { + F.a.one() + F.b.zero() + F.c.zero() + F.stype = FP_ONE +} + +/* set this=0 */ +func (F *FP12) zero() { + F.a.zero() + F.b.zero() + F.c.zero() + F.stype = FP_ZERO +} + +/* this=conj(this) */ +func (F *FP12) conj() { + F.a.conj() + F.b.nconj() + F.c.conj() +} + +/* Granger-Scott Unitary Squaring */ +func (F *FP12) usqr() { + A := NewFP4copy(F.a) + B := NewFP4copy(F.c) + C := NewFP4copy(F.b) + D := NewFP4() + + F.a.sqr() + D.copy(F.a) + D.add(F.a) + F.a.add(D) + + F.a.norm() + A.nconj() + + A.add(A) + F.a.add(A) + B.sqr() + B.times_i() + + D.copy(B) + D.add(B) + B.add(D) + B.norm() + + C.sqr() + D.copy(C) + D.add(C) + C.add(D) + C.norm() + + F.b.conj() + F.b.add(F.b) + F.c.nconj() + + F.c.add(F.c) + F.b.add(B) + F.c.add(C) + F.reduce() + F.stype = FP_DENSE + +} + +/* Chung-Hasan SQR2 method from http://cacr.uwaterloo.ca/techreports/2006/cacr2006-24.pdf */ +func (F *FP12) sqr() { + if F.stype == FP_ONE { + return + } + + A := NewFP4copy(F.a) + B := NewFP4copy(F.b) + C := NewFP4copy(F.c) + D := NewFP4copy(F.a) + + A.sqr() + B.mul(F.c) + B.add(B) + B.norm() + C.sqr() + D.mul(F.b) + D.add(D) + + F.c.add(F.a) + F.c.add(F.b) + F.c.norm() + F.c.sqr() + + F.a.copy(A) + + A.add(B) + A.norm() + A.add(C) + A.add(D) + A.norm() + + A.neg() + B.times_i() + C.times_i() + + F.a.add(B) + + F.b.copy(C) + F.b.add(D) + F.c.add(A) + if F.stype == FP_SPARSER || F.stype == FP_SPARSEST { + F.stype = FP_SPARSE + } else { + F.stype = FP_DENSE + } + F.norm() +} + +/* FP12 full multiplication this=this*y */ +func (F *FP12) Mul(y *FP12) { + z0 := NewFP4copy(F.a) + z1 := NewFP4() + z2 := NewFP4copy(F.b) + z3 := NewFP4() + t0 := NewFP4copy(F.a) + t1 := NewFP4copy(y.a) + + z0.mul(y.a) + z2.mul(y.b) + + t0.add(F.b) + t0.norm() + t1.add(y.b) + t1.norm() + + z1.copy(t0) + z1.mul(t1) + t0.copy(F.b) + t0.add(F.c) + t0.norm() + + t1.copy(y.b) + t1.add(y.c) + t1.norm() + z3.copy(t0) + z3.mul(t1) + + t0.copy(z0) + t0.neg() + t1.copy(z2) + t1.neg() + + z1.add(t0) + F.b.copy(z1) + F.b.add(t1) + + z3.add(t1) + z2.add(t0) + + t0.copy(F.a) + t0.add(F.c) + t0.norm() + t1.copy(y.a) + t1.add(y.c) + t1.norm() + t0.mul(t1) + z2.add(t0) + + t0.copy(F.c) + t0.mul(y.c) + t1.copy(t0) + t1.neg() + + F.c.copy(z2) + F.c.add(t1) + z3.add(t1) + t0.times_i() + F.b.add(t0) + z3.norm() + z3.times_i() + F.a.copy(z0) + F.a.add(z3) + F.stype = FP_DENSE + F.norm() +} + +/* FP12 full multiplication w=w*y */ +/* Supports sparse multiplicands */ +/* Usually w is denser than y */ +func (F *FP12) ssmul(y *FP12) { + if F.stype == FP_ONE { + F.Copy(y) + return + } + if y.stype == FP_ONE { + return + } + if y.stype >= FP_SPARSE { + z0 := NewFP4copy(F.a) + z1 := NewFP4() + z2 := NewFP4() + z3 := NewFP4() + z0.mul(y.a) + + if SEXTIC_TWIST == M_TYPE { + if y.stype == FP_SPARSE || F.stype == FP_SPARSE { + z2.getb().copy(F.b.getb()) + z2.getb().mul(y.b.getb()) + z2.geta().zero() + if y.stype != FP_SPARSE { + z2.geta().copy(F.b.getb()) + z2.geta().mul(y.b.geta()) + } + if F.stype != FP_SPARSE { + z2.geta().copy(F.b.geta()) + z2.geta().mul(y.b.getb()) + } + z2.times_i() + } else { + z2.copy(F.b) + z2.mul(y.b) + } + } else { + z2.copy(F.b) + z2.mul(y.b) + } + t0 := NewFP4copy(F.a) + t1 := NewFP4copy(y.a) + t0.add(F.b) + t0.norm() + t1.add(y.b) + t1.norm() + + z1.copy(t0) + z1.mul(t1) + t0.copy(F.b) + t0.add(F.c) + t0.norm() + t1.copy(y.b) + t1.add(y.c) + t1.norm() + + z3.copy(t0) + z3.mul(t1) + + t0.copy(z0) + t0.neg() + t1.copy(z2) + t1.neg() + + z1.add(t0) + F.b.copy(z1) + F.b.add(t1) + + z3.add(t1) + z2.add(t0) + + t0.copy(F.a) + t0.add(F.c) + t0.norm() + t1.copy(y.a) + t1.add(y.c) + t1.norm() + + t0.mul(t1) + z2.add(t0) + + if SEXTIC_TWIST == D_TYPE { + if y.stype == FP_SPARSE || F.stype == FP_SPARSE { + t0.geta().copy(F.c.geta()) + t0.geta().mul(y.c.geta()) + t0.getb().zero() + if y.stype != FP_SPARSE { + t0.getb().copy(F.c.geta()) + t0.getb().mul(y.c.getb()) + } + if F.stype != FP_SPARSE { + t0.getb().copy(F.c.getb()) + t0.getb().mul(y.c.geta()) + } + } else { + t0.copy(F.c) + t0.mul(y.c) + } + } else { + t0.copy(F.c) + t0.mul(y.c) + } + t1.copy(t0) + t1.neg() + + F.c.copy(z2) + F.c.add(t1) + z3.add(t1) + t0.times_i() + F.b.add(t0) + z3.norm() + z3.times_i() + F.a.copy(z0) + F.a.add(z3) + } else { + if F.stype == FP_SPARSER || F.stype == FP_SPARSEST { + F.smul(y) + return + } + if SEXTIC_TWIST == D_TYPE { // dense by sparser - 13m + z0 := NewFP4copy(F.a) + z2 := NewFP4copy(F.b) + z3 := NewFP4copy(F.b) + t0 := NewFP4() + t1 := NewFP4copy(y.a) + z0.mul(y.a) + + if y.stype == FP_SPARSEST { + z2.qmul(y.b.a.a) + } else { + z2.pmul(y.b.a) + } + F.b.add(F.a) + t1.geta().add(y.b.geta()) + + t1.norm() + F.b.norm() + F.b.mul(t1) + z3.add(F.c) + z3.norm() + + if y.stype == FP_SPARSEST { + z3.qmul(y.b.a.a) + } else { + z3.pmul(y.b.a) + } + + t0.copy(z0) + t0.neg() + t1.copy(z2) + t1.neg() + + F.b.add(t0) + + F.b.add(t1) + z3.add(t1) + z2.add(t0) + + t0.copy(F.a) + t0.add(F.c) + t0.norm() + z3.norm() + t0.mul(y.a) + F.c.copy(z2) + F.c.add(t0) + + z3.times_i() + F.a.copy(z0) + F.a.add(z3) + } + if SEXTIC_TWIST == M_TYPE { + z0 := NewFP4copy(F.a) + z1 := NewFP4() + z2 := NewFP4() + z3 := NewFP4() + t0 := NewFP4copy(F.a) + t1 := NewFP4() + + z0.mul(y.a) + t0.add(F.b) + t0.norm() + + z1.copy(t0) + z1.mul(y.a) + t0.copy(F.b) + t0.add(F.c) + t0.norm() + + z3.copy(t0) + + if y.stype == FP_SPARSEST { + z3.qmul(y.c.b.a) + } else { + z3.pmul(y.c.b) + } + z3.times_i() + + t0.copy(z0) + t0.neg() + z1.add(t0) + F.b.copy(z1) + z2.copy(t0) + + t0.copy(F.a) + t0.add(F.c) + t0.norm() + t1.copy(y.a) + t1.add(y.c) + t1.norm() + + t0.mul(t1) + z2.add(t0) + t0.copy(F.c) + + if y.stype == FP_SPARSEST { + t0.qmul(y.c.b.a) + } else { + t0.pmul(y.c.b) + } + t0.times_i() + t1.copy(t0) + t1.neg() + + F.c.copy(z2) + F.c.add(t1) + z3.add(t1) + t0.times_i() + F.b.add(t0) + z3.norm() + z3.times_i() + F.a.copy(z0) + F.a.add(z3) + } + } + F.stype = FP_DENSE + F.norm() +} + +/* Special case of multiplication arises from special form of ATE pairing line function */ +/* F and y are both sparser or sparsest line functions - cost <= 6m */ +func (F *FP12) smul(y *FP12) { + if SEXTIC_TWIST == D_TYPE { + w1 := NewFP2copy(F.a.geta()) + w2 := NewFP2copy(F.a.getb()) + var w3 *FP2 + + w1.mul(y.a.geta()) + w2.mul(y.a.getb()) + + if y.stype == FP_SPARSEST || F.stype == FP_SPARSEST { + if y.stype == FP_SPARSEST && F.stype == FP_SPARSEST { + t := NewFPcopy(F.b.a.a) + t.mul(y.b.a.a) + w3 = NewFP2fp(t) + } else { + if y.stype != FP_SPARSEST { + w3 = NewFP2copy(y.b.geta()) + w3.pmul(F.b.a.a) + } else { + w3 = NewFP2copy(F.b.geta()) + w3.pmul(y.b.a.a) + } + } + } else { + w3 = NewFP2copy(F.b.geta()) + w3.mul(y.b.geta()) + } + + ta := NewFP2copy(F.a.geta()) + tb := NewFP2copy(y.a.geta()) + ta.add(F.a.getb()) + ta.norm() + tb.add(y.a.getb()) + tb.norm() + tc := NewFP2copy(ta) + tc.mul(tb) + t := NewFP2copy(w1) + t.add(w2) + t.neg() + tc.add(t) + + ta.copy(F.a.geta()) + ta.add(F.b.geta()) + ta.norm() + tb.copy(y.a.geta()) + tb.add(y.b.geta()) + tb.norm() + td := NewFP2copy(ta) + td.mul(tb) + t.copy(w1) + t.add(w3) + t.neg() + td.add(t) + + ta.copy(F.a.getb()) + ta.add(F.b.geta()) + ta.norm() + tb.copy(y.a.getb()) + tb.add(y.b.geta()) + tb.norm() + te := NewFP2copy(ta) + te.mul(tb) + t.copy(w2) + t.add(w3) + t.neg() + te.add(t) + + w2.mul_ip() + w1.add(w2) + + F.a.geta().copy(w1) + F.a.getb().copy(tc) + F.b.geta().copy(td) + F.b.getb().copy(te) + F.c.geta().copy(w3) + F.c.getb().zero() + + F.a.norm() + F.b.norm() + } else { + w1 := NewFP2copy(F.a.geta()) + w2 := NewFP2copy(F.a.getb()) + var w3 *FP2 + + w1.mul(y.a.geta()) + w2.mul(y.a.getb()) + + if y.stype == FP_SPARSEST || F.stype == FP_SPARSEST { + if y.stype == FP_SPARSEST && F.stype == FP_SPARSEST { + t := NewFPcopy(F.c.b.a) + t.mul(y.c.b.a) + w3 = NewFP2fp(t) + } else { + if y.stype != FP_SPARSEST { + w3 = NewFP2copy(y.c.getb()) + w3.pmul(F.c.b.a) + } else { + w3 = NewFP2copy(F.c.getb()) + w3.pmul(y.c.b.a) + } + } + } else { + w3 = NewFP2copy(F.c.getb()) + w3.mul(y.c.getb()) + } + + ta := NewFP2copy(F.a.geta()) + tb := NewFP2copy(y.a.geta()) + ta.add(F.a.getb()) + ta.norm() + tb.add(y.a.getb()) + tb.norm() + tc := NewFP2copy(ta) + tc.mul(tb) + t := NewFP2copy(w1) + t.add(w2) + t.neg() + tc.add(t) + + ta.copy(F.a.geta()) + ta.add(F.c.getb()) + ta.norm() + tb.copy(y.a.geta()) + tb.add(y.c.getb()) + tb.norm() + td := NewFP2copy(ta) + td.mul(tb) + t.copy(w1) + t.add(w3) + t.neg() + td.add(t) + + ta.copy(F.a.getb()) + ta.add(F.c.getb()) + ta.norm() + tb.copy(y.a.getb()) + tb.add(y.c.getb()) + tb.norm() + te := NewFP2copy(ta) + te.mul(tb) + t.copy(w2) + t.add(w3) + t.neg() + te.add(t) + + w2.mul_ip() + w1.add(w2) + F.a.geta().copy(w1) + F.a.getb().copy(tc) + + w3.mul_ip() + w3.norm() + F.b.geta().zero() + F.b.getb().copy(w3) + + te.norm() + te.mul_ip() + F.c.geta().copy(te) + F.c.getb().copy(td) + + F.a.norm() + F.c.norm() + + } + F.stype = FP_SPARSE +} + +/* this=1/this */ +func (F *FP12) Inverse() { + f0 := NewFP4copy(F.a) + f1 := NewFP4copy(F.b) + f2 := NewFP4copy(F.a) + f3 := NewFP4() + + F.norm() + f0.sqr() + f1.mul(F.c) + f1.times_i() + f0.sub(f1) + f0.norm() + + f1.copy(F.c) + f1.sqr() + f1.times_i() + f2.mul(F.b) + f1.sub(f2) + f1.norm() + + f2.copy(F.b) + f2.sqr() + f3.copy(F.a) + f3.mul(F.c) + f2.sub(f3) + f2.norm() + + f3.copy(F.b) + f3.mul(f2) + f3.times_i() + F.a.mul(f0) + f3.add(F.a) + F.c.mul(f1) + F.c.times_i() + + f3.add(F.c) + f3.norm() + f3.inverse(nil) + F.a.copy(f0) + F.a.mul(f3) + F.b.copy(f1) + F.b.mul(f3) + F.c.copy(f2) + F.c.mul(f3) + F.stype = FP_DENSE +} + +/* this=this^p using Frobenius */ +func (F *FP12) frob(f *FP2) { + f2 := NewFP2copy(f) + f3 := NewFP2copy(f) + + f2.sqr() + f3.mul(f2) + + F.a.frob(f3) + F.b.frob(f3) + F.c.frob(f3) + + F.b.pmul(f) + F.c.pmul(f2) + F.stype = FP_DENSE +} + +/* trace function */ +func (F *FP12) trace() *FP4 { + t := NewFP4() + t.copy(F.a) + t.imul(3) + t.reduce() + return t +} + +/* convert from byte array to FP12 */ +func FP12_fromBytes(w []byte) *FP12 { + var t [4*int(MODBYTES)]byte + MB := 4*int(MODBYTES) + + for i:=0;i= 1; i-- { + w.usqr() + bt := e3.bit(i) - e1.bit(i) + if bt == 1 { + w.Mul(sf) + } + if bt == -1 { + sf.conj() + w.Mul(sf) + sf.conj() + } + } + w.reduce() + return w +} + +/* constant time powering by small integer of max length bts */ +func (F *FP12) pinpow(e int, bts int) { + var R []*FP12 + R = append(R, NewFP12int(1)) + R = append(R, NewFP12copy(F)) + + for i := bts - 1; i >= 0; i-- { + b := (e >> uint(i)) & 1 + R[1-b].Mul(R[b]) + R[b].usqr() + } + F.Copy(R[0]) +} + +/* Fast compressed FP4 power of unitary FP12 */ +func (F *FP12) Compow(e *BIG, r *BIG) *FP4 { + q := NewBIGints(Modulus) + f := NewFP2bigs(NewBIGints(Fra), NewBIGints(Frb)) + + m := NewBIGcopy(q) + m.Mod(r) + + a := NewBIGcopy(e) + a.Mod(m) + + b := NewBIGcopy(e) + b.div(m) + + g1 := NewFP12copy(F) + c := g1.trace() + + if b.iszilch() { + c = c.xtr_pow(e) + return c + } + + g2 := NewFP12copy(F) + g2.frob(f) + cp := g2.trace() + + g1.conj() + g2.Mul(g1) + cpm1 := g2.trace() + g2.Mul(g1) + cpm2 := g2.trace() + + c = c.xtr_pow2(cp, cpm1, cpm2, a, b) + return c +} + +/* p=q0^u0.q1^u1.q2^u2.q3^u3 */ +// Bos & Costello https://eprint.iacr.org/2013/458.pdf +// Faz-Hernandez & Longa & Sanchez https://eprint.iacr.org/2013/158.pdf +// Side channel attack secure + +func pow4(q []*FP12, u []*BIG) *FP12 { + var g []*FP12 + var w [NLEN*int(BASEBITS) + 1]int8 + var s [NLEN*int(BASEBITS) + 1]int8 + var t []*BIG + r := NewFP12() + p := NewFP12() + mt := NewBIGint(0) + + for i := 0; i < 4; i++ { + t = append(t, NewBIGcopy(u[i])) + } + + g = append(g, NewFP12copy(q[0])) // q[0] + g = append(g, NewFP12copy(g[0])) + g[1].Mul(q[1]) // q[0].q[1] + g = append(g, NewFP12copy(g[0])) + g[2].Mul(q[2]) // q[0].q[2] + g = append(g, NewFP12copy(g[1])) + g[3].Mul(q[2]) // q[0].q[1].q[2] + g = append(g, NewFP12copy(g[0])) + g[4].Mul(q[3]) // q[0].q[3] + g = append(g, NewFP12copy(g[1])) + g[5].Mul(q[3]) // q[0].q[1].q[3] + g = append(g, NewFP12copy(g[2])) + g[6].Mul(q[3]) // q[0].q[2].q[3] + g = append(g, NewFP12copy(g[3])) + g[7].Mul(q[3]) // q[0].q[1].q[2].q[3] + + // Make it odd + pb := 1 - t[0].parity() + t[0].inc(pb) + // t[0].norm(); + + // Number of bits + mt.zero() + for i := 0; i < 4; i++ { + t[i].norm() + mt.or(t[i]) + } + + nb := 1 + mt.nbits() + + // Sign pivot + s[nb-1] = 1 + for i := 0; i < nb-1; i++ { + t[0].fshr(1) + s[i] = 2*int8(t[0].parity()) - 1 + } + + // Recoded exponent + for i := 0; i < nb; i++ { + w[i] = 0 + k := 1 + for j := 1; j < 4; j++ { + bt := s[i] * int8(t[j].parity()) + t[j].fshr(1) + t[j].dec(int(bt) >> 1) + t[j].norm() + w[i] += bt * int8(k) + k *= 2 + } + } + + // Main loop + p.selector(g, int32(2*w[nb-1]+1)) + for i := nb - 2; i >= 0; i-- { + p.usqr() + r.selector(g, int32(2*w[i]+s[i])) + p.Mul(r) + } + + // apply correction + r.Copy(q[0]) + r.conj() + r.Mul(p) + p.cmove(r, pb) + + p.reduce() + return p +} diff --git a/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/FP2.go b/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/FP2.go new file mode 100644 index 00000000000..9837002749a --- /dev/null +++ b/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/FP2.go @@ -0,0 +1,492 @@ +/* + * Copyright (c) 2012-2020 MIRACL UK Ltd. + * + * This file is part of MIRACL Core + * (see https://github.com/miracl/core). + * + * 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. + */ + +/* Finite Field arithmetic Fp^2 functions */ + +/* FP2 elements are of the form a+ib, where i is sqrt(-1) */ + +package FP256BN +import "github.com/hyperledger/fabric-amcl/core" + + +type FP2 struct { + a *FP + b *FP +} + +func NewFP2() *FP2 { + F := new(FP2) + F.a = NewFP() + F.b = NewFP() + return F +} + +/* Constructors */ +func NewFP2int(a int) *FP2 { + F := new(FP2) + F.a = NewFPint(a) + F.b = NewFP() + return F +} + +func NewFP2ints(a int, b int) *FP2 { + F := new(FP2) + F.a = NewFPint(a) + F.b = NewFPint(b) + return F +} + +func NewFP2copy(x *FP2) *FP2 { + F := new(FP2) + F.a = NewFPcopy(x.a) + F.b = NewFPcopy(x.b) + return F +} + +func NewFP2fps(c *FP, d *FP) *FP2 { + F := new(FP2) + F.a = NewFPcopy(c) + F.b = NewFPcopy(d) + return F +} + +func NewFP2bigs(c *BIG, d *BIG) *FP2 { + F := new(FP2) + F.a = NewFPbig(c) + F.b = NewFPbig(d) + return F +} + +func NewFP2fp(c *FP) *FP2 { + F := new(FP2) + F.a = NewFPcopy(c) + F.b = NewFP() + return F +} + +func NewFP2big(c *BIG) *FP2 { + F := new(FP2) + F.a = NewFPbig(c) + F.b = NewFP() + return F +} + +func NewFP2rand(rng *core.RAND) *FP2 { + F := NewFP2fps(NewFPrand(rng),NewFPrand(rng)) + return F +} + +/* reduce components mod Modulus */ +func (F *FP2) reduce() { + F.a.reduce() + F.b.reduce() +} + +/* normalise components of w */ +func (F *FP2) norm() { + F.a.norm() + F.b.norm() +} + +/* test this=0 ? */ +func (F *FP2) iszilch() bool { + return (F.a.iszilch() && F.b.iszilch()) +} + +func (F *FP2) islarger() int { + if F.iszilch() { + return 0; + } + cmp:=F.b.islarger() + if cmp!=0 { + return cmp + } + return F.a.islarger() +} + +func (F *FP2) ToBytes(bf []byte) { + var t [int(MODBYTES)]byte + MB := int(MODBYTES) + F.b.ToBytes(t[:]); + for i:=0;i int64(FEXCESS) { + if F.a.XES > 1 { + F.a.reduce() + } + if F.b.XES > 1 { + F.b.reduce() + } + } + + pR := NewDBIG() + C := NewBIGcopy(F.a.x) + D := NewBIGcopy(y.a.x) + p := NewBIGints(Modulus) + + pR.ucopy(p) + + A := mul(F.a.x, y.a.x) + B := mul(F.b.x, y.b.x) + + C.add(F.b.x) + C.norm() + D.add(y.b.x) + D.norm() + + E := mul(C, D) + FF := NewDBIGcopy(A) + FF.add(B) + B.rsub(pR) + + A.add(B) + A.norm() + E.sub(FF) + E.norm() + + F.a.x.copy(mod(A)) + F.a.XES = 3 + F.b.x.copy(mod(E)) + F.b.XES = 2 + +} +/* +func (F *FP2) pow(b *BIG) { + w := NewFP2copy(F); + r := NewFP2int(1) + z := NewBIGcopy(b) + for true { + bt := z.parity() + z.shr(1) + if bt==1 { + r.mul(w) + } + if z.iszilch() {break} + w.sqr() + } + r.reduce() + F.copy(r) +} +*/ +func (F *FP2) qr(h *FP) int { + c := NewFP2copy(F) + c.conj() + c.mul(F) + return c.a.qr(h) +} + +/* sqrt(a+ib) = sqrt(a+sqrt(a*a-n*b*b)/2)+ib/(2*sqrt(a+sqrt(a*a-n*b*b)/2)) */ +func (F *FP2) sqrt(h *FP) { + if F.iszilch() { + return + } + w1 := NewFPcopy(F.b) + w2 := NewFPcopy(F.a) + w3 := NewFP() + w4 := NewFP() + hint:=NewFP() + w1.sqr() + w2.sqr() + w1.add(w2); w1.norm() + + w1 = w1.sqrt(h) + w2.copy(F.a) + w3.copy(F.a) + + w2.add(w1) + w2.norm() + w2.div2() + + w1.copy(F.b); w1.div2() + qr:=w2.qr(hint) + +// tweak hint + w3.copy(hint); w3.neg(); w3.norm() + w4.copy(w2); w4.neg(); w4.norm() + + w2.cmove(w4,1-qr) + hint.cmove(w3,1-qr) + + F.a.copy(w2.sqrt(hint)) + w3.copy(w2); w3.inverse(hint) + w3.mul(F.a) + F.b.copy(w3); F.b.mul(w1) + w4.copy(F.a) + + F.a.cmove(F.b,1-qr) + F.b.cmove(w4,1-qr) + +/* + F.a.copy(w2.sqrt(hint)) + w3.copy(w2); w3.inverse(hint) + w3.mul(F.a) + F.b.copy(w3); F.b.mul(w1) + + hint.neg(); hint.norm() + w2.neg(); w2.norm() + + w4.copy(w2.sqrt(hint)) + w3.copy(w2); w3.inverse(hint) + w3.mul(w4) + w3.mul(w1) + + F.a.cmove(w3,1-qr) + F.b.cmove(w4,1-qr) +*/ + + sgn:=F.sign() + nr:=NewFP2copy(F) + nr.neg(); nr.norm() + F.cmove(nr,sgn) +} + +/* output to hex string */ +func (F *FP2) ToString() string { + return ("[" + F.a.ToString() + "," + F.b.ToString() + "]") +} + +/* output to hex string */ +func (F *FP2) toString() string { + return ("[" + F.a.ToString() + "," + F.b.ToString() + "]") +} + +/* this=1/this */ +func (F *FP2) inverse(h *FP) { + F.norm() + w1 := NewFPcopy(F.a) + w2 := NewFPcopy(F.b) + + w1.sqr() + w2.sqr() + w1.add(w2) + w1.inverse(h) + F.a.mul(w1) + w1.neg() + w1.norm() + F.b.mul(w1) +} + +/* this/=2 */ +func (F *FP2) div2() { + F.a.div2() + F.b.div2() +} + +/* this*=sqrt(-1) */ +func (F *FP2) times_i() { + z := NewFPcopy(F.a) + F.a.copy(F.b) + F.a.neg() + F.b.copy(z) +} + +/* w*=(1+sqrt(-1)) */ +/* where X*2-(2^i+sqrt(-1)) is irreducible for FP4 */ +func (F *FP2) mul_ip() { + t := NewFP2copy(F) + i := QNRI + F.times_i() + for i > 0 { + t.add(t) + t.norm() + i-- + } + F.add(t) + + if TOWER == POSITOWER { + F.norm() + F.neg() + } + +} + +/* w/=(2^i+sqrt(-1)) */ +func (F *FP2) div_ip() { + z := NewFP2ints(1<= 0; i-- { + if v.bit(i) != 1 { + t.copy(b) + sf.conj() + c.conj() + b.xtr_A(a, sf, c) + sf.conj() + c.copy(t) + c.xtr_D() + a.xtr_D() + } else { + t.copy(a) + t.conj() + a.copy(b) + a.xtr_D() + b.xtr_A(c, sf, t) + c.xtr_D() + } + } + if par == 0 { + r.copy(c) + } else { + r.copy(b) + } + r.reduce() + return r +} + +/* r=ck^a.cl^n using XTR double exponentiation method on traces of FP12s. See Stam thesis. */ +func (F *FP4) xtr_pow2(ck *FP4, ckml *FP4, ckm2l *FP4, a *BIG, b *BIG) *FP4 { + + e := NewBIGcopy(a) + d := NewBIGcopy(b) + w := NewBIGint(0) + e.norm() + d.norm() + + cu := NewFP4copy(ck) // can probably be passed in w/o copying + cv := NewFP4copy(F) + cumv := NewFP4copy(ckml) + cum2v := NewFP4copy(ckm2l) + r := NewFP4() + t := NewFP4() + + f2 := 0 + for d.parity() == 0 && e.parity() == 0 { + d.fshr(1) + e.fshr(1) + f2++ + } + + for Comp(d, e) != 0 { + if Comp(d, e) > 0 { + w.copy(e) + w.imul(4) + w.norm() + if Comp(d, w) <= 0 { + w.copy(d) + d.copy(e) + e.rsub(w) + e.norm() + + t.copy(cv) + t.xtr_A(cu, cumv, cum2v) + cum2v.copy(cumv) + cum2v.conj() + cumv.copy(cv) + cv.copy(cu) + cu.copy(t) + } else { + if d.parity() == 0 { + d.fshr(1) + r.copy(cum2v) + r.conj() + t.copy(cumv) + t.xtr_A(cu, cv, r) + cum2v.copy(cumv) + cum2v.xtr_D() + cumv.copy(t) + cu.xtr_D() + } else { + if e.parity() == 1 { + d.sub(e) + d.norm() + d.fshr(1) + t.copy(cv) + t.xtr_A(cu, cumv, cum2v) + cu.xtr_D() + cum2v.copy(cv) + cum2v.xtr_D() + cum2v.conj() + cv.copy(t) + } else { + w.copy(d) + d.copy(e) + d.fshr(1) + e.copy(w) + t.copy(cumv) + t.xtr_D() + cumv.copy(cum2v) + cumv.conj() + cum2v.copy(t) + cum2v.conj() + t.copy(cv) + t.xtr_D() + cv.copy(cu) + cu.copy(t) + } + } + } + } + if Comp(d, e) < 0 { + w.copy(d) + w.imul(4) + w.norm() + if Comp(e, w) <= 0 { + e.sub(d) + e.norm() + t.copy(cv) + t.xtr_A(cu, cumv, cum2v) + cum2v.copy(cumv) + cumv.copy(cu) + cu.copy(t) + } else { + if e.parity() == 0 { + w.copy(d) + d.copy(e) + d.fshr(1) + e.copy(w) + t.copy(cumv) + t.xtr_D() + cumv.copy(cum2v) + cumv.conj() + cum2v.copy(t) + cum2v.conj() + t.copy(cv) + t.xtr_D() + cv.copy(cu) + cu.copy(t) + } else { + if d.parity() == 1 { + w.copy(e) + e.copy(d) + w.sub(d) + w.norm() + d.copy(w) + d.fshr(1) + t.copy(cv) + t.xtr_A(cu, cumv, cum2v) + cumv.conj() + cum2v.copy(cu) + cum2v.xtr_D() + cum2v.conj() + cu.copy(cv) + cu.xtr_D() + cv.copy(t) + } else { + d.fshr(1) + r.copy(cum2v) + r.conj() + t.copy(cumv) + t.xtr_A(cu, cv, r) + cum2v.copy(cumv) + cum2v.xtr_D() + cumv.copy(t) + cu.xtr_D() + } + } + } + } + } + r.copy(cv) + r.xtr_A(cu, cumv, cum2v) + for i := 0; i < f2; i++ { + r.xtr_D() + } + r = r.xtr_pow(d) + return r +} + +/* this/=2 */ +func (F *FP4) div2() { + F.a.div2() + F.b.div2() +} + +func (F *FP4) div_i() { + u := NewFP2copy(F.a) + v := NewFP2copy(F.b) + u.div_ip() + F.a.copy(v) + F.b.copy(u) + if TOWER == POSITOWER { + F.neg() + F.norm() + } +} +/* +func (F *FP4) pow(b *BIG) { + w := NewFP4copy(F); + r := NewFP4int(1) + z := NewBIGcopy(b) + for true { + bt := z.parity() + z.shr(1) + if bt==1 { + r.mul(w) + } + if z.iszilch() {break} + w.sqr() + } + r.reduce(); + F.copy(r); +} +*/ + +/* PFGE24S +// Test for Quadratic Residue +func (F *FP4) qr(h *FP) int { + c := NewFP4copy(F) + c.conj() + c.mul(F) + return c.a.qr(h) +} + +// sqrt(a+ib) = sqrt(a+sqrt(a*a-n*b*b)/2)+ib/(2*sqrt(a+sqrt(a*a-n*b*b)/2)) +func (F *FP4) sqrt(h *FP) { + if F.iszilch() { + return + } + + a := NewFP2copy(F.a) + b := NewFP2() + s := NewFP2copy(F.b) + t := NewFP2copy(F.a) + hint := NewFP() + + s.sqr() + a.sqr() + s.mul_ip() + s.norm() + a.sub(s) + + s.copy(a); s.norm() + s.sqrt(h); + + a.copy(t) + b.copy(t) + + a.add(s) + a.norm() + a.div2() + + + b.copy(F.b); b.div2() + qr:=a.qr(hint) + +// tweak hint - multiply old hint by Norm(1/Beta)^e where Beta is irreducible polynomial + s.copy(a) + twk:=NewFPbig(NewBIGints(TWK)) + twk.mul(hint) + s.div_ip(); s.norm() + + a.cmove(s,1-qr) + hint.cmove(twk,1-qr) + + F.a.copy(a); F.a.sqrt(hint) + s.copy(a); s.inverse(hint) + s.mul(F.a) + F.b.copy(s); F.b.mul(b) + t.copy(F.a); + + F.a.cmove(F.b,1-qr); + F.b.cmove(t,1-qr); + + sgn:=F.sign() + nr:=NewFP4copy(F) + nr.neg(); nr.norm() + F.cmove(nr,sgn) +} +PFGE24F */ \ No newline at end of file diff --git a/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/HPKE.go b/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/HPKE.go new file mode 100644 index 00000000000..5b6bf2915d9 --- /dev/null +++ b/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/HPKE.go @@ -0,0 +1,329 @@ +/* + * Copyright (c) 2012-2020 MIRACL UK Ltd. + * + * This file is part of MIRACL Core + * (see https://github.com/miracl/core). + * + * 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. + */ + +/* Hybrid Public Key Encryption */ + +/* Following https://datatracker.ietf.org/doc/draft-irtf-cfrg-hpke/?include_text=1 */ + +package FP256BN + + +import "github.com/hyperledger/fabric-amcl/core" + +func reverse(X []byte) { + lx:=len(X) + for i:=0;i>8)&3 + aead:=(config_id>>10)&3 + + txt := "HPKE" + KEM := []byte(txt) + var SUITE_ID []byte + for i:=0;i= 0; i-- { + r = append(r, NewFP12int(1)) + } + return r +} + +/* basic Miller loop */ +func Miller(r []*FP12) *FP12 { + res := NewFP12int(1) + for i := ATE_BITS - 1; i >= 1; i-- { + res.sqr() + res.ssmul(r[i]) + r[i].zero() + } + + if SIGN_OF_X == NEGATIVEX { + res.conj() + } + res.ssmul(r[0]) + r[0].zero() + return res +} + +// Store precomputed line details in an FP4 +func pack(AA *FP2, BB *FP2, CC *FP2) *FP4 { + i := NewFP2copy(CC) + i.inverse(nil) + a := NewFP2copy(AA) + a.mul(i) + b := NewFP2copy(BB) + b.mul(i) + return NewFP4fp2s(a, b) +} + +// Unpack G2 line function details and include G1 +func unpack(T *FP4, Qx *FP, Qy *FP) *FP12 { + var a *FP4 + var b *FP4 + var c *FP4 + + a = NewFP4copy(T) + a.geta().pmul(Qy) + t := NewFP2fp(Qx) + if SEXTIC_TWIST == D_TYPE { + b = NewFP4fp2(t) + c = NewFP4() + } + if SEXTIC_TWIST == M_TYPE { + b = NewFP4() + c = NewFP4fp2(t) + c.times_i() + } + v := NewFP12fp4s(a, b, c) + v.stype = FP_SPARSEST + return v +} + +func precomp(GV *ECP2) []*FP4 { + var f *FP2 + n := NewBIG() + n3 := NewBIG() + K := NewECP2() + AA := NewFP2() + BB := NewFP2() + CC := NewFP2() + var bt int + P := NewECP2() + P.Copy(GV) + + if CURVE_PAIRING_TYPE == BN { + f = NewFP2bigs(NewBIGints(Fra), NewBIGints(Frb)) + if SEXTIC_TWIST == M_TYPE { + f.inverse(nil) + f.norm() + } + } + A := NewECP2() + A.Copy(P) + MP := NewECP2() + MP.Copy(P) + MP.neg() + + nb := lbits(n3, n) + var T []*FP4 + + for i := nb - 2; i >= 1; i-- { + dbl(A, AA, BB, CC) + T = append(T, pack(AA, BB, CC)) + bt = n3.bit(i) - n.bit(i) + if bt == 1 { + add(A, P, AA, BB, CC) + T = append(T, pack(AA, BB, CC)) + } + if bt == -1 { + add(A, MP, AA, BB, CC) + T = append(T, pack(AA, BB, CC)) + } + } + if CURVE_PAIRING_TYPE == BN { + if SIGN_OF_X == NEGATIVEX { + A.neg() + } + K.Copy(P) + K.frob(f) + add(A, K, AA, BB, CC) + T = append(T, pack(AA, BB, CC)) + K.frob(f) + K.neg() + add(A, K, AA, BB, CC) + T = append(T, pack(AA, BB, CC)) + } + return T +} + +/* Accumulate another set of line functions for n-pairing, assuming precomputation on G2 */ +func Another_pc(r []*FP12, T []*FP4, QV *ECP) { + n := NewBIG() + n3 := NewBIG() + var lv, lv2 *FP12 + var bt, j int + + if QV.Is_infinity() { + return + } + + Q := NewECP() + Q.Copy(QV) + Q.Affine() + Qx := NewFPcopy(Q.getx()) + Qy := NewFPcopy(Q.gety()) + + nb := lbits(n3, n) + j = 0 + for i := nb - 2; i >= 1; i-- { + lv = unpack(T[j], Qx, Qy) + j += 1 + bt = n3.bit(i) - n.bit(i) + if bt == 1 { + lv2 = unpack(T[j], Qx, Qy) + j += 1 + lv.smul(lv2) + } + if bt == -1 { + lv2 = unpack(T[j], Qx, Qy) + j += 1 + lv.smul(lv2) + } + r[i].ssmul(lv) + } + if CURVE_PAIRING_TYPE == BN { + lv = unpack(T[j], Qx, Qy) + j += 1 + lv2 = unpack(T[j], Qx, Qy) + j += 1 + lv.smul(lv2) + r[0].ssmul(lv) + } +} + +/* Accumulate another set of line functions for n-pairing */ +func Another(r []*FP12, P1 *ECP2, Q1 *ECP) { + f := NewFP2bigs(NewBIGints(Fra), NewBIGints(Frb)) + n := NewBIG() + n3 := NewBIG() + K := NewECP2() + var lv, lv2 *FP12 + + if Q1.Is_infinity() { + return + } + + // P is needed in affine form for line function, Q for (Qx,Qy) extraction + P := NewECP2() + P.Copy(P1) + Q := NewECP() + Q.Copy(Q1) + + P.Affine() + Q.Affine() + + if CURVE_PAIRING_TYPE == BN { + if SEXTIC_TWIST == M_TYPE { + f.inverse(nil) + f.norm() + } + } + + Qx := NewFPcopy(Q.getx()) + Qy := NewFPcopy(Q.gety()) + + A := NewECP2() + A.Copy(P) + + MP := NewECP2() + MP.Copy(P) + MP.neg() + + nb := lbits(n3, n) + + for i := nb - 2; i >= 1; i-- { + lv = line(A, A, Qx, Qy) + + bt := n3.bit(i) - n.bit(i) + if bt == 1 { + lv2 = line(A, P, Qx, Qy) + lv.smul(lv2) + } + if bt == -1 { + lv2 = line(A, MP, Qx, Qy) + lv.smul(lv2) + } + r[i].ssmul(lv) + } + + /* R-ate fixup required for BN curves */ + if CURVE_PAIRING_TYPE == BN { + if SIGN_OF_X == NEGATIVEX { + A.neg() + } + K.Copy(P) + K.frob(f) + lv = line(A, K, Qx, Qy) + K.frob(f) + K.neg() + lv2 = line(A, K, Qx, Qy) + lv.smul(lv2) + r[0].ssmul(lv) + } +} + +/* Optimal R-ate pairing */ +func Ate(P1 *ECP2, Q1 *ECP) *FP12 { + f := NewFP2bigs(NewBIGints(Fra), NewBIGints(Frb)) + n := NewBIG() + n3 := NewBIG() + K := NewECP2() + var lv, lv2 *FP12 + + if Q1.Is_infinity() { + return NewFP12int(1) + } + + if CURVE_PAIRING_TYPE == BN { + if SEXTIC_TWIST == M_TYPE { + f.inverse(nil) + f.norm() + } + } + + P := NewECP2() + P.Copy(P1) + P.Affine() + Q := NewECP() + Q.Copy(Q1) + Q.Affine() + + Qx := NewFPcopy(Q.getx()) + Qy := NewFPcopy(Q.gety()) + + A := NewECP2() + r := NewFP12int(1) + + A.Copy(P) + + NP := NewECP2() + NP.Copy(P) + NP.neg() + + nb := lbits(n3, n) + + for i := nb - 2; i >= 1; i-- { + r.sqr() + lv = line(A, A, Qx, Qy) + bt := n3.bit(i) - n.bit(i) + if bt == 1 { + lv2 = line(A, P, Qx, Qy) + lv.smul(lv2) + } + if bt == -1 { + lv2 = line(A, NP, Qx, Qy) + lv.smul(lv2) + } + r.ssmul(lv) + } + + if SIGN_OF_X == NEGATIVEX { + r.conj() + } + + /* R-ate fixup required for BN curves */ + + if CURVE_PAIRING_TYPE == BN { + if SIGN_OF_X == NEGATIVEX { + A.neg() + } + + K.Copy(P) + K.frob(f) + lv = line(A, K, Qx, Qy) + K.frob(f) + K.neg() + lv2 = line(A, K, Qx, Qy) + lv.smul(lv2) + r.ssmul(lv) + } + + return r +} + +/* Optimal R-ate double pairing e(P,Q).e(R,S) */ +func Ate2(P1 *ECP2, Q1 *ECP, R1 *ECP2, S1 *ECP) *FP12 { + f := NewFP2bigs(NewBIGints(Fra), NewBIGints(Frb)) + n := NewBIG() + n3 := NewBIG() + K := NewECP2() + var lv, lv2 *FP12 + + if Q1.Is_infinity() { + return Ate(R1, S1) + } + if S1.Is_infinity() { + return Ate(P1, Q1) + } + if CURVE_PAIRING_TYPE == BN { + if SEXTIC_TWIST == M_TYPE { + f.inverse(nil) + f.norm() + } + } + + P := NewECP2() + P.Copy(P1) + P.Affine() + Q := NewECP() + Q.Copy(Q1) + Q.Affine() + R := NewECP2() + R.Copy(R1) + R.Affine() + S := NewECP() + S.Copy(S1) + S.Affine() + + Qx := NewFPcopy(Q.getx()) + Qy := NewFPcopy(Q.gety()) + Sx := NewFPcopy(S.getx()) + Sy := NewFPcopy(S.gety()) + + A := NewECP2() + B := NewECP2() + r := NewFP12int(1) + + A.Copy(P) + B.Copy(R) + NP := NewECP2() + NP.Copy(P) + NP.neg() + NR := NewECP2() + NR.Copy(R) + NR.neg() + + nb := lbits(n3, n) + + for i := nb - 2; i >= 1; i-- { + r.sqr() + lv = line(A, A, Qx, Qy) + lv2 = line(B, B, Sx, Sy) + lv.smul(lv2) + r.ssmul(lv) + bt := n3.bit(i) - n.bit(i) + if bt == 1 { + lv = line(A, P, Qx, Qy) + lv2 = line(B, R, Sx, Sy) + lv.smul(lv2) + r.ssmul(lv) + } + if bt == -1 { + lv = line(A, NP, Qx, Qy) + lv2 = line(B, NR, Sx, Sy) + lv.smul(lv2) + r.ssmul(lv) + } + } + + if SIGN_OF_X == NEGATIVEX { + r.conj() + } + + /* R-ate fixup */ + if CURVE_PAIRING_TYPE == BN { + if SIGN_OF_X == NEGATIVEX { + A.neg() + B.neg() + } + K.Copy(P) + K.frob(f) + + lv = line(A, K, Qx, Qy) + K.frob(f) + K.neg() + lv2 = line(A, K, Qx, Qy) + lv.smul(lv2) + r.ssmul(lv) + K.Copy(R) + K.frob(f) + lv = line(B, K, Sx, Sy) + K.frob(f) + K.neg() + lv2 = line(B, K, Sx, Sy) + lv.smul(lv2) + r.ssmul(lv) + } + + return r +} + +/* final exponentiation - keep separate for multi-pairings and to avoid thrashing stack */ +func Fexp(m *FP12) *FP12 { + f := NewFP2bigs(NewBIGints(Fra), NewBIGints(Frb)) + x := NewBIGints(CURVE_Bnx) + r := NewFP12copy(m) + + /* Easy part of final exp */ + lv := NewFP12copy(r) + lv.Inverse() + r.conj() + + r.Mul(lv) + lv.Copy(r) + r.frob(f) + r.frob(f) + r.Mul(lv) + + /* Hard part of final exp */ + if CURVE_PAIRING_TYPE == BN { + lv.Copy(r) + lv.frob(f) + x0 := NewFP12copy(lv) + x0.frob(f) + lv.Mul(r) + x0.Mul(lv) + x0.frob(f) + x1 := NewFP12copy(r) + x1.conj() + x4 := r.Pow(x) + if SIGN_OF_X == POSITIVEX { + x4.conj() + } + + x3 := NewFP12copy(x4) + x3.frob(f) + + x2 := x4.Pow(x) + if SIGN_OF_X == POSITIVEX { + x2.conj() + } + + x5 := NewFP12copy(x2) + x5.conj() + lv = x2.Pow(x) + if SIGN_OF_X == POSITIVEX { + lv.conj() + } + + x2.frob(f) + r.Copy(x2) + r.conj() + + x4.Mul(r) + x2.frob(f) + + r.Copy(lv) + r.frob(f) + lv.Mul(r) + + lv.usqr() + lv.Mul(x4) + lv.Mul(x5) + r.Copy(x3) + r.Mul(x5) + r.Mul(lv) + lv.Mul(x2) + r.usqr() + r.Mul(lv) + r.usqr() + lv.Copy(r) + lv.Mul(x1) + r.Mul(x0) + lv.usqr() + r.Mul(lv) + r.reduce() + } else { + +// See https://eprint.iacr.org/2020/875.pdf + y1:=NewFP12copy(r) + y1.usqr() + y1.Mul(r) // y1=r^3 + + y0:=NewFP12copy(r.Pow(x)) + if SIGN_OF_X == NEGATIVEX { + y0.conj() + } + t0:=NewFP12copy(r); t0.conj() + r.Copy(y0) + r.Mul(t0) + + y0.Copy(r.Pow(x)) + if SIGN_OF_X == NEGATIVEX { + y0.conj() + } + t0.Copy(r); t0.conj() + r.Copy(y0) + r.Mul(t0) + +// ^(x+p) + y0.Copy(r.Pow(x)); + if SIGN_OF_X == NEGATIVEX { + y0.conj() + } + t0.Copy(r) + t0.frob(f) + r.Copy(y0) + r.Mul(t0); + +// ^(x^2+p^2-1) + y0.Copy(r.Pow(x)) + y0.Copy(y0.Pow(x)) + t0.Copy(r) + t0.frob(f); t0.frob(f) + y0.Mul(t0) + t0.Copy(r); t0.conj() + r.Copy(y0) + r.Mul(t0) + + r.Mul(y1) + r.reduce(); + +/* + // Ghamman & Fouotsa Method + y0 := NewFP12copy(r) + y0.usqr() + y1 := y0.Pow(x) + if SIGN_OF_X == NEGATIVEX { + y1.conj() + } + + x.fshr(1) + y2 := y1.Pow(x) + if SIGN_OF_X == NEGATIVEX { + y2.conj() + } + + x.fshl(1) + y3 := NewFP12copy(r) + y3.conj() + y1.Mul(y3) + + y1.conj() + y1.Mul(y2) + + y2 = y1.Pow(x) + if SIGN_OF_X == NEGATIVEX { + y2.conj() + } + + y3 = y2.Pow(x) + if SIGN_OF_X == NEGATIVEX { + y3.conj() + } + + y1.conj() + y3.Mul(y1) + + y1.conj() + y1.frob(f) + y1.frob(f) + y1.frob(f) + y2.frob(f) + y2.frob(f) + y1.Mul(y2) + + y2 = y3.Pow(x) + if SIGN_OF_X == NEGATIVEX { + y2.conj() + } + + y2.Mul(y0) + y2.Mul(r) + + y1.Mul(y2) + y2.Copy(y3) + y2.frob(f) + y1.Mul(y2) + r.Copy(y1) + r.reduce() +*/ + } + return r +} + +/* GLV method */ +func glv(e *BIG) []*BIG { + var u []*BIG + if CURVE_PAIRING_TYPE == BN { +/* */ + t := NewBIGint(0) + q := NewBIGints(CURVE_Order) + var v []*BIG + + for i := 0; i < 2; i++ { + t.copy(NewBIGints(CURVE_W[i])) // why not just t=new BIG(ROM.CURVE_W[i]); + d := mul(t, e) + v = append(v, NewBIGcopy(d.div(q))) + u = append(u, NewBIGint(0)) + } + u[0].copy(e) + for i := 0; i < 2; i++ { + for j := 0; j < 2; j++ { + t.copy(NewBIGints(CURVE_SB[j][i])) + t.copy(Modmul(v[j], t, q)) + u[i].add(q) + u[i].sub(t) + u[i].Mod(q) + } + } +/* */ + } else { + q := NewBIGints(CURVE_Order) + x := NewBIGints(CURVE_Bnx) + x2 := smul(x, x) + u = append(u, NewBIGcopy(e)) + u[0].Mod(x2) + u = append(u, NewBIGcopy(e)) + u[1].div(x2) + u[1].rsub(q) + } + return u +} + +/* Galbraith & Scott Method */ +func gs(e *BIG) []*BIG { + var u []*BIG + if CURVE_PAIRING_TYPE == BN { +/* */ + t := NewBIGint(0) + q := NewBIGints(CURVE_Order) + + var v []*BIG + for i := 0; i < 4; i++ { + t.copy(NewBIGints(CURVE_WB[i])) + d := mul(t, e) + v = append(v, NewBIGcopy(d.div(q))) + u = append(u, NewBIGint(0)) + } + u[0].copy(e) + for i := 0; i < 4; i++ { + for j := 0; j < 4; j++ { + t.copy(NewBIGints(CURVE_BB[j][i])) + t.copy(Modmul(v[j], t, q)) + u[i].add(q) + u[i].sub(t) + u[i].Mod(q) + } + } +/* */ + } else { + q := NewBIGints(CURVE_Order) + x := NewBIGints(CURVE_Bnx) + w := NewBIGcopy(e) + for i := 0; i < 3; i++ { + u = append(u, NewBIGcopy(w)) + u[i].Mod(x) + w.div(x) + } + u = append(u, NewBIGcopy(w)) + if SIGN_OF_X == NEGATIVEX { + u[1].copy(Modneg(u[1], q)) + u[3].copy(Modneg(u[3], q)) + } + } + return u +} + +/* Multiply P by e in group G1 */ +func G1mul(P *ECP, e *BIG) *ECP { + var R *ECP + if USE_GLV { + R = NewECP() + R.Copy(P) + Q := NewECP() + Q.Copy(P) + Q.Affine() + q := NewBIGints(CURVE_Order) + cru := NewFPbig(NewBIGints(CRu)) + t := NewBIGint(0) + u := glv(e) + Q.getx().mul(cru) + + np := u[0].nbits() + t.copy(Modneg(u[0], q)) + nn := t.nbits() + if nn < np { + u[0].copy(t) + R.Neg() + } + + np = u[1].nbits() + t.copy(Modneg(u[1], q)) + nn = t.nbits() + if nn < np { + u[1].copy(t) + Q.Neg() + } + u[0].norm() + u[1].norm() + R = R.Mul2(u[0], Q, u[1]) + + } else { + R = P.mul(e) + } + return R +} + +/* Multiply P by e in group G2 */ +func G2mul(P *ECP2, e *BIG) *ECP2 { + var R *ECP2 + if USE_GS_G2 { + var Q []*ECP2 + f := NewFP2bigs(NewBIGints(Fra), NewBIGints(Frb)) + + if SEXTIC_TWIST == M_TYPE { + f.inverse(nil) + f.norm() + } + + q := NewBIGints(CURVE_Order) + u := gs(e) + + t := NewBIGint(0) + Q = append(Q, NewECP2()) + Q[0].Copy(P) + for i := 1; i < 4; i++ { + Q = append(Q, NewECP2()) + Q[i].Copy(Q[i-1]) + Q[i].frob(f) + } + for i := 0; i < 4; i++ { + np := u[i].nbits() + t.copy(Modneg(u[i], q)) + nn := t.nbits() + if nn < np { + u[i].copy(t) + Q[i].neg() + } + u[i].norm() + } + + R = mul4(Q, u) + + } else { + R = P.mul(e) + } + return R +} + +/* f=f^e */ +/* Note that this method requires a lot of RAM! Better to use compressed XTR method, see FP4.java */ +func GTpow(d *FP12, e *BIG) *FP12 { + var r *FP12 + if USE_GS_GT { + var g []*FP12 + f := NewFP2bigs(NewBIGints(Fra), NewBIGints(Frb)) + q := NewBIGints(CURVE_Order) + t := NewBIGint(0) + + u := gs(e) + + g = append(g, NewFP12copy(d)) + for i := 1; i < 4; i++ { + g = append(g, NewFP12()) + g[i].Copy(g[i-1]) + g[i].frob(f) + } + for i := 0; i < 4; i++ { + np := u[i].nbits() + t.copy(Modneg(u[i], q)) + nn := t.nbits() + if nn < np { + u[i].copy(t) + g[i].conj() + } + u[i].norm() + } + r = pow4(g, u) + } else { + r = d.Pow(e) + } + return r +} + +/* test G1 group membership */ + func G1member(P *ECP) bool { + q := NewBIGints(CURVE_Order) + if P.Is_infinity() {return false} + W:=G1mul(P,q) + if !W.Is_infinity() {return false} + return true + } + +/* test G2 group membership */ + func G2member(P *ECP2) bool { + q := NewBIGints(CURVE_Order) + if P.Is_infinity() {return false} + W:=G2mul(P,q) + if !W.Is_infinity() {return false} + return true + } + +/* test group membership - no longer needed*/ +/* Check that m!=1, conj(m)*m==1, and m.m^{p^4}=m^{p^2} */ + +func GTmember(m *FP12) bool { + if m.Isunity() {return false} + r:=NewFP12copy(m) + r.conj() + r.Mul(m) + if !r.Isunity() {return false} + + f:=NewFP2bigs(NewBIGints(Fra),NewBIGints(Frb)) + + r.Copy(m); r.frob(f); r.frob(f) + w:=NewFP12copy(r); w.frob(f); w.frob(f) + w.Mul(m) + if !w.Equals(r) {return false} + + q := NewBIGints(CURVE_Order) + w.Copy(m) + r.Copy(GTpow(w,q)) + if !r.Isunity() {return false} + return true +} + diff --git a/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/ROM.go b/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/ROM.go new file mode 100644 index 00000000000..604deb6eade --- /dev/null +++ b/vendor/github.com/hyperledger/fabric-amcl/core/FP256BN/ROM.go @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2012-2020 MIRACL UK Ltd. + * + * This file is part of MIRACL Core + * (see https://github.com/miracl/core). + * + * 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. + */ + +/* Fixed Data in ROM - Field and Curve parameters */ + +package FP256BN + +// Base Bits= 56 +var Modulus = [...]Chunk{0x292DDBAED33013, 0x65FB12980A82D3, 0x5EEE71A49F0CDC, 0xFFFCF0CD46E5F2, 0xFFFFFFFF} +var ROI = [...]Chunk{0x292DDBAED33012, 0x65FB12980A82D3, 0x5EEE71A49F0CDC, 0xFFFCF0CD46E5F2, 0xFFFFFFFF} +var R2modp = [...]Chunk{0xEDE336303B9F8B, 0x92FFEE9FEC54E8, 0x13C1C063C55F79, 0xA12F2EAC0123FA, 0x8E559B2A} +var SQRTm3= [...]Chunk {0xF11992678FC004,0xB6BF2F71B0451C,0xDDCA5173D3D540,0xFFFCF0CAD3D42F,0xFFFFFFFF} +const MConst Chunk = 0x6C964E0537E5E5 + +const CURVE_Cof_I int = 1 +const CURVE_B_I int = 3 + +var CURVE_B = [...]Chunk{0x3, 0x0, 0x0, 0x0, 0x0} +var CURVE_Order = [...]Chunk{0x2D536CD10B500D, 0x65FB1299921AF6, 0x5EEE71A49E0CDC, 0xFFFCF0CD46E5F2, 0xFFFFFFFF} +var CURVE_Gx = [...]Chunk{0x1, 0x0, 0x0, 0x0, 0x0} +var CURVE_Gy = [...]Chunk{0x2, 0x0, 0x0, 0x0, 0x0} +var CURVE_HTPC= [...]Chunk {0x1,0x0,0x0,0x0,0x0} + +var Fra = [...]Chunk{0x760328AF943106, 0x71511E3AB28F74, 0x8DDB0867CF39A1, 0xCA786F352D1A6E, 0x3D617662} +var Frb = [...]Chunk{0xB32AB2FF3EFF0D, 0xF4A9F45D57F35E, 0xD113693CCFD33A, 0x3584819819CB83, 0xC29E899D} +var CURVE_Bnx = [...]Chunk{0x82F5C030B0A801, 0x68, 0x0, 0x0, 0x0} +var CURVE_Cof = [...]Chunk{0x1, 0x0, 0x0, 0x0, 0x0} +var CRu = [...]Chunk{0x1C0A24A3A1B807, 0xD79DF1932D1EDB, 0x40921018659BCD, 0x13988E1, 0x0} +var CURVE_Pxa = [...]Chunk{0x2616B689C09EFB, 0x539A12BF843CD2, 0x577C28913ACE1C, 0xB4C96C2028560F, 0xFE0C3350} +var CURVE_Pxb = [...]Chunk{0x69ED34A37E6A2B, 0x78E287D03589D2, 0xC637D813B924DD, 0x738AC054DB5AE1, 0x4EA66057} +var CURVE_Pya = [...]Chunk{0x9B481BEDC27FF, 0x24758D615848E9, 0x75124E3E51EFCB, 0xC542A3B376770D, 0x702046E7} +var CURVE_Pyb = [...]Chunk{0x1281114AAD049B, 0xBE80821A98B3E0, 0x49297EB29F8B4C, 0xD388C29042EEA6, 0x554E3BC} +var CURVE_W = [2][5]Chunk{{0xF0036E1B054003, 0xFFFFFFFE78663A, 0xFFFF, 0x0, 0x0}, {0x5EB8061615001, 0xD1, 0x0, 0x0, 0x0}} +var CURVE_SB = [2][2][5]Chunk{{{0xF5EEEE7C669004, 0xFFFFFFFE78670B, 0xFFFF, 0x0, 0x0}, {0x5EB8061615001, 0xD1, 0x0, 0x0, 0x0}}, {{0x5EB8061615001, 0xD1, 0x0, 0x0, 0x0}, {0x3D4FFEB606100A, 0x65FB129B19B4BB, 0x5EEE71A49D0CDC, 0xFFFCF0CD46E5F2, 0xFFFFFFFF}}} +var CURVE_WB = [4][5]Chunk{{0x20678F0D30A800, 0x55555554D2CC10, 0x5555, 0x0, 0x0}, {0xD6764C0D7DC805, 0x8FBEA10BC3AD1A, 0x806160104467DE, 0xD105EB, 0x0}, {0xACB6061F173803, 0x47DF5085E1D6C1, 0xC030B0082233EF, 0x6882F5, 0x0}, {0x26530F6E91F801, 0x55555554D2CCE1, 0x5555, 0x0, 0x0}} +var CURVE_BB = [4][4][5]Chunk{{{0xAA5DACA05AA80D, 0x65FB1299921A8D, 0x5EEE71A49E0CDC, 0xFFFCF0CD46E5F2, 0xFFFFFFFF}, {0xAA5DACA05AA80C, 0x65FB1299921A8D, 0x5EEE71A49E0CDC, 0xFFFCF0CD46E5F2, 0xFFFFFFFF}, {0xAA5DACA05AA80C, 0x65FB1299921A8D, 0x5EEE71A49E0CDC, 0xFFFCF0CD46E5F2, 0xFFFFFFFF}, {0x5EB8061615002, 0xD1, 0x0, 0x0, 0x0}}, {{0x5EB8061615001, 0xD1, 0x0, 0x0, 0x0}, {0xAA5DACA05AA80C, 0x65FB1299921A8D, 0x5EEE71A49E0CDC, 0xFFFCF0CD46E5F2, 0xFFFFFFFF}, {0xAA5DACA05AA80D, 0x65FB1299921A8D, 0x5EEE71A49E0CDC, 0xFFFCF0CD46E5F2, 0xFFFFFFFF}, {0xAA5DACA05AA80C, 0x65FB1299921A8D, 0x5EEE71A49E0CDC, 0xFFFCF0CD46E5F2, 0xFFFFFFFF}}, {{0x5EB8061615002, 0xD1, 0x0, 0x0, 0x0}, {0x5EB8061615001, 0xD1, 0x0, 0x0, 0x0}, {0x5EB8061615001, 0xD1, 0x0, 0x0, 0x0}, {0x5EB8061615001, 0xD1, 0x0, 0x0, 0x0}}, {{0x82F5C030B0A802, 0x68, 0x0, 0x0, 0x0}, {0xBD700C2C2A002, 0x1A2, 0x0, 0x0, 0x0}, {0x2767EC6FAA000A, 0x65FB1299921A25, 0x5EEE71A49E0CDC, 0xFFFCF0CD46E5F2, 0xFFFFFFFF}, {0x82F5C030B0A802, 0x68, 0x0, 0x0, 0x0}}} + diff --git a/vendor/github.com/hyperledger/fabric-amcl/core/GCM.go b/vendor/github.com/hyperledger/fabric-amcl/core/GCM.go new file mode 100644 index 00000000000..eeee78b41ca --- /dev/null +++ b/vendor/github.com/hyperledger/fabric-amcl/core/GCM.go @@ -0,0 +1,457 @@ +/* + * Copyright (c) 2012-2020 MIRACL UK Ltd. + * + * This file is part of MIRACL Core + * (see https://github.com/miracl/core). + * + * 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. + */ + +/* +* Implementation of the AES-GCM Encryption/Authentication +* +* Some restrictions.. +* 1. Only for use with AES +* 2. Returned tag is always 128-bits. Truncate at your own risk. +* 3. The order of function calls must follow some rules +* +* Typical sequence of calls.. +* 1. call GCM_init +* 2. call GCM_add_header any number of times, as long as length of header is multiple of 16 bytes (block size) +* 3. call GCM_add_header one last time with any length of header +* 4. call GCM_add_cipher any number of times, as long as length of cipher/plaintext is multiple of 16 bytes +* 5. call GCM_add_cipher one last time with any length of cipher/plaintext +* 6. call GCM_finish to extract the tag. +* +* See http://www.mindspring.com/~dmcgrew/gcm-nist-6.pdf + */ + +package core + +import ( + // "fmt" + "strconv" +) + +const gcm_NB int = 4 +const GCM_ACCEPTING_HEADER int = 0 +const GCM_ACCEPTING_CIPHER int = 1 +const GCM_NOT_ACCEPTING_MORE int = 2 +const GCM_FINISHED int = 3 +const GCM_ENCRYPTING int = 0 +const GCM_DECRYPTING int = 1 + +type GCM struct { + table [128][4]uint32 /* 2k bytes */ + stateX [16]byte + Y_0 [16]byte + counter int + lenA [2]uint32 + lenC [2]uint32 + status int + a *AES +} + +func gcm_pack(b [4]byte) uint32 { /* pack bytes into a 32-bit Word */ + return ((uint32(b[0]) & 0xff) << 24) | ((uint32(b[1]) & 0xff) << 16) | ((uint32(b[2]) & 0xff) << 8) | (uint32(b[3]) & 0xff) +} + +func gcm_unpack(a uint32) [4]byte { /* unpack bytes from a word */ + var b = [4]byte{byte((a >> 24) & 0xff), byte((a >> 16) & 0xff), byte((a >> 8) & 0xff), byte(a & 0xff)} + return b +} + +func (G *GCM) precompute(H []byte) { + var b [4]byte + j := 0 + for i := 0; i < gcm_NB; i++ { + b[0] = H[j] + b[1] = H[j+1] + b[2] = H[j+2] + b[3] = H[j+3] + G.table[0][i] = gcm_pack(b) + j += 4 + } + for i := 1; i < 128; i++ { + c := uint32(0) + for j := 0; j < gcm_NB; j++ { + G.table[i][j] = c | (G.table[i-1][j])>>1 + c = G.table[i-1][j] << 31 + } + if c != 0 { + G.table[i][0] ^= 0xE1000000 + } /* irreducible polynomial */ + } +} + +func (G *GCM) gf2mul() { /* gf2m mul - Z=H*X mod 2^128 */ + var P [4]uint32 + + for i := 0; i < 4; i++ { + P[i] = 0 + } + j := uint(8) + m := 0 + for i := 0; i < 128; i++ { + j-- + c := uint32((G.stateX[m] >> j) & 1) + c = ^c + 1 + for k := 0; k < gcm_NB; k++ { + P[k] ^= (G.table[i][k] & c) + } + if j == 0 { + j = 8 + m++ + if m == 16 { + break + } + } + } + j = 0 + for i := 0; i < gcm_NB; i++ { + b := gcm_unpack(P[i]) + G.stateX[j] = b[0] + G.stateX[j+1] = b[1] + G.stateX[j+2] = b[2] + G.stateX[j+3] = b[3] + j += 4 + } +} + +func (G *GCM) wrap() { /* Finish off GHASH */ + var F [4]uint32 + var L [16]byte + + /* convert lengths from bytes to bits */ + F[0] = (G.lenA[0] << 3) | (G.lenA[1]&0xE0000000)>>29 + F[1] = G.lenA[1] << 3 + F[2] = (G.lenC[0] << 3) | (G.lenC[1]&0xE0000000)>>29 + F[3] = G.lenC[1] << 3 + j := 0 + for i := 0; i < gcm_NB; i++ { + b := gcm_unpack(F[i]) + L[j] = b[0] + L[j+1] = b[1] + L[j+2] = b[2] + L[j+3] = b[3] + j += 4 + } + for i := 0; i < 16; i++ { + G.stateX[i] ^= L[i] + } + G.gf2mul() +} + +func (G *GCM) ghash(plain []byte, len int) bool { + if G.status == GCM_ACCEPTING_HEADER { + G.status = GCM_ACCEPTING_CIPHER + } + if G.status != GCM_ACCEPTING_CIPHER { + return false + } + + j := 0 + for j < len { + for i := 0; i < 16 && j < len; i++ { + G.stateX[i] ^= plain[j] + j++ + G.lenC[1]++ + if G.lenC[1] == 0 { + G.lenC[0]++ + } + } + G.gf2mul() + } + if len%16 != 0 { + G.status = GCM_NOT_ACCEPTING_MORE + } + return true +} + +/* Initialize GCM mode */ +func (G *GCM) Init(nk int, key []byte, niv int, iv []byte) { /* iv size niv is usually 12 bytes (96 bits). AES key size nk can be 16,24 or 32 bytes */ + var H [16]byte + + for i := 0; i < 16; i++ { + H[i] = 0 + G.stateX[i] = 0 + } + + G.a = new(AES) + + G.a.Init(AES_ECB, nk, key, iv) + G.a.ecb_encrypt(H[:]) /* E(K,0) */ + G.precompute(H[:]) + + G.lenA[0] = 0 + G.lenC[0] = 0 + G.lenA[1] = 0 + G.lenC[1] = 0 + if niv == 12 { + for i := 0; i < 12; i++ { + G.a.f[i] = iv[i] + } + b := gcm_unpack(uint32(1)) + G.a.f[12] = b[0] + G.a.f[13] = b[1] + G.a.f[14] = b[2] + G.a.f[15] = b[3] /* initialise IV */ + for i := 0; i < 16; i++ { + G.Y_0[i] = G.a.f[i] + } + } else { + G.status = GCM_ACCEPTING_CIPHER + G.ghash(iv, niv) /* GHASH(H,0,IV) */ + G.wrap() + for i := 0; i < 16; i++ { + G.a.f[i] = G.stateX[i] + G.Y_0[i] = G.a.f[i] + G.stateX[i] = 0 + } + G.lenA[0] = 0 + G.lenC[0] = 0 + G.lenA[1] = 0 + G.lenC[1] = 0 + } + G.status = GCM_ACCEPTING_HEADER +} + +/* Add Header data - included but not encrypted */ +func (G *GCM) Add_header(header []byte, len int) bool { /* Add some header. Won't be encrypted, but will be authenticated. len is length of header */ + if G.status != GCM_ACCEPTING_HEADER { + return false + } + + j := 0 + for j < len { + for i := 0; i < 16 && j < len; i++ { + G.stateX[i] ^= header[j] + j++ + G.lenA[1]++ + if G.lenA[1] == 0 { + G.lenA[0]++ + } + } + G.gf2mul() + } + if len%16 != 0 { + G.status = GCM_ACCEPTING_CIPHER + } + + return true +} + +/* Add Plaintext - included and encrypted */ +func (G *GCM) Add_plain(plain []byte, len int) []byte { + var B [16]byte + var b [4]byte + + cipher := make([]byte, len) + var counter uint32 = 0 + if G.status == GCM_ACCEPTING_HEADER { + G.status = GCM_ACCEPTING_CIPHER + } + if G.status != GCM_ACCEPTING_CIPHER { + return nil + } + + j := 0 + for j < len { + + b[0] = G.a.f[12] + b[1] = G.a.f[13] + b[2] = G.a.f[14] + b[3] = G.a.f[15] + counter = gcm_pack(b) + counter++ + b = gcm_unpack(counter) + G.a.f[12] = b[0] + G.a.f[13] = b[1] + G.a.f[14] = b[2] + G.a.f[15] = b[3] /* increment counter */ + for i := 0; i < 16; i++ { + B[i] = G.a.f[i] + } + G.a.ecb_encrypt(B[:]) /* encrypt it */ + + for i := 0; i < 16 && j < len; i++ { + cipher[j] = (plain[j] ^ B[i]) + G.stateX[i] ^= cipher[j] + j++ + G.lenC[1]++ + if G.lenC[1] == 0 { + G.lenC[0]++ + } + } + G.gf2mul() + } + if len%16 != 0 { + G.status = GCM_NOT_ACCEPTING_MORE + } + return cipher +} + +/* Add Ciphertext - decrypts to plaintext */ +func (G *GCM) Add_cipher(cipher []byte, len int) []byte { + var B [16]byte + var b [4]byte + + plain := make([]byte, len) + var counter uint32 = 0 + + if G.status == GCM_ACCEPTING_HEADER { + G.status = GCM_ACCEPTING_CIPHER + } + if G.status != GCM_ACCEPTING_CIPHER { + return nil + } + + j := 0 + for j < len { + b[0] = G.a.f[12] + b[1] = G.a.f[13] + b[2] = G.a.f[14] + b[3] = G.a.f[15] + counter = gcm_pack(b) + counter++ + b = gcm_unpack(counter) + G.a.f[12] = b[0] + G.a.f[13] = b[1] + G.a.f[14] = b[2] + G.a.f[15] = b[3] /* increment counter */ + for i := 0; i < 16; i++ { + B[i] = G.a.f[i] + } + G.a.ecb_encrypt(B[:]) /* encrypt it */ + for i := 0; i < 16 && j < len; i++ { + oc := cipher[j] + plain[j] = (cipher[j] ^ B[i]) + G.stateX[i] ^= oc + j++ + G.lenC[1]++ + if G.lenC[1] == 0 { + G.lenC[0]++ + } + } + G.gf2mul() + } + if len%16 != 0 { + G.status = GCM_NOT_ACCEPTING_MORE + } + return plain +} + +/* Finish and extract Tag */ +func (G *GCM) Finish(extract bool) []byte { /* Finish off GHASH and extract tag (MAC) */ + var tag []byte + + G.wrap() + /* extract tag */ + if extract { + G.a.ecb_encrypt(G.Y_0[:]) /* E(K,Y0) */ + for i := 0; i < 16; i++ { + G.Y_0[i] ^= G.stateX[i] + } + for i := 0; i < 16; i++ { + tag = append(tag,G.Y_0[i]) + G.Y_0[i] = 0 + G.stateX[i] = 0 + } + } + G.status = GCM_FINISHED + G.a.End() + return tag +} + +func hex2bytes(s string) []byte { + lgh := len(s) + data := make([]byte, lgh/2) + + for i := 0; i < lgh; i += 2 { + a, _ := strconv.ParseInt(s[i:i+2], 16, 32) + data[i/2] = byte(a) + } + return data +} + +func GCM_ENCRYPT(K []byte,IV []byte,H []byte,P []byte) ([]byte,[]byte){ + g:=new(GCM) + g.Init(len(K),K,len(IV),IV) + g.Add_header(H,len(H)) + C:=g.Add_plain(P,len(P)) + T:=g.Finish(true) + return C,T +} + +func GCM_DECRYPT(K []byte,IV []byte,H []byte,C []byte) ([]byte,[]byte){ + g:=new(GCM) + g.Init(len(K),K,len(IV),IV) + g.Add_header(H,len(H)) + P:=g.Add_cipher(C,len(C)) + T:=g.Finish(true) + return P,T +} + +/* +func main() { + + KT:="feffe9928665731c6d6a8f9467308308" + MT:="d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39" + HT:="feedfacedeadbeeffeedfacedeadbeefabaddad2" + + NT:="9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b"; +// Tag should be 619cc5aefffe0bfa462af43c1699d050 + + g:=new(GCM) + + M:=hex2bytes(MT) + H:=hex2bytes(HT) + N:=hex2bytes(NT) + K:=hex2bytes(KT) + + lenM:=len(M) + lenH:=len(H) + lenK:=len(K) + lenIV:=len(N) + + fmt.Printf("Plaintext=\n"); + for i:=0;i> n) | ((x) << (32 - n))) +} + +func hash256_R(n uint32, x uint32) uint32 { + return ((x) >> n) +} + +func hash256_Ch(x, y, z uint32) uint32 { + return ((x & y) ^ (^(x) & z)) +} + +func hash256_Maj(x, y, z uint32) uint32 { + return ((x & y) ^ (x & z) ^ (y & z)) +} + +func hash256_Sig0(x uint32) uint32 { + return (hash256_S(2, x) ^ hash256_S(13, x) ^ hash256_S(22, x)) +} + +func hash256_Sig1(x uint32) uint32 { + return (hash256_S(6, x) ^ hash256_S(11, x) ^ hash256_S(25, x)) +} + +func hash256_theta0(x uint32) uint32 { + return (hash256_S(7, x) ^ hash256_S(18, x) ^ hash256_R(3, x)) +} + +func hash256_theta1(x uint32) uint32 { + return (hash256_S(17, x) ^ hash256_S(19, x) ^ hash256_R(10, x)) +} + +func (H *HASH256) transform() { /* basic transformation step */ + for j := 16; j < 64; j++ { + H.w[j] = hash256_theta1(H.w[j-2]) + H.w[j-7] + hash256_theta0(H.w[j-15]) + H.w[j-16] + } + a := H.h[0] + b := H.h[1] + c := H.h[2] + d := H.h[3] + e := H.h[4] + f := H.h[5] + g := H.h[6] + hh := H.h[7] + for j := 0; j < 64; j++ { /* 64 times - mush it up */ + t1 := hh + hash256_Sig1(e) + hash256_Ch(e, f, g) + hash256_K[j] + H.w[j] + t2 := hash256_Sig0(a) + hash256_Maj(a, b, c) + hh = g + g = f + f = e + e = d + t1 + d = c + c = b + b = a + a = t1 + t2 + } + H.h[0] += a + H.h[1] += b + H.h[2] += c + H.h[3] += d + H.h[4] += e + H.h[5] += f + H.h[6] += g + H.h[7] += hh +} + +/* Initialise Hash function */ +func (H *HASH256) Init() { /* initialise */ + for i := 0; i < 64; i++ { + H.w[i] = 0 + } + H.length[0] = 0 + H.length[1] = 0 + H.h[0] = hash256_H0 + H.h[1] = hash256_H1 + H.h[2] = hash256_H2 + H.h[3] = hash256_H3 + H.h[4] = hash256_H4 + H.h[5] = hash256_H5 + H.h[6] = hash256_H6 + H.h[7] = hash256_H7 +} + +func NewHASH256() *HASH256 { + H := new(HASH256) + H.Init() + return H +} + +func NewHASH256copy(HC *HASH256) *HASH256 { + H := new(HASH256) + for i:=0;i<64;i++ { + H.w[i]=HC.w[i] + } + for i:=0;i<8;i++ { + H.h[i]=HC.h[i] + } + H.length[0]=HC.length[0] + H.length[1]=HC.length[1] + return H +} + +/* process a single byte */ +func (H *HASH256) Process(byt byte) { /* process the next message byte */ + cnt := (H.length[0] / 32) % 16 + + H.w[cnt] <<= 8 + H.w[cnt] |= uint32(byt & 0xFF) + H.length[0] += 8 + if H.length[0] == 0 { + H.length[1]++ + H.length[0] = 0 + } + if (H.length[0] % 512) == 0 { + H.transform() + } +} + +/* process an array of bytes */ +func (H *HASH256) Process_array(b []byte) { + for i := 0; i < len(b); i++ { + H.Process((b[i])) + } +} + +/* process a 32-bit integer */ +func (H *HASH256) Process_num(n int32) { + H.Process(byte((n >> 24) & 0xff)) + H.Process(byte((n >> 16) & 0xff)) + H.Process(byte((n >> 8) & 0xff)) + H.Process(byte(n & 0xff)) +} + +/* Generate 32-byte Hash */ +func (H *HASH256) Hash() []byte { /* pad message and finish - supply digest */ + var digest [32]byte + len0 := H.length[0] + len1 := H.length[1] + H.Process(0x80) + for (H.length[0] % 512) != 448 { + H.Process(0) + } + H.w[14] = len1 + H.w[15] = len0 + H.transform() + for i := 0; i < 32; i++ { /* convert to bytes */ + digest[i] = byte((H.h[i/4] >> uint(8*(3-i%4))) & 0xff) + } + H.Init() + return digest[0:32] +} + +func (H *HASH256) Continuing_Hash() []byte { + sh := NewHASH256copy(H) + return sh.Hash() +} + +/* test program: should produce digest */ + +//248d6a61 d20638b8 e5c02693 0c3e6039 a33ce459 64ff2167 f6ecedd4 19db06c1 +/* +func main() { + + test := []byte("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq") + sh:=NewHASH256() + + for i:=0;i> n) | ((x) << (64 - n))) +} + +func hash384_R(n uint64, x uint64) uint64 { + return ((x) >> n) +} + +func hash384_Ch(x, y, z uint64) uint64 { + return ((x & y) ^ (^(x) & z)) +} + +func hash384_Maj(x, y, z uint64) uint64 { + return ((x & y) ^ (x & z) ^ (y & z)) +} + +func hash384_Sig0(x uint64) uint64 { + return (hash384_S(28, x) ^ hash384_S(34, x) ^ hash384_S(39, x)) +} + +func hash384_Sig1(x uint64) uint64 { + return (hash384_S(14, x) ^ hash384_S(18, x) ^ hash384_S(41, x)) +} + +func hash384_theta0(x uint64) uint64 { + return (hash384_S(1, x) ^ hash384_S(8, x) ^ hash384_R(7, x)) +} + +func hash384_theta1(x uint64) uint64 { + return (hash384_S(19, x) ^ hash384_S(61, x) ^ hash384_R(6, x)) +} + +func (H *HASH384) transform() { /* basic transformation step */ + for j := 16; j < 80; j++ { + H.w[j] = hash384_theta1(H.w[j-2]) + H.w[j-7] + hash384_theta0(H.w[j-15]) + H.w[j-16] + } + a := H.h[0] + b := H.h[1] + c := H.h[2] + d := H.h[3] + e := H.h[4] + f := H.h[5] + g := H.h[6] + hh := H.h[7] + for j := 0; j < 80; j++ { /* 80 times - mush it up */ + t1 := hh + hash384_Sig1(e) + hash384_Ch(e, f, g) + hash384_K[j] + H.w[j] + t2 := hash384_Sig0(a) + hash384_Maj(a, b, c) + hh = g + g = f + f = e + e = d + t1 + d = c + c = b + b = a + a = t1 + t2 + } + H.h[0] += a + H.h[1] += b + H.h[2] += c + H.h[3] += d + H.h[4] += e + H.h[5] += f + H.h[6] += g + H.h[7] += hh +} + +/* Initialise Hash function */ +func (H *HASH384) Init() { /* initialise */ + for i := 0; i < 80; i++ { + H.w[i] = 0 + } + H.length[0] = 0 + H.length[1] = 0 + H.h[0] = hash384_H0 + H.h[1] = hash384_H1 + H.h[2] = hash384_H2 + H.h[3] = hash384_H3 + H.h[4] = hash384_H4 + H.h[5] = hash384_H5 + H.h[6] = hash384_H6 + H.h[7] = hash384_H7 +} + +func NewHASH384() *HASH384 { + H := new(HASH384) + H.Init() + return H +} + +func NewHASH384copy(HC *HASH384) *HASH384 { + H := new(HASH384) + for i:=0;i<80;i++ { + H.w[i]=HC.w[i] + } + for i:=0;i<8;i++ { + H.h[i]=HC.h[i] + } + H.length[0]=HC.length[0] + H.length[1]=HC.length[1] + return H +} + +/* process a single byte */ +func (H *HASH384) Process(byt byte) { /* process the next message byte */ + cnt := (H.length[0] / 64) % 16 + + H.w[cnt] <<= 8 + H.w[cnt] |= uint64(byt & 0xFF) + H.length[0] += 8 + if H.length[0] == 0 { + H.length[1]++ + H.length[0] = 0 + } + if (H.length[0] % 1024) == 0 { + H.transform() + } +} + +/* process an array of bytes */ +func (H *HASH384) Process_array(b []byte) { + for i := 0; i < len(b); i++ { + H.Process((b[i])) + } +} + +/* process a 32-bit integer */ +func (H *HASH384) Process_num(n int32) { + H.Process(byte((n >> 24) & 0xff)) + H.Process(byte((n >> 16) & 0xff)) + H.Process(byte((n >> 8) & 0xff)) + H.Process(byte(n & 0xff)) +} + +/* Generate 32-byte Hash */ +func (H *HASH384) Hash() []byte { /* pad message and finish - supply digest */ + var digest [48]byte + len0 := H.length[0] + len1 := H.length[1] + H.Process(0x80) + for (H.length[0] % 1024) != 896 { + H.Process(0) + } + H.w[14] = len1 + H.w[15] = len0 + H.transform() + for i := 0; i < 48; i++ { /* convert to bytes */ + digest[i] = byte((H.h[i/8] >> uint(8*(7-i%8))) & 0xff) + } + H.Init() + return digest[0:48] +} + +func (H *HASH384) Continuing_Hash() []byte { + sh := NewHASH384copy(H) + return sh.Hash() +} + +/* test program: should produce digest */ + +//09330c33f71147e8 3d192fc782cd1b47 53111b173b3b05d2 2fa08086e3b0f712 fcc7c71a557e2db9 66c3e9fa91746039 +/* +func main() { + + test := []byte("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu") + sh:=NewHASH384() + + for i:=0;i> n) | ((x) << (64 - n))) +} + +func hash512_R(n uint64, x uint64) uint64 { + return ((x) >> n) +} + +func hash512_Ch(x, y, z uint64) uint64 { + return ((x & y) ^ (^(x) & z)) +} + +func hash512_Maj(x, y, z uint64) uint64 { + return ((x & y) ^ (x & z) ^ (y & z)) +} + +func hash512_Sig0(x uint64) uint64 { + return (hash512_S(28, x) ^ hash512_S(34, x) ^ hash512_S(39, x)) +} + +func hash512_Sig1(x uint64) uint64 { + return (hash512_S(14, x) ^ hash512_S(18, x) ^ hash512_S(41, x)) +} + +func hash512_theta0(x uint64) uint64 { + return (hash512_S(1, x) ^ hash512_S(8, x) ^ hash512_R(7, x)) +} + +func hash512_theta1(x uint64) uint64 { + return (hash512_S(19, x) ^ hash512_S(61, x) ^ hash512_R(6, x)) +} + +func (H *HASH512) transform() { /* basic transformation step */ + for j := 16; j < 80; j++ { + H.w[j] = hash512_theta1(H.w[j-2]) + H.w[j-7] + hash512_theta0(H.w[j-15]) + H.w[j-16] + } + a := H.h[0] + b := H.h[1] + c := H.h[2] + d := H.h[3] + e := H.h[4] + f := H.h[5] + g := H.h[6] + hh := H.h[7] + for j := 0; j < 80; j++ { /* 80 times - mush it up */ + t1 := hh + hash512_Sig1(e) + hash512_Ch(e, f, g) + hash512_K[j] + H.w[j] + t2 := hash512_Sig0(a) + hash512_Maj(a, b, c) + hh = g + g = f + f = e + e = d + t1 + d = c + c = b + b = a + a = t1 + t2 + } + H.h[0] += a + H.h[1] += b + H.h[2] += c + H.h[3] += d + H.h[4] += e + H.h[5] += f + H.h[6] += g + H.h[7] += hh +} + +/* Initialise Hash function */ +func (H *HASH512) Init() { /* initialise */ + for i := 0; i < 80; i++ { + H.w[i] = 0 + } + H.length[0] = 0 + H.length[1] = 0 + H.h[0] = hash512_H0 + H.h[1] = hash512_H1 + H.h[2] = hash512_H2 + H.h[3] = hash512_H3 + H.h[4] = hash512_H4 + H.h[5] = hash512_H5 + H.h[6] = hash512_H6 + H.h[7] = hash512_H7 +} + +func NewHASH512() *HASH512 { + H := new(HASH512) + H.Init() + return H +} + +func NewHASH512copy(HC *HASH512) *HASH512 { + H := new(HASH512) + for i:=0;i<80;i++ { + H.w[i]=HC.w[i] + } + for i:=0;i<8;i++ { + H.h[i]=HC.h[i] + } + H.length[0]=HC.length[0] + H.length[1]=HC.length[1] + return H +} + +/* process a single byte */ +func (H *HASH512) Process(byt byte) { /* process the next message byte */ + cnt := (H.length[0] / 64) % 16 + + H.w[cnt] <<= 8 + H.w[cnt] |= uint64(byt & 0xFF) + H.length[0] += 8 + if H.length[0] == 0 { + H.length[1]++ + H.length[0] = 0 + } + if (H.length[0] % 1024) == 0 { + H.transform() + } +} + +/* process an array of bytes */ +func (H *HASH512) Process_array(b []byte) { + for i := 0; i < len(b); i++ { + H.Process((b[i])) + } +} + +/* process a 32-bit integer */ +func (H *HASH512) Process_num(n int32) { + H.Process(byte((n >> 24) & 0xff)) + H.Process(byte((n >> 16) & 0xff)) + H.Process(byte((n >> 8) & 0xff)) + H.Process(byte(n & 0xff)) +} + +/* Generate 64-byte Hash */ +func (H *HASH512) Hash() []byte { /* pad message and finish - supply digest */ + var digest [64]byte + len0 := H.length[0] + len1 := H.length[1] + H.Process(0x80) + for (H.length[0] % 1024) != 896 { + H.Process(0) + } + H.w[14] = len1 + H.w[15] = len0 + H.transform() + for i := 0; i < 64; i++ { /* convert to bytes */ + digest[i] = byte((H.h[i/8] >> uint(8*(7-i%8))) & 0xff) + } + H.Init() + return digest[0:64] +} + +func (H *HASH512) Continuing_Hash() []byte { + sh := NewHASH512copy(H) + return sh.Hash() +} + +/* test program: should produce digest */ + +//8e959b75dae313da 8cf4f72814fc143f 8f7779c6eb9f7fa1 7299aeadb6889018 501d289e4900f7e4 331b99dec4b5433a c7d329eeb6dd2654 5e96e55b874be909 +/* +func main() { + + test := []byte("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu") + sh:=NewHASH512() + + for i:=0;i 0 && i > 0 { + i-- + b[i] = byte(n & 0xff) + n /= 256 + } + return b +} +/* general purpose hashing of Byte array|integer|Byte array. Output of length olen, padded with leading zeros if required */ + +func GPhashit(hash int,hlen int, olen int, zpad int,A []byte, n int32, B []byte) []byte { + var R []byte + if hash == MC_SHA2 { + if hlen == SHA256 { + H := NewHASH256() + for i := 0; i < zpad; i++ { + H.Process(0) + } + if A != nil { + H.Process_array(A) + } + if n >= 0 { + H.Process_num(int32(n)) + } + if B != nil { + H.Process_array(B) + } + R = H.Hash() + } + if hlen == SHA384 { + H := NewHASH384() + for i := 0; i < zpad; i++ { + H.Process(0) + } + if A != nil { + H.Process_array(A) + } + if n >= 0 { + H.Process_num(int32(n)) + } + if B != nil { + H.Process_array(B) + } + R = H.Hash() + } + if hlen == SHA512 { + H := NewHASH512() + for i := 0; i < zpad; i++ { + H.Process(0) + } + if A != nil { + H.Process_array(A) + } + if n >= 0 { + H.Process_num(int32(n)) + } + if B != nil { + H.Process_array(B) + } + R = H.Hash() + } + } + if hash == MC_SHA3 { + H := NewSHA3(hlen) + for i := 0; i < zpad; i++ { + H.Process(0) + } + if A != nil { + H.Process_array(A) + } + if n >= 0 { + H.Process_num(int32(n)) + } + if B != nil { + H.Process_array(B) + } + R = H.Hash() + } + + if R == nil { + return nil + } + + if olen == 0 { + return R + } + var W []byte + for i := 0; i < olen; i++ { + W = append(W, 0) + } + if olen <= hlen { + for i := 0; i < olen; i++ { + W[i] = R[i] + } + } else { + for i := 0; i < hlen; i++ { + W[i+olen-hlen] = R[i] + } + for i := 0; i < olen-hlen; i++ { + W[i] = 0 + } + } + return W +} + +/* Simple hashing of byte array */ +func SPhashit(hash int,hlen int, A []byte) []byte { + return GPhashit(hash,hlen,0,0,A,-1,nil) +} + +/* Key Derivation Function */ +/* Input octet Z */ +/* Output key of length olen */ + +func KDF2(hash int, sha int, Z []byte, P []byte, olen int) []byte { + /* NOTE: the parameter olen is the length of the output k in bytes */ + hlen := sha + var K []byte + k := 0 + + for i := 0; i < olen; i++ { + K = append(K, 0) + } + + cthreshold := olen / hlen + if olen%hlen != 0 { + cthreshold++ + } + + for counter := 1; counter <= cthreshold; counter++ { + B := GPhashit(hash,sha, 0, 0, Z, int32(counter), P) + if k+hlen > olen { + for i := 0; i < olen%hlen; i++ { + K[k] = B[i] + k++ + } + } else { + for i := 0; i < hlen; i++ { + K[k] = B[i] + k++ + } + } + } + return K +} + +/* Password based Key Derivation Function */ +/* Input password p, salt s, and repeat count */ +/* Output key of length olen */ +func PBKDF2(hash int, sha int, Pass []byte, Salt []byte, rep int, olen int) []byte { + d := olen / sha + if olen%sha != 0 { + d++ + } + + var F []byte + var U []byte + var S []byte + var K []byte + + for i := 0; i < sha; i++ { + F = append(F, 0) + U = append(U, 0) + } + + for i := 1; i <= d; i++ { + for j := 0; j < len(Salt); j++ { + S = append(S, Salt[j]) + } + N := InttoBytes(i, 4) + for j := 0; j < 4; j++ { + S = append(S, N[j]) + } + + HMAC(MC_SHA2, sha, F[:], sha, S, Pass) + + for j := 0; j < sha; j++ { + U[j] = F[j] + } + for j := 2; j <= rep; j++ { + HMAC(MC_SHA2, sha, U[:], sha, U[:], Pass) + for k := 0; k < sha; k++ { + F[k] ^= U[k] + } + } + for j := 0; j < sha; j++ { + K = append(K, F[j]) + } + } + var key []byte + for i := 0; i < olen; i++ { + key = append(key, K[i]) + } + return key +} + +func blksize(hash int,sha int) int { + b := 0 + if hash == MC_SHA2 { + b = 64 + if sha > 32 { + b = 128 + } + } + if hash == MC_SHA3 { + b=200-2*sha + } + return b +} + +/* Calculate HMAC of m using key k. HMAC is tag of length olen (which is length of tag) */ +func HMAC(hash int, sha int, tag []byte, olen int, K []byte, M []byte) int { + /* Input is from an octet m * + * olen is requested output length in bytes. k is the key * + * The output is the calculated tag */ + var B []byte + + b := blksize(hash,sha) + if b == 0 {return 0} + + var K0 [200]byte + //olen := len(tag) + + for i := 0; i < b; i++ { + K0[i] = 0 + } + + if len(K) > b { + B = SPhashit(hash, sha, K) + for i := 0; i < sha; i++ { + K0[i] = B[i] + } + } else { + for i := 0; i < len(K); i++ { + K0[i] = K[i] + } + } + + for i := 0; i < b; i++ { + K0[i] ^= 0x36 + } + B = GPhashit(hash, sha, 0, 0, K0[0:b], -1, M) + + for i := 0; i < b; i++ { + K0[i] ^= 0x6a + } + B = GPhashit(hash, sha, olen, 0, K0[0:b], -1, B) + + for i := 0; i < olen; i++ { + tag[i] = B[i] + } + + return 1 +} + +func HKDF_Extract(hash int, hlen int, SALT []byte, IKM []byte) []byte { + var PRK []byte + for i:=0;i 0 { + for j := 0; j < len(INFO); j++ { + T = append(T, INFO[j]) + } + T = append(T, byte(n+1)) + HMAC(hash,hlen,K[:],flen,PRK,T); + for j := 0; j < flen; j++ { + OKM = append(OKM, K[j]) + } + } + return OKM +} + +func ceil(a int,b int) int { + return (((a)-1)/(b)+1) +} + +func XOF_Expand(hlen int,olen int,DST []byte,MSG []byte) []byte { + var OKM =make([]byte,olen) + H := NewSHA3(hlen) + for i:=0;i> 8) & 0xff)); + H.Process(byte(olen & 0xff)); + + for i:=0;i> 8) & 0xff) + TMP[1]=byte(olen & 0xff) + TMP[2]=byte(0) + + for j:=0;j olen { + for i := 0; i < olen%hlen; i++ { + K[k] = B[i] + k++ + } + } else { + for i := 0; i < hlen; i++ { + K[k] = B[i] + k++ + } + } + } +} + + +func MGF1XOR(sha int, Z []byte, olen int, K []byte) { + hlen := sha + + var k int = 0 + + cthreshold := olen / hlen + if olen%hlen != 0 { + cthreshold++ + } + for counter := 0; counter < cthreshold; counter++ { + B := GPhashit(MC_SHA2,sha,0,0,Z,int32(counter),nil) + //B := hashit(sha, Z, counter) + + if k+hlen > olen { + for i := 0; i < olen%hlen; i++ { + K[k] ^= B[i] + k++ + } + } else { + for i := 0; i < hlen; i++ { + K[k] ^= B[i] + k++ + } + } + } +} + +/* SHAXXX identifier strings */ +var SHA256ID = [...]byte{0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20} +var SHA384ID = [...]byte{0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30} +var SHA512ID = [...]byte{0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40} + +func RSA_PKCS15(sha int, m []byte, w []byte, RFS int) bool { + olen := RFS + hlen := sha + idlen := 19 + + if olen < idlen+hlen+10 { + return false + } + H := SPhashit(MC_SHA2,sha,m) + //H := hashit(sha, m, -1) + + for i := 0; i < len(w); i++ { + w[i] = 0 + } + i := 0 + w[i] = 0 + i++ + w[i] = 1 + i++ + for j := 0; j < olen-idlen-hlen-3; j++ { + w[i] = 0xff + i++ + } + w[i] = 0 + i++ + + if hlen == SHA256 { + for j := 0; j < idlen; j++ { + w[i] = SHA256ID[j] + i++ + } + } + if hlen == SHA384 { + for j := 0; j < idlen; j++ { + w[i] = SHA384ID[j] + i++ + } + } + if hlen == SHA512 { + for j := 0; j < idlen; j++ { + w[i] = SHA512ID[j] + i++ + } + } + for j := 0; j < hlen; j++ { + w[i] = H[j] + i++ + } + + return true +} + +/* SHAXXX identifier strings */ +var SHA256IDb = [...]byte{0x30, 0x2f, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x04, 0x20} +var SHA384IDb = [...]byte{0x30, 0x3f, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x04, 0x30} +var SHA512IDb = [...]byte{0x30, 0x4f, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x04, 0x40} + +func RSA_PKCS15b(sha int, m []byte, w []byte, RFS int) bool { + olen := RFS + hlen := sha + idlen := 17 + + if olen < idlen+hlen+10 { + return false + } + H := SPhashit(MC_SHA2,sha,m) + //H := hashit(sha, m, -1) + + for i := 0; i < len(w); i++ { + w[i] = 0 + } + i := 0 + w[i] = 0 + i++ + w[i] = 1 + i++ + for j := 0; j < olen-idlen-hlen-3; j++ { + w[i] = 0xff + i++ + } + w[i] = 0 + i++ + + if hlen == SHA256 { + for j := 0; j < idlen; j++ { + w[i] = SHA256IDb[j] + i++ + } + } + if hlen == SHA384 { + for j := 0; j < idlen; j++ { + w[i] = SHA384IDb[j] + i++ + } + } + if hlen == SHA512 { + for j := 0; j < idlen; j++ { + w[i] = SHA512IDb[j] + i++ + } + } + for j := 0; j < hlen; j++ { + w[i] = H[j] + i++ + } + return true +} + + +func RSA_PSS_ENCODE(sha int, m []byte, rng *RAND, RFS int) []byte { + emlen:=RFS + embits:=8*emlen-1 + + hlen:=sha + SALT := make([]byte,hlen) + for i := 0; i < hlen; i++ { + SALT[i] = rng.GetByte() + } + mask:=byte(0xff>>(8*emlen-embits)) + + H := SPhashit(MC_SHA2,sha,m) + if emlen < hlen+hlen+2 { + return nil + } + + MD := make([]byte,8+hlen+hlen) + for i:=0;i<8;i++ { + MD[i]=0; + } + for i:=0;i>(8*emlen-embits)) + + HMASK := SPhashit(MC_SHA2,sha,m) + if emlen < hlen + hlen + 2 { + return false + } + if (f[emlen-1]!=byte(0xbc)) { + return false + } + if (f[0]&(^mask))!=0 { + return false + } + DB:=make([]byte,emlen-hlen-1) + for i:=0;i olen-hlen-seedlen-1 { + return nil + } + + DBMASK := make([]byte, olen-seedlen) + + h := SPhashit(MC_SHA2,sha,p) + //h := hashit(sha, p, -1) + + for i := 0; i < hlen; i++ { + f[i] = h[i] + } + + slen := olen - mlen - hlen - seedlen - 1 + + for i := 0; i < slen; i++ { + f[hlen+i] = 0 + } + f[hlen+slen] = 1 + for i := 0; i < mlen; i++ { + f[hlen+slen+1+i] = m[i] + } + + for i := 0; i < seedlen; i++ { + SEED[i] = rng.GetByte() + } + MGF1(sha, SEED, olen-seedlen, DBMASK) + + for i := 0; i < olen-seedlen; i++ { + DBMASK[i] ^= f[i] + } + + MGF1(sha, DBMASK, seedlen, f[:]) + + for i := 0; i < seedlen; i++ { + f[i] ^= SEED[i] + } + + for i := 0; i < olen-seedlen; i++ { + f[i+seedlen] = DBMASK[i] + } + + /* pad to length RFS */ + d := 1 + for i := RFS - 1; i >= d; i-- { + f[i] = f[i-d] + } + for i := d - 1; i >= 0; i-- { + f[i] = 0 + } + return f[:] +} + +/* OAEP Message Decoding for Decryption */ +func RSA_OAEP_DECODE(sha int, p []byte, f []byte, RFS int) []byte { + olen := RFS - 1 + + hlen := sha + SEED := make([]byte, hlen) + seedlen := hlen + CHASH := make([]byte, hlen) + + if olen < seedlen+hlen+1 { + return nil + } + DBMASK := make([]byte, olen-seedlen) + for i := 0; i < olen-seedlen; i++ { + DBMASK[i] = 0 + } + + if len(f) < RFS { + d := RFS - len(f) + for i := RFS - 1; i >= d; i-- { + f[i] = f[i-d] + } + for i := d - 1; i >= 0; i-- { + f[i] = 0 + } + } + + h := SPhashit(MC_SHA2,sha,p) + //h := hashit(sha, p, -1) + for i := 0; i < hlen; i++ { + CHASH[i] = h[i] + } + + x := f[0] + + for i := seedlen; i < olen; i++ { + DBMASK[i-seedlen] = f[i+1] + } + + MGF1(sha, DBMASK, seedlen, SEED) + for i := 0; i < seedlen; i++ { + SEED[i] ^= f[i+1] + } + MGF1(sha, SEED, olen-seedlen, f) + for i := 0; i < olen-seedlen; i++ { + DBMASK[i] ^= f[i] + } + + comp := true + for i := 0; i < hlen; i++ { + if CHASH[i] != DBMASK[i] { + comp = false + } + } + + for i := 0; i < olen-seedlen-hlen; i++ { + DBMASK[i] = DBMASK[i+hlen] + } + + for i := 0; i < hlen; i++ { + SEED[i] = 0 + CHASH[i] = 0 + } + + var k int + for k = 0; ; k++ { + if k >= olen-seedlen-hlen { + return nil + } + if DBMASK[k] != 0 { + break + } + } + + t := DBMASK[k] + if !comp || x != 0 || t != 0x01 { + for i := 0; i < olen-seedlen; i++ { + DBMASK[i] = 0 + } + return nil + } + + var r = make([]byte, olen-seedlen-hlen-k-1) + + for i := 0; i < olen-seedlen-hlen-k-1; i++ { + r[i] = DBMASK[i+k+1] + } + + for i := 0; i < olen-seedlen; i++ { + DBMASK[i] = 0 + } + + return r +} + + + + +/* + + + MSG := []byte("abc") + DST := []byte("P256_XMD:SHA-256_SSWU_RO_TESTGEN") + + OKM := core.XOF_Expand(core.SHA3_SHAKE128,48,DST,MSG) + fmt.Printf("OKM= "); printBinary(OKM[:]) + + OKM = core.XMD_Expand(core.MC_SHA2,32,48,DST,MSG) + fmt.Printf("OKM= "); printBinary(OKM[:]) + + + +func main() { + var ikm []byte + var salt []byte + var info []byte + + for i:=0;i<22;i++ {ikm=append(ikm,0x0b)} + for i:=0;i<13;i++ {salt=append(salt,byte(i))} + for i:=0;i<10;i++ {info=append(info,byte(0xf0+i))} + + prk:=core.HKDF_Extract(core.MC_SHA2,32,salt,ikm) + fmt.Printf("PRK= ") + for i := 0; i < len(prk); i++ { + fmt.Printf("%02x", prk[i]) + } + + okm:=core.HKDF_Expand(core.MC_SHA2,32,42,prk,info) + fmt.Printf("\nOKM= ") + for i := 0; i < len(okm); i++ { + fmt.Printf("%02x", okm[i]) + } + +} +*/ + diff --git a/vendor/github.com/hyperledger/fabric-amcl/core/NHS.go b/vendor/github.com/hyperledger/fabric-amcl/core/NHS.go new file mode 100644 index 00000000000..b6093aaf2e7 --- /dev/null +++ b/vendor/github.com/hyperledger/fabric-amcl/core/NHS.go @@ -0,0 +1,548 @@ +/* + * Copyright (c) 2012-2020 MIRACL UK Ltd. + * + * This file is part of MIRACL Core + * (see https://github.com/miracl/core). + * + * 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. + */ + +// NEWHOPE nhs_package main + +package core + +//import "fmt" + +const NHS_PRIME int32 = 0x3001 // q in Hex +const NHS_LGN uint = 10 // Degree n=2^LGN +const NHS_ND uint32 = 0xF7002FFF // 1/(R-q) mod R +const NHS_ONE int32 = 0x2AC8 // R mod q +const NHS_R2MODP uint64 = 0x1620 // R^2 mod q + +const NHS_DEGREE int = (1 << NHS_LGN) +const NHS_WL uint = 32 + +const NHS_inv int32 = 0xeab +const NHS_invpr int32 = 0x2c2a + +var NHS_roots = [1024]int32{0x2ac8, 0x2baf, 0x299b, 0x685, 0x2f04, 0x158d, 0x2d49, 0x24b5, 0x1edc, 0xab3, 0x2a95, 0x24d, 0x3cb, 0x6a8, 0x12f9, 0x15ba, 0x1861, 0x2a89, 0x1c5c, 0xbe6, 0xc1e, 0x2024, 0x207, 0x19ce, 0x2710, 0x1744, 0x18bc, 0x2cd7, 0x396, 0x18d5, 0x1c45, 0xc4, 0x21a6, 0xe03, 0x2b3c, 0x2d91, 0xc5d, 0x432, 0x1fbc, 0xcae, 0x2512, 0x2979, 0x3b2, 0x714, 0xb2e, 0x1a97, 0x1a03, 0x1bcd, 0x2216, 0x2701, 0xa, 0x263c, 0x1179, 0x200c, 0x2d08, 0x1c34, 0x291, 0x2c99, 0x2a5a, 0x723, 0xb1d, 0x1ccc, 0x1fb6, 0x2f58, 0x2bfe, 0x1cda, 0x2a0, 0x5f1, 0x2de, 0x1fc7, 0x1ea8, 0x1719, 0x2fa7, 0x27ec, 0x20ff, 0x12c0, 0x1ac1, 0x2232, 0x2f9b, 0xd3e, 0x2aed, 0x15f0, 0x11e8, 0xed0, 0x26a, 0x1de5, 0xa3f, 0xf43, 0xebf, 0x204e, 0xac7, 0x2d9c, 0x5ea, 0x25d1, 0xb6, 0x49c, 0x995, 0x2555, 0x26e2, 0x100, 0x1878, 0x5aa, 0x2e10, 0x271c, 0xcb, 0x1b4c, 0x2fb8, 0x25b7, 0x1543, 0x2c7b, 0x241a, 0x2223, 0x20ca, 0x24ed, 0x137, 0x1b65, 0x1dc2, 0x7c7, 0x2ec3, 0xd0c, 0x1169, 0x1c7a, 0x1ea1, 0xf89, 0x2199, 0x291d, 0x1088, 0x2046, 0x256d, 0x2bc7, 0x2e9b, 0x41f, 0x1b55, 0x2b38, 0xd0, 0x2e6a, 0x1755, 0x6bc, 0x2724, 0x3ba, 0x222e, 0x2c5c, 0x2da5, 0x213c, 0x10fe, 0x169a, 0x1552, 0x5d3, 0x300, 0x1b5d, 0x1342, 0x2004, 0x256f, 0x2039, 0x667, 0x23b5, 0x1123, 0xdb, 0x2da0, 0xe1e, 0x2f54, 0x2767, 0x154a, 0x40a, 0x11d3, 0x2821, 0xc09, 0x974, 0x694, 0xfbf, 0x27ba, 0x132, 0x83f, 0x2d06, 0x10e, 0x183f, 0x29ae, 0x28c3, 0x2dc9, 0x1144, 0x2c70, 0x2a4a, 0xf3c, 0x1e32, 0x1171, 0x1e43, 0xdd4, 0x2ddf, 0x28d2, 0xfac, 0x3c4, 0x2f19, 0x10a6, 0x2f7, 0xe1d, 0x828, 0x138f, 0x1332, 0xfab, 0xcf6, 0x13f8, 0x24a0, 0x112d, 0x2717, 0x6e7, 0x1044, 0x36e, 0xfe8, 0x6a, 0xba7, 0x1d69, 0x29ec, 0x23b2, 0xaee, 0x16df, 0x1068, 0x1a7e, 0x253f, 0x24c, 0xb33, 0x2683, 0x15ce, 0x1ad3, 0x1a36, 0xc96, 0xaea, 0x260a, 0xce, 0x28b1, 0xe4f, 0x2b11, 0x5f8, 0x1fc4, 0xe77, 0x2366, 0x11f9, 0x153c, 0x24eb, 0x20cd, 0x1398, 0x22, 0x2b97, 0x249b, 0x8eb, 0x12b2, 0x2fe3, 0x29c1, 0x1b00, 0x2663, 0xeaa, 0x2e06, 0xe0, 0x1569, 0x10f5, 0x284e, 0xa38, 0x201d, 0x1c53, 0x1681, 0x1f6f, 0x2f95, 0x2fe8, 0xacb, 0x1680, 0x17fd, 0x2c39, 0x165a, 0x10bb, 0x29d8, 0x2622, 0x1196, 0x884, 0x2a79, 0x140e, 0x2d80, 0x6fa, 0x11b2, 0x26c4, 0x355, 0x1054, 0x29e9, 0x23ed, 0xbe3, 0x24fa, 0x1fb3, 0x10ac, 0x2919, 0x2584, 0x10a4, 0xe85, 0x650, 0x1893, 0x1dc1, 0xd8e, 0x12dc, 0x2d42, 0x284d, 0xfff, 0x250f, 0xacd, 0x13c3, 0x6cc, 0x1a79, 0x1221, 0x2614, 0x270a, 0x1ea, 0x155, 0x2818, 0x222c, 0x2e5b, 0x25d8, 0x1dbf, 0x191c, 0xb0f, 0xdac, 0x1082, 0x12ef, 0x11b6, 0xfa8, 0x2b72, 0x159d, 0x209e, 0x31b, 0x2c7c, 0x14f7, 0xe09, 0x1bb2, 0x1ec7, 0x2404, 0x20ae, 0x6ad, 0xed6, 0x2b70, 0x1c7b, 0x18d1, 0x2732, 0x12da, 0xd56, 0x5c1, 0x1648, 0x18b7, 0x1605, 0x1bc4, 0x280, 0x2ece, 0xc, 0x1aae, 0x1c4, 0x1cdb, 0x22d6, 0x21d8, 0x257c, 0x51f, 0x211b, 0xff, 0x2ee0, 0x2585, 0xe1, 0x2c35, 0x26db, 0x2971, 0x2208, 0x17e1, 0x21be, 0x135e, 0x28d6, 0x2891, 0x1689, 0x2138, 0xb86, 0x2e3a, 0x1204, 0x2d10, 0x2324, 0xf3f, 0x2508, 0x33d, 0xcb2, 0x292a, 0xe27, 0x2e64, 0x29f8, 0x2d46, 0x9b7, 0x20eb, 0x1b7c, 0x9eb, 0x2b2a, 0x58c, 0x27d0, 0x121b, 0x272e, 0x29f6, 0x2dbd, 0x2697, 0x2aac, 0xd6f, 0x1c67, 0x2c5b, 0x108d, 0x363, 0x249d, 0x2d5e, 0x2fd, 0x2cb2, 0x1f8f, 0x20a4, 0xa19, 0x2ac9, 0x19b1, 0x1581, 0x17a2, 0x29eb, 0x1b72, 0x13b0, 0xee4, 0xa8f, 0x2315, 0x5e6, 0x951, 0x2e29, 0xdad, 0x1f2b, 0x224e, 0x37f, 0x1a72, 0xa91, 0x1407, 0x2df9, 0x3ad, 0x23f7, 0x1a24, 0x1d2a, 0x234b, 0x1df3, 0x1143, 0x7ff, 0x1a6d, 0x2774, 0x2690, 0x2ab5, 0x586, 0x2781, 0x2009, 0x2fdd, 0x2881, 0x399, 0x2fb6, 0x144, 0x137f, 0xfa0, 0x2e4c, 0x1c7f, 0x2fac, 0xb09, 0x1264, 0x127b, 0x198c, 0x2b40, 0x230, 0x1cf4, 0x180b, 0xb58, 0x144a, 0x2aec, 0xfb, 0x2602, 0x14ee, 0x783, 0x1098, 0x23d8, 0x203, 0xe9, 0x108a, 0x14b8, 0xeec, 0xc58, 0x1248, 0x243c, 0x28aa, 0x6bf, 0x27c4, 0x276e, 0x19b8, 0x1d11, 0x2e16, 0x472, 0x1464, 0x24b9, 0x662, 0x1097, 0x2067, 0x20d6, 0x171c, 0x4, 0x682, 0x17bb, 0x1186, 0x4f2, 0x3ff, 0x2a43, 0x1dc7, 0x1ae5, 0x8cc, 0x2e7c, 0x2ef8, 0x2ae0, 0x2904, 0xed4, 0x6c5, 0x14ae, 0xb72, 0x11c3, 0x337, 0x2da3, 0x2916, 0x6d8, 0x1cf9, 0x10ee, 0x1800, 0x1ae4, 0xa0d, 0x101b, 0x1a8d, 0x2e98, 0x24cd, 0x813, 0x1aa4, 0x9b9, 0x680, 0x2349, 0x24d1, 0x20f8, 0xe31, 0x249f, 0x216b, 0x12d9, 0x1d21, 0x19db, 0x191a, 0x1dd0, 0x5df, 0x55c, 0x2b86, 0x213, 0xe9e, 0x1ef1, 0x268a, 0x1d5e, 0x1e20, 0x28c1, 0x1379, 0x249, 0x19de, 0x18b, 0x1e41, 0x2a1e, 0x2612, 0x297, 0x2e96, 0x2102, 0x46, 0x1b9f, 0x1a4d, 0x2050, 0x1b32, 0x568, 0x11f7, 0x1829, 0x870, 0x1f4, 0x1dca, 0x990, 0x1df6, 0x2b62, 0x13ec, 0x9f2, 0x1260, 0x2997, 0x1412, 0x1e6d, 0x1694, 0x11ac, 0x2d8b, 0x276f, 0x26f5, 0x233e, 0x2b44, 0x2f5a, 0x2d37, 0x2cb1, 0xc75, 0x98d, 0x1d56, 0x7ae, 0x10e6, 0x113f, 0x17b8, 0xad3, 0x737, 0x221e, 0x1b70, 0x1f3e, 0x2966, 0x18b2, 0x4fa, 0x2044, 0x1312, 0x154e, 0x2029, 0x700, 0x1b45, 0x27a6, 0x226a, 0x21bf, 0x58d, 0x2f11, 0x2e02, 0x17fc, 0x4d2, 0x1757, 0xcb1, 0x2ef1, 0x2582, 0x1276, 0x881, 0x2fc0, 0x104a, 0x670, 0x274f, 0x2b53, 0x19dd, 0x752, 0x1663, 0xcbd, 0x2b2b, 0x2fc6, 0x13b6, 0x21e6, 0x15f6, 0x126b, 0x2637, 0x1cd9, 0x2f50, 0xe82, 0x5b0, 0x24e0, 0x1350, 0x2f24, 0x21f7, 0x1a16, 0x2f3e, 0x167e, 0x1f7d, 0x28a0, 0x16f0, 0xe33, 0x53b, 0x28c5, 0x1500, 0x2f88, 0x26cc, 0x2018, 0x1604, 0x218b, 0x2cd1, 0x9ee, 0x17f3, 0x5fd, 0x1f5a, 0x2d0, 0x2b46, 0x23cc, 0x503, 0x1c46, 0x1cc3, 0x28e2, 0x243e, 0x122b, 0x2e0c, 0xe37, 0x2611, 0x85e, 0x9b8, 0x1b24, 0x762, 0x19b6, 0x3bc, 0x2d50, 0x2079, 0x18da, 0x170a, 0x800, 0xaa2, 0x135a, 0x1a15, 0x13d1, 0xca, 0x2113, 0x2db9, 0xdb2, 0x1a5c, 0x29a9, 0x1488, 0x14c1, 0x2c9, 0x917, 0x28e7, 0x265c, 0xdab, 0x2ab9, 0x2bc6, 0x105b, 0x1839, 0x219c, 0x50, 0x11da, 0x1802, 0xf56, 0x2e6, 0x2190, 0xddb, 0x56e, 0x9d9, 0x1c81, 0x1016, 0x12d6, 0x296f, 0x14b4, 0x1014, 0x1e64, 0x1d90, 0x89f, 0x2bc2, 0x2777, 0x2819, 0x1c65, 0x1a41, 0x5a2, 0x2cd2, 0x427, 0xd71, 0x29c8, 0x1e58, 0x53f, 0x7c5, 0x1dcd, 0x4a1, 0x1268, 0x2597, 0x2926, 0xee, 0x111b, 0x1038, 0xe6c, 0x22dc, 0x2f2f, 0x441, 0x2cfd, 0x1cb0, 0x6a4, 0x2224, 0x620, 0x5dc, 0x16b1, 0x2a1d, 0x1787, 0x20c7, 0x641, 0xd84, 0x1c05, 0x2d0d, 0x2f52, 0x1b8c, 0xd7d, 0x17e8, 0x1589, 0xc73, 0x151b, 0x4e2, 0x1ae9, 0x1b18, 0xb9b, 0x949, 0x2c60, 0x1e7a, 0xd5, 0x1bdc, 0x1f57, 0x1753, 0x124a, 0x559, 0xb76, 0x2334, 0x12d1, 0x1de1, 0x14b2, 0x2faa, 0x1697, 0x147a, 0x5a1, 0x2c30, 0x1c02, 0x1043, 0x2ee1, 0x2402, 0x1cc8, 0x2a16, 0xff7, 0x1364, 0x1b9a, 0x2a53, 0x2f94, 0x294c, 0x1ee5, 0x1a87, 0x2141, 0xd66, 0x953, 0x28a3, 0x2f30, 0x2477, 0x18e3, 0x1035, 0x1fc1, 0x1d68, 0x2fb3, 0x138c, 0x2487, 0x1bf8, 0xd96, 0x1018, 0x748, 0x244e, 0x15bd, 0x175e, 0x2be, 0x23d, 0x1da, 0x176d, 0xc17, 0x24be, 0x2ebb, 0x7d8, 0x100a, 0x759, 0x1db4, 0x2259, 0x23f4, 0x2d59, 0x2847, 0xbf5, 0x1cfe, 0xa20, 0x258, 0x1180, 0x279c, 0x54, 0x2abf, 0xc5c, 0x9f9, 0x3d5, 0x2ce4, 0x165f, 0x23d9, 0x27b9, 0x6f9, 0x281a, 0x169e, 0x627, 0x156d, 0x1ff8, 0x211, 0x2e34, 0x1724, 0x2c2e, 0x2790, 0x2dd5, 0x2bf2, 0xdbc, 0x2884, 0x20a9, 0x2390, 0x1e1a, 0x1b6a, 0x5f7, 0xab7, 0x1333, 0x16ab, 0x28dd, 0x20, 0x30f, 0x24b6, 0x5c2, 0x1ce4, 0x1400, 0x2669, 0x60, 0x156c, 0xe20, 0x26d4, 0x26ab, 0x1ebb, 0x223d, 0x5b4, 0x2025, 0x1e1c, 0xaae, 0x2e08, 0x6cd, 0x1677, 0x13d9, 0x17b5, 0x1046, 0x1d8c, 0x14eb, 0x18d8, 0x1ce5, 0x2478, 0x16ae, 0xb79, 0x23d4, 0x684, 0x156b, 0x567, 0x1a, 0x29ce, 0x83a, 0x19e8, 0x58e, 0x294a, 0x1136, 0x2319, 0x2fba, 0x1a29, 0x1d, 0x1879, 0x291b, 0x19f6, 0x2c2f, 0x21c9, 0x19bb, 0xbbc, 0x26f9, 0xc22, 0x708, 0x11a1, 0x18d3, 0x7f8, 0x28f8, 0x2427, 0x1deb, 0xaed, 0x26aa, 0x2482, 0x203b, 0x2f05, 0x2b82, 0x192f, 0x2df4, 0x8dc, 0x2877, 0xd5e, 0x240e, 0x775, 0x2dae, 0x1d3e, 0x20ba, 0x215b, 0x22d1, 0xeba, 0xf50, 0xaa8, 0x184a, 0x1f67, 0x2e04, 0xc6e, 0x6dd, 0x1a09, 0x27f, 0x494, 0x1426, 0xae3, 0xe15, 0x65f, 0x13c4, 0x105, 0x872, 0x2667, 0x1ff6, 0xd9f, 0x2ca1, 0x2f39, 0x2657, 0x23fd, 0x2405, 0xb73, 0x2294, 0x1f1e, 0x2eba, 0x110a, 0x2cae, 0x141f, 0x22cd, 0x25d6, 0x11c1, 0x1c, 0x2d8e, 0x161a, 0x1aa8, 0x229e, 0x1bf9, 0x7cf, 0x106d, 0x2c40, 0xd93, 0x255e, 0x28c2, 0xc1a, 0x2f17, 0x7ca, 0x2f63, 0xbf} +var NHS_iroots = [1024]int32{0x2ac8, 0x452, 0x297c, 0x666, 0xb4c, 0x2b8, 0x1a74, 0xfd, 0x1a47, 0x1d08, 0x2959, 0x2c36, 0x2db4, 0x56c, 0x254e, 0x1125, 0x2f3d, 0x13bc, 0x172c, 0x2c6b, 0x32a, 0x1745, 0x18bd, 0x8f1, 0x1633, 0x2dfa, 0xfdd, 0x23e3, 0x241b, 0x13a5, 0x578, 0x17a0, 0xa9, 0x104b, 0x1335, 0x24e4, 0x28de, 0x5a7, 0x368, 0x2d70, 0x13cd, 0x2f9, 0xff5, 0x1e88, 0x9c5, 0x2ff7, 0x900, 0xdeb, 0x1434, 0x15fe, 0x156a, 0x24d3, 0x28ed, 0x2c4f, 0x688, 0xaef, 0x2353, 0x1045, 0x2bcf, 0x23a4, 0x270, 0x4c5, 0x21fe, 0xe5b, 0xfbb, 0x1f79, 0x6e4, 0xe68, 0x2078, 0x1160, 0x1387, 0x1e98, 0x22f5, 0x13e, 0x283a, 0x123f, 0x149c, 0x2eca, 0xb14, 0xf37, 0xdde, 0xbe7, 0x386, 0x1abe, 0xa4a, 0x49, 0x14b5, 0x2f36, 0x8e5, 0x1f1, 0x2a57, 0x1789, 0x2f01, 0x91f, 0xaac, 0x266c, 0x2b65, 0x2f4b, 0xa30, 0x2a17, 0x265, 0x253a, 0xfb3, 0x2142, 0x20be, 0x25c2, 0x121c, 0x2d97, 0x2131, 0x1e19, 0x1a11, 0x514, 0x22c3, 0x66, 0xdcf, 0x1540, 0x1d41, 0xf02, 0x815, 0x5a, 0x18e8, 0x1159, 0x103a, 0x2d23, 0x2a10, 0x2d61, 0x1327, 0x403, 0x25c9, 0x7b3, 0x1f0c, 0x1a98, 0x2f21, 0x1fb, 0x2157, 0x99e, 0x1501, 0x640, 0x1e, 0x1d4f, 0x2716, 0xb66, 0x46a, 0x2fdf, 0x1c69, 0xf34, 0xb16, 0x1ac5, 0x1e08, 0xc9b, 0x218a, 0x103d, 0x2a09, 0x4f0, 0x21b2, 0x750, 0x2f33, 0x9f7, 0x2517, 0x236b, 0x15cb, 0x152e, 0x1a33, 0x97e, 0x24ce, 0x2db5, 0xac2, 0x1583, 0x1f99, 0x1922, 0x2513, 0xc4f, 0x615, 0x1298, 0x245a, 0x2f97, 0x2019, 0x2c93, 0x1fbd, 0x291a, 0x8ea, 0x1ed4, 0xb61, 0x1c09, 0x230b, 0x2056, 0x1ccf, 0x1c72, 0x27d9, 0x21e4, 0x2d0a, 0x1f5b, 0xe8, 0x2c3d, 0x2055, 0x72f, 0x222, 0x222d, 0x11be, 0x1e90, 0x11cf, 0x20c5, 0x5b7, 0x391, 0x1ebd, 0x238, 0x73e, 0x653, 0x17c2, 0x2ef3, 0x2fb, 0x27c2, 0x2ecf, 0x847, 0x2042, 0x296d, 0x268d, 0x23f8, 0x7e0, 0x1e2e, 0x2bf7, 0x1ab7, 0x89a, 0xad, 0x21e3, 0x261, 0x2f26, 0x1ede, 0xc4c, 0x299a, 0xfc8, 0xa92, 0xffd, 0x1cbf, 0x14a4, 0x2d01, 0x2a2e, 0x1aaf, 0x1967, 0x1f03, 0xec5, 0x25c, 0x3a5, 0xdd3, 0x2c47, 0x8dd, 0x2945, 0x18ac, 0x197, 0x2f31, 0x4c9, 0x14ac, 0x2be2, 0x166, 0x43a, 0xa94, 0x1b53, 0x293c, 0x212d, 0x6fd, 0x521, 0x109, 0x185, 0x2735, 0x151c, 0x123a, 0x5be, 0x2c02, 0x2b0f, 0x1e7b, 0x1846, 0x297f, 0x2ffd, 0x18e5, 0xf2b, 0xf9a, 0x1f6a, 0x299f, 0xb48, 0x1b9d, 0x2b8f, 0x1eb, 0x12f0, 0x1649, 0x893, 0x83d, 0x2942, 0x757, 0xbc5, 0x1db9, 0x23a9, 0x2115, 0x1b49, 0x1f77, 0x2f18, 0x2dfe, 0xc29, 0x1f69, 0x287e, 0x1b13, 0x9ff, 0x2f06, 0x515, 0x1bb7, 0x24a9, 0x17f6, 0x130d, 0x2dd1, 0x4c1, 0x1675, 0x1d86, 0x1d9d, 0x24f8, 0x55, 0x1382, 0x1b5, 0x2061, 0x1c82, 0x2ebd, 0x4b, 0x2c68, 0x780, 0x24, 0xff8, 0x880, 0x2a7b, 0x54c, 0x971, 0x88d, 0x1594, 0x2802, 0x1ebe, 0x120e, 0xcb6, 0x12d7, 0x15dd, 0xc0a, 0x2c54, 0x208, 0x1bfa, 0x2570, 0x158f, 0x2c82, 0xdb3, 0x10d6, 0x2254, 0x1d8, 0x26b0, 0x2a1b, 0xcec, 0x2572, 0x211d, 0x1c51, 0x148f, 0x616, 0x185f, 0x1a80, 0x1650, 0x538, 0x25e8, 0xf5d, 0x1072, 0x34f, 0x2d04, 0x2a3, 0xb64, 0x2c9e, 0x1f74, 0x3a6, 0x139a, 0x2292, 0x555, 0x96a, 0x244, 0x60b, 0x8d3, 0x1de6, 0x831, 0x2a75, 0x4d7, 0x2616, 0x1485, 0xf16, 0x264a, 0x2bb, 0x609, 0x19d, 0x21da, 0x6d7, 0x234f, 0x2cc4, 0xaf9, 0x20c2, 0xcdd, 0x2f1, 0x1dfd, 0x1c7, 0x247b, 0xec9, 0x1978, 0x770, 0x72b, 0x1ca3, 0xe43, 0x1820, 0xdf9, 0x690, 0x926, 0x3cc, 0x2f20, 0xa7c, 0x121, 0x2f02, 0xee6, 0x2ae2, 0xa85, 0xe29, 0xd2b, 0x1326, 0x2e3d, 0x1553, 0x2ff5, 0x133, 0x2d81, 0x143d, 0x19fc, 0x174a, 0x19b9, 0x2a40, 0x22ab, 0x1d27, 0x8cf, 0x1730, 0x1386, 0x491, 0x212b, 0x2954, 0xf53, 0xbfd, 0x113a, 0x144f, 0x21f8, 0x1b0a, 0x385, 0x2ce6, 0xf63, 0x1a64, 0x48f, 0x2059, 0x1e4b, 0x1d12, 0x1f7f, 0x2255, 0x24f2, 0x16e5, 0x1242, 0xa29, 0x1a6, 0xdd5, 0x7e9, 0x2eac, 0x2e17, 0x8f7, 0x9ed, 0x1de0, 0x1588, 0x2935, 0x1c3e, 0x2534, 0xaf2, 0x2002, 0x7b4, 0x2bf, 0x1d25, 0x2273, 0x1240, 0x176e, 0x29b1, 0x217c, 0x1f5d, 0xa7d, 0x6e8, 0x1f55, 0x104e, 0xb07, 0x241e, 0xc14, 0x618, 0x1fad, 0x2cac, 0x93d, 0x1e4f, 0x2907, 0x281, 0x1bf3, 0x588, 0x277d, 0x1e6b, 0x9df, 0x629, 0x1f46, 0x19a7, 0x3c8, 0x1804, 0x1981, 0x2536, 0x19, 0x6c, 0x1092, 0x1980, 0x13ae, 0xfe4, 0x2f42, 0x9e, 0x2837, 0xea, 0x23e7, 0x73f, 0xaa3, 0x226e, 0x3c1, 0x1f94, 0x2832, 0x1408, 0xd63, 0x1559, 0x19e7, 0x273, 0x2fe5, 0x1e40, 0xa2b, 0xd34, 0x1be2, 0x353, 0x1ef7, 0x147, 0x10e3, 0xd6d, 0x248e, 0xbfc, 0xc04, 0x9aa, 0xc8, 0x360, 0x2262, 0x100b, 0x99a, 0x278f, 0x2efc, 0x1c3d, 0x29a2, 0x21ec, 0x251e, 0x1bdb, 0x2b6d, 0x2d82, 0x15f8, 0x2924, 0x2393, 0x1fd, 0x109a, 0x17b7, 0x2559, 0x20b1, 0x2147, 0xd30, 0xea6, 0xf47, 0x12c3, 0x253, 0x288c, 0xbf3, 0x22a3, 0x78a, 0x2725, 0x20d, 0x16d2, 0x47f, 0xfc, 0xfc6, 0xb7f, 0x957, 0x2514, 0x1216, 0xbda, 0x709, 0x2809, 0x172e, 0x1e60, 0x28f9, 0x23df, 0x908, 0x2445, 0x1646, 0xe38, 0x3d2, 0x160b, 0x6e6, 0x1788, 0x2fe4, 0x15d8, 0x47, 0xce8, 0x1ecb, 0x6b7, 0x2a73, 0x1619, 0x27c7, 0x633, 0x2fe7, 0x2a9a, 0x1a96, 0x297d, 0xc2d, 0x2488, 0x1953, 0xb89, 0x131c, 0x1729, 0x1b16, 0x1275, 0x1fbb, 0x184c, 0x1c28, 0x198a, 0x2934, 0x1f9, 0x2553, 0x11e5, 0xfdc, 0x2a4d, 0xdc4, 0x1146, 0x956, 0x92d, 0x21e1, 0x1a95, 0x2fa1, 0x998, 0x1c01, 0x131d, 0x2a3f, 0xb4b, 0x2cf2, 0x2fe1, 0x724, 0x1956, 0x1cce, 0x254a, 0x2a0a, 0x1497, 0x11e7, 0xc71, 0xf58, 0x77d, 0x2245, 0x40f, 0x22c, 0x871, 0x3d3, 0x18dd, 0x1cd, 0x2df0, 0x1009, 0x1a94, 0x29da, 0x1963, 0x7e7, 0x2908, 0x848, 0xc28, 0x19a2, 0x31d, 0x2c2c, 0x2608, 0x23a5, 0x542, 0x2fad, 0x865, 0x1e81, 0x2da9, 0x25e1, 0x1303, 0x240c, 0x7ba, 0x2a8, 0xc0d, 0xda8, 0x124d, 0x28a8, 0x1ff7, 0x2829, 0x146, 0xb43, 0x23ea, 0x1894, 0x2e27, 0x2dc4, 0x2d43, 0x18a3, 0x1a44, 0xbb3, 0x28b9, 0x1fe9, 0x226b, 0x1409, 0xb7a, 0x1c75, 0x4e, 0x1299, 0x1040, 0x1fcc, 0x171e, 0xb8a, 0xd1, 0x75e, 0x26ae, 0x229b, 0xec0, 0x157a, 0x111c, 0x6b5, 0x6d, 0x5ae, 0x1467, 0x1c9d, 0x200a, 0x5eb, 0x1339, 0xbff, 0x120, 0x1fbe, 0x13ff, 0x3d1, 0x2a60, 0x1b87, 0x196a, 0x57, 0x1b4f, 0x1220, 0x1d30, 0xccd, 0x248b, 0x2aa8, 0x1db7, 0x18ae, 0x10aa, 0x1425, 0x2f2c, 0x1187, 0x3a1, 0x26b8, 0x2466, 0x14e9, 0x1518, 0x2b1f, 0x1ae6, 0x238e, 0x1a78, 0x1819, 0x2284, 0x1475, 0xaf, 0x2f4, 0x13fc, 0x227d, 0x29c0, 0xf3a, 0x187a, 0x5e4, 0x1950, 0x2a25, 0x29e1, 0xddd, 0x295d, 0x1351, 0x304, 0x2bc0, 0xd2, 0xd25, 0x2195, 0x1fc9, 0x1ee6, 0x2f13, 0x6db, 0xa6a, 0x1d99, 0x2b60, 0x1234, 0x283c, 0x2ac2, 0x11a9, 0x639, 0x2290, 0x2bda, 0x32f, 0x2a5f, 0x15c0, 0x139c, 0x7e8, 0x88a, 0x43f, 0x2762, 0x1271, 0x119d, 0x1fed, 0x1b4d, 0x692, 0x1d2b, 0x1feb, 0x1380, 0x2628, 0x2a93, 0x2226, 0xe71, 0x2d1b, 0x20ab, 0x17ff, 0x1e27, 0x2fb1, 0xe65, 0x17c8, 0x1fa6, 0x43b, 0x548, 0x2256, 0x9a5, 0x71a, 0x26ea, 0x2d38, 0x1b40, 0x1b79, 0x658, 0x15a5, 0x224f, 0x248, 0xeee, 0x2f37, 0x1c30, 0x15ec, 0x1ca7, 0x255f, 0x2801, 0x18f7, 0x1727, 0xf88, 0x2b1, 0x2c45, 0x164b, 0x289f, 0x14dd, 0x2649, 0x27a3, 0x9f0, 0x21ca, 0x1f5, 0x1dd6, 0xbc3, 0x71f, 0x133e, 0x13bb, 0x2afe, 0xc35, 0x4bb, 0x2d31, 0x10a7, 0x2a04, 0x180e, 0x2613, 0x330, 0xe76, 0x19fd, 0xfe9, 0x935, 0x79, 0x1b01, 0x73c, 0x2ac6, 0x21ce, 0x1911, 0x761, 0x1084, 0x1983, 0xc3, 0x15eb, 0xe0a, 0xdd, 0x1cb1, 0xb21, 0x2a51, 0x217f, 0xb1, 0x1328, 0x9ca, 0x1d96, 0x1a0b, 0xe1b, 0x1c4b, 0x3b, 0x4d6, 0x2344, 0x199e, 0x28af, 0x1624, 0x4ae, 0x8b2, 0x2991, 0x1fb7, 0x41, 0x2780, 0x1d8b, 0xa7f, 0x110, 0x2350, 0x18aa, 0x2b2f, 0x1805, 0x1ff, 0xf0, 0x2a74, 0xe42, 0xd97, 0x85b, 0x14bc, 0x2901, 0xfd8, 0x1ab3, 0x1cef, 0xfbd, 0x2b07, 0x174f, 0x69b, 0x10c3, 0x1491, 0xde3, 0x28ca, 0x252e, 0x1849, 0x1ec2, 0x1f1b, 0x2853, 0x12ab, 0x2674, 0x238c, 0x350, 0x2ca, 0xa7, 0x4bd, 0xcc3, 0x90c, 0x892, 0x276, 0x1e55, 0x196d, 0x1194, 0x1bef, 0x66a, 0x1da1, 0x260f, 0x1c15, 0x49f, 0x120b, 0x2671, 0x1237, 0x2e0d, 0x2791, 0x17d8, 0x1e0a, 0x2a99, 0x14cf, 0xfb1, 0x15b4, 0x1462, 0x2fbb, 0xeff, 0x16b, 0x2d6a, 0x9ef, 0x5e3, 0x11c0, 0x2e76, 0x1623, 0x2db8, 0x1c88, 0x740, 0x11e1, 0x12a3, 0x977, 0x1110, 0x2163, 0x2dee, 0x47b, 0x2aa5, 0x2a22, 0x1231, 0x16e7, 0x1626, 0x12e0, 0x1d28, 0xe96, 0xb62, 0x21d0, 0xf09, 0xb30, 0xcb8, 0x2981, 0x2648, 0x155d, 0x27ee, 0xb34, 0x169, 0x1574, 0x1fe6, 0x25f4, 0x151d, 0x1801, 0x1f13, 0x1308, 0x2929, 0x6eb, 0x25e, 0x2cca, 0x1e3e, 0x248f} + +func round(a int32, b int32) int32 { + return (a + b/2) / b +} + +/* constant time absolute vaue */ +func nabs(x int32) int32 { + mask := (x >> 31) + return (x + mask) ^ mask +} + +/* Montgomery stuff */ + +func redc(T uint64) int32 { + m := (uint32(T) * NHS_ND) + return int32((uint64(m)*uint64(NHS_PRIME) + T) >> NHS_WL) +} + +func nres(x int32) int32 { + return redc(uint64(x) * NHS_R2MODP) +} + +func modmul(a int32, b int32) int32 { + return redc(uint64(a) * uint64(b)) +} + +/* NTT code */ +/* Cooley-Tukey NTT */ + +func ntt(x []int32) { + t := NHS_DEGREE / 2 + q := NHS_PRIME + + /* Convert to Montgomery form */ + for j := 0; j < NHS_DEGREE; j++ { + x[j] = nres(x[j]) + } + m := 1 + for m < NHS_DEGREE { + k := 0 + for i := 0; i < m; i++ { + S := NHS_roots[m+i] + for j := k; j < k+t; j++ { + U := x[j] + V := modmul(x[j+t], S) + x[j] = U + V + x[j+t] = U + 2*q - V + } + k += 2 * t + } + t /= 2 + m *= 2 + } +} + +/* Gentleman-Sande INTT */ + +func intt(x []int32) { + t := 1 + q := NHS_PRIME + + m := NHS_DEGREE / 2 + for m > 1 { + k := 0 + for i := 0; i < m; i++ { + S := NHS_iroots[m+i] + for j := k; j < k+t; j++ { + U := x[j] + V := x[j+t] + x[j] = U + V + W := U + int32(NHS_DEGREE)*q - V + x[j+t] = modmul(W, S) + } + k += 2 * t + } + t *= 2 + m /= 2 + } + + /* Last iteration merged with n^-1 */ + + t = NHS_DEGREE / 2 + for j := 0; j < t; j++ { + U := x[j] + V := x[j+t] + W := U + int32(NHS_DEGREE)*q - V + x[j+t] = modmul(W, NHS_invpr) + x[j] = modmul(U+V, NHS_inv) + } + /* convert back from Montgomery to "normal" form */ + for j := 0; j < NHS_DEGREE; j++ { + x[j] = redc(uint64(x[j])) + x[j] -= q + x[j] += (x[j] >> (NHS_WL - 1)) & q + } +} + +/* See https://eprint.iacr.org/2016/1157.pdf */ + +func encode(key []byte, poly []int32) { + + q2 := NHS_PRIME / 2 + j := 0 + for i := 0; i < 256; { + kj := key[j] + j++ + for k := 0; k < 8; k++ { + b := int32(kj & 1) + poly[i] = b * q2 + poly[i+256] = b * q2 + poly[i+512] = b * q2 + poly[i+768] = b * q2 + kj >>= 1 + i++ + } + } +} + +func decode(poly []int32, key []byte) { + q2 := NHS_PRIME / 2 + for i := 0; i < 32; i++ { + key[i] = 0 + } + + j := 0 + for i := 0; i < 256; { + for k := 0; k < 8; k++ { + t := nabs(poly[i]-q2) + nabs(poly[i+256]-q2) + nabs(poly[i+512]-q2) + nabs(poly[i+768]-q2) + b := t - NHS_PRIME + b = (b >> 31) & 1 + key[j] = (key[j] >> 1) + byte(b<<7) + i++ + } + j++ + } +} + +/* convert 32-byte seed to random polynomial */ + +func parse(seed []byte, poly []int32) { + var hash [4 * NHS_DEGREE]byte + sh := NewSHA3(SHA3_SHAKE128) + + for i := 0; i < 32; i++ { + sh.Process(seed[i]) + } + sh.Shake(hash[:], 4*NHS_DEGREE) + + j := 0 + for i := 0; i < NHS_DEGREE; i++ { + n := int32(hash[j] & 0x7f) + n <<= 8 + n += int32(hash[j+1]) + n <<= 8 + n += int32(hash[j+2]) + n <<= 8 + n += int32(hash[j+3]) + j += 4 + poly[i] = nres(n) + //poly[i]=modmul(n,NHS_ONE) // reduce 31-bit random number mod q + } +} + +/* Compress 14 bits polynomial coefficients into byte array */ +/* 7 bytes is 3x14 */ + +func nhs_pack(poly []int32, array []byte) { + j := 0 + for i := 0; i < NHS_DEGREE; { + a := poly[i] + b := poly[i+1] + c := poly[i+2] + d := poly[i+3] + i += 4 + array[j] = byte(a & 0xff) + array[j+1] = byte(((a >> 8) | (b << 6)) & 0xff) + array[j+2] = byte((b >> 2) & 0xff) + array[j+3] = byte(((b >> 10) | (c << 4)) & 0xff) + array[j+4] = byte((c >> 4) & 0xff) + array[j+5] = byte(((c >> 12) | (d << 2)) & 0xff) + array[j+6] = byte(d >> 6) + j += 7 + } +} + +func nhs_unpack(array []byte, poly []int32) { + j := 0 + for i := 0; i < NHS_DEGREE; { + a := int32((array[j]) & 0xff) + b := int32((array[j+1]) & 0xff) + c := int32((array[j+2]) & 0xff) + d := int32((array[j+3]) & 0xff) + e := int32((array[j+4]) & 0xff) + f := int32((array[j+5]) & 0xff) + g := int32((array[j+6]) & 0xff) + j += 7 + poly[i] = a | ((b & 0x3f) << 8) + poly[i+1] = (b >> 6) | (c << 2) | ((d & 0xf) << 10) + poly[i+2] = (d >> 4) | (e << 4) | ((f & 3) << 12) + poly[i+3] = (f >> 2) | (g << 6) + i += 4 + } +} + +/* See https://eprint.iacr.org/2016/1157.pdf */ + +func compress(poly []int32, array []byte) { + + var col int32 = 0 + j := 0 + for i := 0; i < NHS_DEGREE; { + for k := 0; k < 8; k++ { + b := round((poly[i]*8), NHS_PRIME) & 7 + col = (col << 3) + b + i += 1 + } + array[j] = byte(col & 0xff) + array[j+1] = byte((col >> 8) & 0xff) + array[j+2] = byte((col >> 16) & 0xff) + j += 3 + col = 0 + } +} + +func decompress(array []byte, poly []int32) { + var col int32 = 0 + j := 0 + for i := 0; i < NHS_DEGREE; { + col = int32(array[j+2]) & 0xff + col = (col << 8) + (int32(array[j+1]) & 0xff) + col = (col << 8) + (int32(array[j]) & 0xff) + j += 3 + for k := 0; k < 8; k++ { + b := (col & 0xe00000) >> 21 + col <<= 3 + poly[i] = round((b * NHS_PRIME), 8) + i += 1 + } + } +} + +/* generate centered binomial distribution */ + +func error(rng *RAND, poly []int32) { + var r int32 + for i := 0; i < NHS_DEGREE; i++ { + n1 := (int32(rng.GetByte()) & 0xff) + ((int32(rng.GetByte()) & 0xff) << 8) + n2 := (int32(rng.GetByte()) & 0xff) + ((int32(rng.GetByte()) & 0xff) << 8) + r = 0 + for j := 0; j < 16; j++ { + r += (n1 & 1) - (n2 & 1) + n1 >>= 1 + n2 >>= 1 + } + poly[i] = (r + NHS_PRIME) + } +} + +func redc_it(p []int32) { + for i := 0; i < NHS_DEGREE; i++ { + p[i] = redc(uint64(p[i])) + } +} + +func nres_it(p []int32) { + for i := 0; i < NHS_DEGREE; i++ { + p[i] = nres(p[i]) + } +} + +func poly_mul(p1 []int32, p2 []int32, p3 []int32) { + for i := 0; i < NHS_DEGREE; i++ { + p1[i] = modmul(p2[i], p3[i]) + } +} + +func poly_add(p1 []int32, p2 []int32, p3 []int32) { + for i := 0; i < NHS_DEGREE; i++ { + p1[i] = (p2[i] + p3[i]) + } +} + +func poly_sub(p1 []int32, p2 []int32, p3 []int32) { + for i := 0; i < NHS_DEGREE; i++ { + p1[i] = (p2[i] + NHS_PRIME - p3[i]) + } +} + +/* reduces inputs < 2q */ +func poly_soft_reduce(poly []int32) { + for i := 0; i < NHS_DEGREE; i++ { + e := poly[i] - NHS_PRIME + poly[i] = e + ((e >> (NHS_WL - 1)) & NHS_PRIME) + } +} + +/* fully reduces modulo q */ +func poly_hard_reduce(poly []int32) { + for i := 0; i < NHS_DEGREE; i++ { + e := modmul(poly[i], NHS_ONE) + e = e - NHS_PRIME + poly[i] = e + ((e >> (NHS_WL - 1)) & NHS_PRIME) + } +} + +/* API files */ + +func NHS_SERVER_1(rng *RAND, SB []byte, S []byte) { + var seed [32]byte + var array [1792]byte + var s [NHS_DEGREE]int32 + var e [NHS_DEGREE]int32 + var b [NHS_DEGREE]int32 + + for i := 0; i < 32; i++ { + seed[i] = rng.GetByte() + } + + parse(seed[:], b[:]) + + error(rng, e[:]) + error(rng, s[:]) + + ntt(s[:]) + ntt(e[:]) + poly_mul(b[:], b[:], s[:]) + poly_add(b[:], b[:], e[:]) + poly_hard_reduce(b[:]) + + redc_it(b[:]) + nhs_pack(b[:], array[:]) + + for i := 0; i < 32; i++ { + SB[i] = seed[i] + } + + for i := 0; i < 1792; i++ { + SB[i+32] = array[i] + } + + poly_hard_reduce(s[:]) + nhs_pack(s[:], array[:]) + + for i := 0; i < 1792; i++ { + S[i] = array[i] + } + +} + +func NHS_CLIENT(rng *RAND, SB []byte, UC []byte, KEY []byte) { + sh := NewSHA3(SHA3_HASH256) + var seed [32]byte + var array [1792]byte + var key [32]byte + var cc [384]byte + + var sd [NHS_DEGREE]int32 + var ed [NHS_DEGREE]int32 + var u [NHS_DEGREE]int32 + var k [NHS_DEGREE]int32 + var c [NHS_DEGREE]int32 + + error(rng, sd[:]) + error(rng, ed[:]) + + ntt(sd[:]) + ntt(ed[:]) + + for i := 0; i < 32; i++ { + seed[i] = SB[i] + } + + for i := 0; i < 1792; i++ { + array[i] = SB[i+32] + } + + parse(seed[:], u[:]) + + poly_mul(u[:], u[:], sd[:]) + poly_add(u[:], u[:], ed[:]) + poly_hard_reduce(u[:]) + + for i := 0; i < 32; i++ { + key[i] = rng.GetByte() + } + + for i := 0; i < 32; i++ { + sh.Process(key[i]) + } + hkey := sh.Hash() + + encode(hkey[:], k[:]) + + nhs_unpack(array[:], c[:]) + nres_it(c[:]) + + poly_mul(c[:], c[:], sd[:]) + intt(c[:]) + error(rng, ed[:]) + poly_add(c[:], c[:], ed[:]) + poly_add(c[:], c[:], k[:]) + + compress(c[:], cc[:]) + + sh.Init(SHA3_HASH256) + for i := 0; i < 32; i++ { + sh.Process(hkey[i]) + } + fkey := sh.Hash() + + for i := 0; i < 32; i++ { + KEY[i] = fkey[i] + } + + redc_it(u[:]) + nhs_pack(u[:], array[:]) + + for i := 0; i < 1792; i++ { + UC[i] = array[i] + } + + for i := 0; i < 384; i++ { + UC[i+1792] = cc[i] + } +} + +func NHS_SERVER_2(S []byte, UC []byte, KEY []byte) { + sh := NewSHA3(SHA3_HASH256) + + var c [NHS_DEGREE]int32 + var s [NHS_DEGREE]int32 + var k [NHS_DEGREE]int32 + + var array [1792]byte + var key [32]byte + var cc [384]byte + + for i := 0; i < 1792; i++ { + array[i] = UC[i] + } + + nhs_unpack(array[:], k[:]) + nres_it(k[:]) + + for i := 0; i < 384; i++ { + cc[i] = UC[i+1792] + } + + decompress(cc[:], c[:]) + + for i := 0; i < 1792; i++ { + array[i] = S[i] + } + + nhs_unpack(array[:], s[:]) + + poly_mul(k[:], k[:], s[:]) + intt(k[:]) + poly_sub(k[:], c[:], k[:]) + poly_soft_reduce(k[:]) + + decode(k[:], key[:]) + + for i := 0; i < 32; i++ { + sh.Process(key[i]) + } + hkey := sh.Hash() + + for i := 0; i < 32; i++ { + KEY[i] = hkey[i] + } +} + +/* +func main() { + + srng:=NewRAND() + var sraw [100]byte + for i:=0;i<100;i++ {sraw[i]=byte(i+1)} + srng.Seed(100,sraw[:]) + + crng:=NewRAND() + var craw [100]byte + for i:=0;i<100;i++ {craw[i]=byte(i+2)} + crng.Seed(100,craw[:]) + + var S [1792] byte + + var SB [1824] byte + NHS_SERVER_1(srng,SB[:],S[:]) + var UC [2176] byte + var KEYB [32] byte + NHS_CLIENT(crng,SB[:],UC[:],KEYB[:]) + + fmt.Printf("Bob's Key= ") + for i:=0;i<32;i++ { + fmt.Printf("%02x", KEYB[i]) + } + fmt.Printf("\n") + var KEYA [32] byte + NHS_SERVER_2(S[:],UC[:],KEYA[:]) + + fmt.Printf("Alice Key= ") + for i:=0;i<32;i++ { + fmt.Printf("%02x", KEYA[i]) + } + +} +*/ diff --git a/vendor/github.com/hyperledger/fabric-amcl/core/RAND.go b/vendor/github.com/hyperledger/fabric-amcl/core/RAND.go new file mode 100644 index 00000000000..842e605fd08 --- /dev/null +++ b/vendor/github.com/hyperledger/fabric-amcl/core/RAND.go @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2012-2020 MIRACL UK Ltd. + * + * This file is part of MIRACL Core + * (see https://github.com/miracl/core). + * + * 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. + */ + +/* + * Cryptographic strong random number generator + * + * Unguessable seed -> SHA -> PRNG internal state -> SHA -> random numbers + * Slow - but secure + * + * See ftp://ftp.rsasecurity.com/pub/pdfs/bull-1.pdf for a justification + */ + +/* Marsaglia & Zaman Random number generator constants */ + +package core + +//import "fmt" + +const rand_NK int = 21 +const rand_NJ int = 6 +const rand_NV int = 8 + +type RAND struct { + ira [rand_NK]uint32 /* random number... */ + rndptr int + borrow uint32 + pool_ptr int + pool [32]byte +} + +/* Terminate and clean up */ +func (R *RAND) Clean() { /* kill internal state */ + R.pool_ptr = 0 + R.rndptr = 0 + for i := 0; i < 32; i++ { + R.pool[i] = 0 + } + for i := 0; i < rand_NK; i++ { + R.ira[i] = 0 + } + R.borrow = 0 +} + +func NewRAND() *RAND { + R := new(RAND) + R.Clean() + return R +} + +func (R *RAND) sbrand() uint32 { /* Marsaglia & Zaman random number generator */ + R.rndptr++ + if R.rndptr < rand_NK { + return R.ira[R.rndptr] + } + R.rndptr = 0 + k := rand_NK - rand_NJ + for i := 0; i < rand_NK; i++ { /* calculate next NK values */ + if k == rand_NK { + k = 0 + } + t := R.ira[k] + pdiff := t - R.ira[i] - R.borrow + if pdiff < t { + R.borrow = 0 + } + if pdiff > t { + R.borrow = 1 + } + R.ira[i] = pdiff + k++ + } + + return R.ira[0] +} + +func (R *RAND) sirand(seed uint32) { + var m uint32 = 1 + R.borrow = 0 + R.rndptr = 0 + R.ira[0] ^= seed + for i := 1; i < rand_NK; i++ { /* fill initialisation vector */ + in := (rand_NV * i) % rand_NK + R.ira[in] ^= m /* note XOR */ + t := m + m = seed - m + seed = t + } + for i := 0; i < 10000; i++ { + R.sbrand() + } /* "warm-up" & stir the generator */ +} + +func (R *RAND) fill_pool() { + sh := NewHASH256() + for i := 0; i < 128; i++ { + sh.Process(byte(R.sbrand() & 0xff)) + } + W := sh.Hash() + for i := 0; i < 32; i++ { + R.pool[i] = W[i] + } + R.pool_ptr = 0 +} + +func pack(b [4]byte) uint32 { /* pack 4 bytes into a 32-bit Word */ + return (((uint32(b[3])) & 0xff) << 24) | ((uint32(b[2]) & 0xff) << 16) | ((uint32(b[1]) & 0xff) << 8) | (uint32(b[0]) & 0xff) +} + +/* Initialize RNG with some real entropy from some external source */ +func (R *RAND) Seed(rawlen int, raw []byte) { /* initialise from at least 128 byte string of raw random entropy */ + var b [4]byte + sh := NewHASH256() + R.pool_ptr = 0 + + for i := 0; i < rand_NK; i++ { + R.ira[i] = 0 + } + if rawlen > 0 { + for i := 0; i < rawlen; i++ { + sh.Process(raw[i]) + } + digest := sh.Hash() + + /* initialise PRNG from distilled randomness */ + + for i := 0; i < 8; i++ { + b[0] = digest[4*i] + b[1] = digest[4*i+1] + b[2] = digest[4*i+2] + b[3] = digest[4*i+3] + R.sirand(pack(b)) + } + } + R.fill_pool() +} + +/* get random byte */ +func (R *RAND) GetByte() byte { + r := R.pool[R.pool_ptr] + R.pool_ptr++ + if R.pool_ptr >= 32 { + R.fill_pool() + } + return byte(r & 0xff) +} + +/* test main program */ +/* +func main() { + var raw [100]byte + rng:=NewRAND() + + rng.Clean() + for i:=0;i<100;i++ {raw[i]=byte(i)} + + rng.Seed(100,raw[:]) + + for i:=0;i<1000;i++ { + fmt.Printf("%03d ",rng.GetByte()) + } +} +*/ diff --git a/vendor/github.com/hyperledger/fabric-amcl/core/SHA3.go b/vendor/github.com/hyperledger/fabric-amcl/core/SHA3.go new file mode 100644 index 00000000000..3402caaaf31 --- /dev/null +++ b/vendor/github.com/hyperledger/fabric-amcl/core/SHA3.go @@ -0,0 +1,303 @@ +/* + * Copyright (c) 2012-2020 MIRACL UK Ltd. + * + * This file is part of MIRACL Core + * (see https://github.com/miracl/core). + * + * 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. + */ + +/* + * Implementation of the Secure Hashing Algorithm (SHA-384) + * + * Generates a 384 bit message digest. It should be impossible to come + * come up with two messages that hash to the same value ("collision free"). + * + * For use with byte-oriented messages only. + */ + +//package main + +package core + +//import "fmt" + +const SHA3_HASH224 int = 28 +const SHA3_HASH256 int = 32 +const SHA3_HASH384 int = 48 +const SHA3_HASH512 int = 64 +const SHA3_SHAKE128 int = 16 +const SHA3_SHAKE256 int = 32 + +const sha3_ROUNDS int = 24 + +var sha3_RC = [24]uint64{ + 0x0000000000000001, 0x0000000000008082, 0x800000000000808A, 0x8000000080008000, + 0x000000000000808B, 0x0000000080000001, 0x8000000080008081, 0x8000000000008009, + 0x000000000000008A, 0x0000000000000088, 0x0000000080008009, 0x000000008000000A, + 0x000000008000808B, 0x800000000000008B, 0x8000000000008089, 0x8000000000008003, + 0x8000000000008002, 0x8000000000000080, 0x000000000000800A, 0x800000008000000A, + 0x8000000080008081, 0x8000000000008080, 0x0000000080000001, 0x8000000080008008} + +type SHA3 struct { + length uint64 + rate int + len int + s [5][5]uint64 +} + +/* functions */ + +func sha3_ROTL(x uint64, n uint64) uint64 { + return (((x) << n) | ((x) >> (64 - n))) +} + +func (H *SHA3) transform() { /* basic transformation step */ + + var c [5]uint64 + var d [5]uint64 + var b [5][5]uint64 + + for k := 0; k < sha3_ROUNDS; k++ { + c[0] = H.s[0][0] ^ H.s[0][1] ^ H.s[0][2] ^ H.s[0][3] ^ H.s[0][4] + c[1] = H.s[1][0] ^ H.s[1][1] ^ H.s[1][2] ^ H.s[1][3] ^ H.s[1][4] + c[2] = H.s[2][0] ^ H.s[2][1] ^ H.s[2][2] ^ H.s[2][3] ^ H.s[2][4] + c[3] = H.s[3][0] ^ H.s[3][1] ^ H.s[3][2] ^ H.s[3][3] ^ H.s[3][4] + c[4] = H.s[4][0] ^ H.s[4][1] ^ H.s[4][2] ^ H.s[4][3] ^ H.s[4][4] + + d[0] = c[4] ^ sha3_ROTL(c[1], 1) + d[1] = c[0] ^ sha3_ROTL(c[2], 1) + d[2] = c[1] ^ sha3_ROTL(c[3], 1) + d[3] = c[2] ^ sha3_ROTL(c[4], 1) + d[4] = c[3] ^ sha3_ROTL(c[0], 1) + + for i := 0; i < 5; i++ { + for j := 0; j < 5; j++ { + H.s[i][j] ^= d[i] + } + } + + b[0][0] = H.s[0][0] + b[1][3] = sha3_ROTL(H.s[0][1], 36) + b[2][1] = sha3_ROTL(H.s[0][2], 3) + b[3][4] = sha3_ROTL(H.s[0][3], 41) + b[4][2] = sha3_ROTL(H.s[0][4], 18) + + b[0][2] = sha3_ROTL(H.s[1][0], 1) + b[1][0] = sha3_ROTL(H.s[1][1], 44) + b[2][3] = sha3_ROTL(H.s[1][2], 10) + b[3][1] = sha3_ROTL(H.s[1][3], 45) + b[4][4] = sha3_ROTL(H.s[1][4], 2) + + b[0][4] = sha3_ROTL(H.s[2][0], 62) + b[1][2] = sha3_ROTL(H.s[2][1], 6) + b[2][0] = sha3_ROTL(H.s[2][2], 43) + b[3][3] = sha3_ROTL(H.s[2][3], 15) + b[4][1] = sha3_ROTL(H.s[2][4], 61) + + b[0][1] = sha3_ROTL(H.s[3][0], 28) + b[1][4] = sha3_ROTL(H.s[3][1], 55) + b[2][2] = sha3_ROTL(H.s[3][2], 25) + b[3][0] = sha3_ROTL(H.s[3][3], 21) + b[4][3] = sha3_ROTL(H.s[3][4], 56) + + b[0][3] = sha3_ROTL(H.s[4][0], 27) + b[1][1] = sha3_ROTL(H.s[4][1], 20) + b[2][4] = sha3_ROTL(H.s[4][2], 39) + b[3][2] = sha3_ROTL(H.s[4][3], 8) + b[4][0] = sha3_ROTL(H.s[4][4], 14) + + for i := 0; i < 5; i++ { + for j := 0; j < 5; j++ { + H.s[i][j] = b[i][j] ^ (^b[(i+1)%5][j] & b[(i+2)%5][j]) + } + } + + H.s[0][0] ^= sha3_RC[k] + } +} + +/* Initialise Hash function */ +func (H *SHA3) Init(olen int) { + for i := 0; i < 5; i++ { + for j := 0; j < 5; j++ { + H.s[i][j] = 0 + } + } + H.length = 0 + H.len = olen + H.rate = 200 - 2*olen +} + +func NewSHA3(olen int) *SHA3 { + H := new(SHA3) + H.Init(olen) + return H +} + +func NewSHA3copy(HC *SHA3) *SHA3 { + H := new(SHA3) + for i := 0; i < 5; i++ { + for j := 0; j < 5; j++ { + H.s[i][j] = HC.s[i][j] + } + } + H.length=HC.length + H.len=HC.len + H.rate=HC.rate + return H +} + +/* process a single byte */ +func (H *SHA3) Process(byt byte) { /* process the next message byte */ + cnt := int(H.length % uint64(H.rate)) + b := cnt % 8 + cnt /= 8 + i := cnt % 5 + j := cnt / 5 + H.s[i][j] ^= uint64(byt&0xff) << uint(8*b) + H.length++ + if int(H.length%uint64(H.rate)) == 0 { + H.transform() + } +} + +/* process an array of bytes */ +func (H *SHA3) Process_array(b []byte) { + for i := 0; i < len(b); i++ { + H.Process((b[i])) + } +} + +/* process a 32-bit integer */ +func (H *SHA3) Process_num(n int32) { + H.Process(byte((n >> 24) & 0xff)) + H.Process(byte((n >> 16) & 0xff)) + H.Process(byte((n >> 8) & 0xff)) + H.Process(byte(n & 0xff)) +} + + +/* squeeze the sponge */ +func (H *SHA3) Squeeze(buff []byte, olen int) { + // olen:=len(buff) + done := false + m := 0 + /* extract by columns */ + for { + for j := 0; j < 5; j++ { + for i := 0; i < 5; i++ { + el := H.s[i][j] + for k := 0; k < 8; k++ { + buff[m] = byte(el & 0xff) + m++ + if m >= olen || (m%H.rate) == 0 { + done = true + break + } + el >>= 8 + } + if done { + break + } + } + if done { + break + } + } + if m >= olen { + break + } + done = false + H.transform() + + } +} + +/* Generate Hash */ +func (H *SHA3) Hash() []byte { /* generate a SHA3 hash of appropriate size */ + var digest [64]byte + q := H.rate - int(H.length%uint64(H.rate)) + if q == 1 { + H.Process(0x86) + } else { + H.Process(0x06) + for int(H.length%uint64(H.rate)) != (H.rate - 1) { + H.Process(0x00) + } + H.Process(0x80) + } + H.Squeeze(digest[:], H.len) + return digest[0:H.len] +} + +func (H *SHA3) Continuing_Hash() [] byte { + sh := NewSHA3copy(H) + return sh.Hash() +} + +func (H *SHA3) Shake(hash []byte, olen int) { /* generate a SHA3 hash of appropriate size */ + q := H.rate - int(H.length%uint64(H.rate)) + if q == 1 { + H.Process(0x9f) + } else { + H.Process(0x1f) + for int(H.length%uint64(H.rate)) != H.rate-1 { + H.Process(0x00) + } + H.Process(0x80) + } + H.Squeeze(hash, olen) +} + +func (H *SHA3) Continuing_Shake(hash []byte, olen int) { + sh := NewSHA3copy(H) + sh.Shake(hash,olen) +} + +/* test program: should produce digest */ +//916f6061fe879741ca6469b43971dfdb28b1a32dc36cb3254e812be27aad1d18 +//afebb2ef542e6579c50cad06d2e578f9f8dd6881d7dc824d26360feebf18a4fa73e3261122948efcfd492e74e82e2189ed0fb440d187f382270cb455f21dd185 +//98be04516c04cc73593fef3ed0352ea9f6443942d6950e29a372a681c3deaf4535423709b02843948684e029010badcc0acd8303fc85fdad3eabf4f78cae165635f57afd28810fc2 + +/* +func main() { + + test := []byte("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu") + var digest [172]byte + + sh:=NewSHA3(SHA3_HASH256) + for i:=0;i=256 || nsr<2 || nsr>=256 { + S.ID=0 + S.NSR=0 + S.B=nil + return S + } + S.ID=byte(id) + S.NSR=byte(nsr) + m:=len(M) + S.B=make([]byte,m) + rng := NewRAND() + rng.Clean() + rng.Seed(len(R),R) + for j:=0;j sc.maxClientStreamID) { + // Discard all DATA frames if the GOAWAY is due to an + // error, or: + // + // Section 6.8: After sending a GOAWAY frame, the sender + // can discard frames for streams initiated by the + // receiver with identifiers higher than the identified + // last stream. return nil } - data := f.Data() - // "If a DATA frame is received whose stream is not in "open" - // or "half closed (local)" state, the recipient MUST respond - // with a stream error (Section 5.4.2) of type STREAM_CLOSED." - id := f.Header().StreamID + data := f.Data() state, st := sc.state(id) if id == 0 || state == stateIdle { + // Section 6.1: "DATA frames MUST be associated with a + // stream. If a DATA frame is received whose stream + // identifier field is 0x0, the recipient MUST respond + // with a connection error (Section 5.4.1) of type + // PROTOCOL_ERROR." + // // Section 5.1: "Receiving any frame other than HEADERS // or PRIORITY on a stream in this state MUST be // treated as a connection error (Section 5.4.1) of // type PROTOCOL_ERROR." return ConnectionError(ErrCodeProtocol) } + + // "If a DATA frame is received whose stream is not in "open" + // or "half closed (local)" state, the recipient MUST respond + // with a stream error (Section 5.4.2) of type STREAM_CLOSED." if st == nil || state != stateOpen || st.gotTrailerHeader || st.resetQueued { // This includes sending a RST_STREAM if the stream is // in stateHalfClosedLocal (which currently means that diff --git a/vendor/golang.org/x/net/idna/idna10.0.0.go b/vendor/golang.org/x/net/idna/idna10.0.0.go index a98a31f4038..7e69ee1b22e 100644 --- a/vendor/golang.org/x/net/idna/idna10.0.0.go +++ b/vendor/golang.org/x/net/idna/idna10.0.0.go @@ -4,6 +4,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build go1.10 // +build go1.10 // Package idna implements IDNA2008 using the compatibility processing diff --git a/vendor/golang.org/x/net/idna/idna9.0.0.go b/vendor/golang.org/x/net/idna/idna9.0.0.go index 8842146b5d9..7c7456374c1 100644 --- a/vendor/golang.org/x/net/idna/idna9.0.0.go +++ b/vendor/golang.org/x/net/idna/idna9.0.0.go @@ -4,6 +4,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !go1.10 // +build !go1.10 // Package idna implements IDNA2008 using the compatibility processing diff --git a/vendor/golang.org/x/net/idna/tables10.0.0.go b/vendor/golang.org/x/net/idna/tables10.0.0.go index 54fddb4b16c..d1d62ef459b 100644 --- a/vendor/golang.org/x/net/idna/tables10.0.0.go +++ b/vendor/golang.org/x/net/idna/tables10.0.0.go @@ -1,5 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. +//go:build go1.10 && !go1.13 // +build go1.10,!go1.13 package idna diff --git a/vendor/golang.org/x/net/idna/tables11.0.0.go b/vendor/golang.org/x/net/idna/tables11.0.0.go index 8ce0811fdf3..167efba7125 100644 --- a/vendor/golang.org/x/net/idna/tables11.0.0.go +++ b/vendor/golang.org/x/net/idna/tables11.0.0.go @@ -1,5 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. +//go:build go1.13 && !go1.14 // +build go1.13,!go1.14 package idna diff --git a/vendor/golang.org/x/net/idna/tables12.0.0.go b/vendor/golang.org/x/net/idna/tables12.0.0.go index f39f0cb4cd8..ab40f7bcc3b 100644 --- a/vendor/golang.org/x/net/idna/tables12.0.0.go +++ b/vendor/golang.org/x/net/idna/tables12.0.0.go @@ -1,5 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. +//go:build go1.14 && !go1.16 // +build go1.14,!go1.16 package idna diff --git a/vendor/golang.org/x/net/idna/tables13.0.0.go b/vendor/golang.org/x/net/idna/tables13.0.0.go index e8c7a36d7a7..390c5e56d2a 100644 --- a/vendor/golang.org/x/net/idna/tables13.0.0.go +++ b/vendor/golang.org/x/net/idna/tables13.0.0.go @@ -1,5 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. +//go:build go1.16 // +build go1.16 package idna diff --git a/vendor/golang.org/x/net/idna/tables9.0.0.go b/vendor/golang.org/x/net/idna/tables9.0.0.go index 8b65fa16783..4074b5332e3 100644 --- a/vendor/golang.org/x/net/idna/tables9.0.0.go +++ b/vendor/golang.org/x/net/idna/tables9.0.0.go @@ -1,5 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. +//go:build !go1.10 // +build !go1.10 package idna diff --git a/vendor/golang.org/x/sys/cpu/cpu_aix.go b/vendor/golang.org/x/sys/cpu/cpu_aix.go index 464a209cf59..28b521643b1 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_aix.go +++ b/vendor/golang.org/x/sys/cpu/cpu_aix.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix // +build aix package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go index 7f7f272a014..ccf542a73da 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build gc // +build gc package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go b/vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go index 75a95566161..0af2f248412 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go +++ b/vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build gc // +build gc package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_gc_x86.go b/vendor/golang.org/x/sys/cpu/cpu_gc_x86.go index 4adb89cf9cc..fa7cdb9bcd5 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_gc_x86.go +++ b/vendor/golang.org/x/sys/cpu/cpu_gc_x86.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (386 || amd64 || amd64p32) && gc // +build 386 amd64 amd64p32 // +build gc diff --git a/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go index 53ca8d65c37..2aff3189116 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build gccgo // +build gccgo package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go b/vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go index aa986f77825..4bfbda61993 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go +++ b/vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build gccgo // +build gccgo package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go b/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go index ba49b91bd39..8478a6d5979 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go +++ b/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (386 || amd64 || amd64p32) && gccgo // +build 386 amd64 amd64p32 // +build gccgo diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux.go b/vendor/golang.org/x/sys/cpu/cpu_linux.go index 6fc874f7fef..159a686f6f7 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_linux.go +++ b/vendor/golang.org/x/sys/cpu/cpu_linux.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !386 && !amd64 && !amd64p32 && !arm64 // +build !386,!amd64,!amd64p32,!arm64 package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux_mips64x.go b/vendor/golang.org/x/sys/cpu/cpu_linux_mips64x.go index 5a418900538..6000db4cdd1 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_linux_mips64x.go +++ b/vendor/golang.org/x/sys/cpu/cpu_linux_mips64x.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && (mips64 || mips64le) // +build linux // +build mips64 mips64le diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go b/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go index 42b5d33cb69..f4992b1a593 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go +++ b/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && !arm && !arm64 && !mips64 && !mips64le && !ppc64 && !ppc64le && !s390x // +build linux,!arm,!arm64,!mips64,!mips64le,!ppc64,!ppc64le,!s390x package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go b/vendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go index 99f8a6399ef..021356d6deb 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go +++ b/vendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && (ppc64 || ppc64le) // +build linux // +build ppc64 ppc64le diff --git a/vendor/golang.org/x/sys/cpu/cpu_mips64x.go b/vendor/golang.org/x/sys/cpu/cpu_mips64x.go index 57b5b677de0..f4063c66423 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_mips64x.go +++ b/vendor/golang.org/x/sys/cpu/cpu_mips64x.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_mipsx.go b/vendor/golang.org/x/sys/cpu/cpu_mipsx.go index cfc1946b7bb..07c4e36d8f5 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_mipsx.go +++ b/vendor/golang.org/x/sys/cpu/cpu_mipsx.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_other_arm.go b/vendor/golang.org/x/sys/cpu/cpu_other_arm.go index b412efc1bd1..d7b4fb4ccc2 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_other_arm.go +++ b/vendor/golang.org/x/sys/cpu/cpu_other_arm.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !linux && arm // +build !linux,arm package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go index 16c1c4090ee..f8c484f589f 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !linux,!netbsd -// +build arm64 +//go:build !linux && !netbsd && arm64 +// +build !linux,!netbsd,arm64 package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_other_mips64x.go b/vendor/golang.org/x/sys/cpu/cpu_other_mips64x.go index f49fad67783..0dafe9644a5 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_other_mips64x.go +++ b/vendor/golang.org/x/sys/cpu/cpu_other_mips64x.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !linux && (mips64 || mips64le) // +build !linux // +build mips64 mips64le diff --git a/vendor/golang.org/x/sys/cpu/cpu_ppc64x.go b/vendor/golang.org/x/sys/cpu/cpu_ppc64x.go index d28d675b5f1..4e8acd16583 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_ppc64x.go +++ b/vendor/golang.org/x/sys/cpu/cpu_ppc64x.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_riscv64.go b/vendor/golang.org/x/sys/cpu/cpu_riscv64.go index 8b08de341b8..bd6c128af9b 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_riscv64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_riscv64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build riscv64 // +build riscv64 package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_wasm.go b/vendor/golang.org/x/sys/cpu/cpu_wasm.go index 5382f2a227a..7747d888a69 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_wasm.go +++ b/vendor/golang.org/x/sys/cpu/cpu_wasm.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build wasm // +build wasm package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_x86.go b/vendor/golang.org/x/sys/cpu/cpu_x86.go index 48d42933195..fd380c0a713 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_x86.go +++ b/vendor/golang.org/x/sys/cpu/cpu_x86.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build 386 || amd64 || amd64p32 // +build 386 amd64 amd64p32 package cpu diff --git a/vendor/golang.org/x/sys/cpu/syscall_aix_gccgo.go b/vendor/golang.org/x/sys/cpu/syscall_aix_gccgo.go index 76fbe40b762..a864f24d758 100644 --- a/vendor/golang.org/x/sys/cpu/syscall_aix_gccgo.go +++ b/vendor/golang.org/x/sys/cpu/syscall_aix_gccgo.go @@ -8,8 +8,8 @@ // Morever, this file will be used during the building of // gccgo's libgo and thus must not used a CGo method. -// +build aix -// +build gccgo +//go:build aix && gccgo +// +build aix,gccgo package cpu diff --git a/vendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.go b/vendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.go index 5b427d67e2f..904be42ffdc 100644 --- a/vendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.go +++ b/vendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.go @@ -6,8 +6,8 @@ // system call on AIX without depending on x/sys/unix. // (See golang.org/issue/32102) -// +build aix,ppc64 -// +build gc +//go:build aix && ppc64 && gc +// +build aix,ppc64,gc package cpu diff --git a/vendor/golang.org/x/sys/unix/aliases.go b/vendor/golang.org/x/sys/unix/aliases.go index 951fce4d0d9..abc89c104a8 100644 --- a/vendor/golang.org/x/sys/unix/aliases.go +++ b/vendor/golang.org/x/sys/unix/aliases.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris +//go:build (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos) && go1.9 +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos // +build go1.9 package unix diff --git a/vendor/golang.org/x/sys/unix/asm_freebsd_386.s b/vendor/golang.org/x/sys/unix/asm_bsd_386.s similarity index 70% rename from vendor/golang.org/x/sys/unix/asm_freebsd_386.s rename to vendor/golang.org/x/sys/unix/asm_bsd_386.s index 49f0ac2364c..7f29275fa00 100644 --- a/vendor/golang.org/x/sys/unix/asm_freebsd_386.s +++ b/vendor/golang.org/x/sys/unix/asm_bsd_386.s @@ -1,14 +1,14 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2021 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (darwin || freebsd || netbsd || openbsd) && gc +// +build darwin freebsd netbsd openbsd // +build gc #include "textflag.h" -// -// System call support for 386, FreeBSD -// +// System call support for 386 BSD // Just jump to package syscall's implementation for all these functions. // The runtime may know about them. @@ -22,7 +22,7 @@ TEXT ·Syscall6(SB),NOSPLIT,$0-40 TEXT ·Syscall9(SB),NOSPLIT,$0-52 JMP syscall·Syscall9(SB) -TEXT ·RawSyscall(SB),NOSPLIT,$0-28 +TEXT ·RawSyscall(SB),NOSPLIT,$0-28 JMP syscall·RawSyscall(SB) TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 diff --git a/vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s b/vendor/golang.org/x/sys/unix/asm_bsd_amd64.s similarity index 72% rename from vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s rename to vendor/golang.org/x/sys/unix/asm_bsd_amd64.s index e57367c17aa..2b99c349a2d 100644 --- a/vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s +++ b/vendor/golang.org/x/sys/unix/asm_bsd_amd64.s @@ -1,14 +1,14 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2021 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && gc +// +build darwin dragonfly freebsd netbsd openbsd // +build gc #include "textflag.h" -// -// System call support for AMD64, NetBSD -// +// System call support for AMD64 BSD // Just jump to package syscall's implementation for all these functions. // The runtime may know about them. diff --git a/vendor/golang.org/x/sys/unix/asm_netbsd_arm.s b/vendor/golang.org/x/sys/unix/asm_bsd_arm.s similarity index 74% rename from vendor/golang.org/x/sys/unix/asm_netbsd_arm.s rename to vendor/golang.org/x/sys/unix/asm_bsd_arm.s index d7da175e1a3..98ebfad9d51 100644 --- a/vendor/golang.org/x/sys/unix/asm_netbsd_arm.s +++ b/vendor/golang.org/x/sys/unix/asm_bsd_arm.s @@ -1,14 +1,14 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// Copyright 2021 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (darwin || freebsd || netbsd || openbsd) && gc +// +build darwin freebsd netbsd openbsd // +build gc #include "textflag.h" -// -// System call support for ARM, NetBSD -// +// System call support for ARM BSD // Just jump to package syscall's implementation for all these functions. // The runtime may know about them. diff --git a/vendor/golang.org/x/sys/unix/asm_darwin_amd64.s b/vendor/golang.org/x/sys/unix/asm_bsd_arm64.s similarity index 75% rename from vendor/golang.org/x/sys/unix/asm_darwin_amd64.s rename to vendor/golang.org/x/sys/unix/asm_bsd_arm64.s index f2397fde554..fe36a7391a6 100644 --- a/vendor/golang.org/x/sys/unix/asm_darwin_amd64.s +++ b/vendor/golang.org/x/sys/unix/asm_bsd_arm64.s @@ -1,14 +1,14 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2021 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (darwin || freebsd || netbsd || openbsd) && gc +// +build darwin freebsd netbsd openbsd // +build gc #include "textflag.h" -// -// System call support for AMD64, Darwin -// +// System call support for ARM64 BSD // Just jump to package syscall's implementation for all these functions. // The runtime may know about them. diff --git a/vendor/golang.org/x/sys/unix/asm_darwin_386.s b/vendor/golang.org/x/sys/unix/asm_darwin_386.s deleted file mode 100644 index 8a06b87d715..00000000000 --- a/vendor/golang.org/x/sys/unix/asm_darwin_386.s +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build gc - -#include "textflag.h" - -// -// System call support for 386, Darwin -// - -// Just jump to package syscall's implementation for all these functions. -// The runtime may know about them. - -TEXT ·Syscall(SB),NOSPLIT,$0-28 - JMP syscall·Syscall(SB) - -TEXT ·Syscall6(SB),NOSPLIT,$0-40 - JMP syscall·Syscall6(SB) - -TEXT ·Syscall9(SB),NOSPLIT,$0-52 - JMP syscall·Syscall9(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-28 - JMP syscall·RawSyscall(SB) - -TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 - JMP syscall·RawSyscall6(SB) diff --git a/vendor/golang.org/x/sys/unix/asm_darwin_arm.s b/vendor/golang.org/x/sys/unix/asm_darwin_arm.s deleted file mode 100644 index c9e6b6fc8b5..00000000000 --- a/vendor/golang.org/x/sys/unix/asm_darwin_arm.s +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build gc -// +build arm,darwin - -#include "textflag.h" - -// -// System call support for ARM, Darwin -// - -// Just jump to package syscall's implementation for all these functions. -// The runtime may know about them. - -TEXT ·Syscall(SB),NOSPLIT,$0-28 - B syscall·Syscall(SB) - -TEXT ·Syscall6(SB),NOSPLIT,$0-40 - B syscall·Syscall6(SB) - -TEXT ·Syscall9(SB),NOSPLIT,$0-52 - B syscall·Syscall9(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-28 - B syscall·RawSyscall(SB) - -TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 - B syscall·RawSyscall6(SB) diff --git a/vendor/golang.org/x/sys/unix/asm_darwin_arm64.s b/vendor/golang.org/x/sys/unix/asm_darwin_arm64.s deleted file mode 100644 index 89843f8f4b2..00000000000 --- a/vendor/golang.org/x/sys/unix/asm_darwin_arm64.s +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build gc -// +build arm64,darwin - -#include "textflag.h" - -// -// System call support for AMD64, Darwin -// - -// Just jump to package syscall's implementation for all these functions. -// The runtime may know about them. - -TEXT ·Syscall(SB),NOSPLIT,$0-56 - B syscall·Syscall(SB) - -TEXT ·Syscall6(SB),NOSPLIT,$0-80 - B syscall·Syscall6(SB) - -TEXT ·Syscall9(SB),NOSPLIT,$0-104 - B syscall·Syscall9(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-56 - B syscall·RawSyscall(SB) - -TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 - B syscall·RawSyscall6(SB) diff --git a/vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s b/vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s deleted file mode 100644 index 27674e1cafd..00000000000 --- a/vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build gc - -#include "textflag.h" - -// -// System call support for AMD64, DragonFly -// - -// Just jump to package syscall's implementation for all these functions. -// The runtime may know about them. - -TEXT ·Syscall(SB),NOSPLIT,$0-56 - JMP syscall·Syscall(SB) - -TEXT ·Syscall6(SB),NOSPLIT,$0-80 - JMP syscall·Syscall6(SB) - -TEXT ·Syscall9(SB),NOSPLIT,$0-104 - JMP syscall·Syscall9(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-56 - JMP syscall·RawSyscall(SB) - -TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 - JMP syscall·RawSyscall6(SB) diff --git a/vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s b/vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s deleted file mode 100644 index f2dfc57b836..00000000000 --- a/vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build gc - -#include "textflag.h" - -// -// System call support for AMD64, FreeBSD -// - -// Just jump to package syscall's implementation for all these functions. -// The runtime may know about them. - -TEXT ·Syscall(SB),NOSPLIT,$0-56 - JMP syscall·Syscall(SB) - -TEXT ·Syscall6(SB),NOSPLIT,$0-80 - JMP syscall·Syscall6(SB) - -TEXT ·Syscall9(SB),NOSPLIT,$0-104 - JMP syscall·Syscall9(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-56 - JMP syscall·RawSyscall(SB) - -TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 - JMP syscall·RawSyscall6(SB) diff --git a/vendor/golang.org/x/sys/unix/asm_freebsd_arm.s b/vendor/golang.org/x/sys/unix/asm_freebsd_arm.s deleted file mode 100644 index 6d740db2c0c..00000000000 --- a/vendor/golang.org/x/sys/unix/asm_freebsd_arm.s +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build gc - -#include "textflag.h" - -// -// System call support for ARM, FreeBSD -// - -// Just jump to package syscall's implementation for all these functions. -// The runtime may know about them. - -TEXT ·Syscall(SB),NOSPLIT,$0-28 - B syscall·Syscall(SB) - -TEXT ·Syscall6(SB),NOSPLIT,$0-40 - B syscall·Syscall6(SB) - -TEXT ·Syscall9(SB),NOSPLIT,$0-52 - B syscall·Syscall9(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-28 - B syscall·RawSyscall(SB) - -TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 - B syscall·RawSyscall6(SB) diff --git a/vendor/golang.org/x/sys/unix/asm_freebsd_arm64.s b/vendor/golang.org/x/sys/unix/asm_freebsd_arm64.s deleted file mode 100644 index a8f5a29b35f..00000000000 --- a/vendor/golang.org/x/sys/unix/asm_freebsd_arm64.s +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build gc - -#include "textflag.h" - -// -// System call support for ARM64, FreeBSD -// - -// Just jump to package syscall's implementation for all these functions. -// The runtime may know about them. - -TEXT ·Syscall(SB),NOSPLIT,$0-56 - JMP syscall·Syscall(SB) - -TEXT ·Syscall6(SB),NOSPLIT,$0-80 - JMP syscall·Syscall6(SB) - -TEXT ·Syscall9(SB),NOSPLIT,$0-104 - JMP syscall·Syscall9(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-56 - JMP syscall·RawSyscall(SB) - -TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 - JMP syscall·RawSyscall6(SB) diff --git a/vendor/golang.org/x/sys/unix/asm_netbsd_386.s b/vendor/golang.org/x/sys/unix/asm_netbsd_386.s deleted file mode 100644 index ae7b498d506..00000000000 --- a/vendor/golang.org/x/sys/unix/asm_netbsd_386.s +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build gc - -#include "textflag.h" - -// -// System call support for 386, NetBSD -// - -// Just jump to package syscall's implementation for all these functions. -// The runtime may know about them. - -TEXT ·Syscall(SB),NOSPLIT,$0-28 - JMP syscall·Syscall(SB) - -TEXT ·Syscall6(SB),NOSPLIT,$0-40 - JMP syscall·Syscall6(SB) - -TEXT ·Syscall9(SB),NOSPLIT,$0-52 - JMP syscall·Syscall9(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-28 - JMP syscall·RawSyscall(SB) - -TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 - JMP syscall·RawSyscall6(SB) diff --git a/vendor/golang.org/x/sys/unix/asm_netbsd_arm64.s b/vendor/golang.org/x/sys/unix/asm_netbsd_arm64.s deleted file mode 100644 index e7cbe1904c4..00000000000 --- a/vendor/golang.org/x/sys/unix/asm_netbsd_arm64.s +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build gc - -#include "textflag.h" - -// -// System call support for ARM64, NetBSD -// - -// Just jump to package syscall's implementation for all these functions. -// The runtime may know about them. - -TEXT ·Syscall(SB),NOSPLIT,$0-56 - B syscall·Syscall(SB) - -TEXT ·Syscall6(SB),NOSPLIT,$0-80 - B syscall·Syscall6(SB) - -TEXT ·Syscall9(SB),NOSPLIT,$0-104 - B syscall·Syscall9(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-56 - B syscall·RawSyscall(SB) - -TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 - B syscall·RawSyscall6(SB) diff --git a/vendor/golang.org/x/sys/unix/asm_openbsd_386.s b/vendor/golang.org/x/sys/unix/asm_openbsd_386.s deleted file mode 100644 index 2f00b0310f4..00000000000 --- a/vendor/golang.org/x/sys/unix/asm_openbsd_386.s +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build gc - -#include "textflag.h" - -// -// System call support for 386, OpenBSD -// - -// Just jump to package syscall's implementation for all these functions. -// The runtime may know about them. - -TEXT ·Syscall(SB),NOSPLIT,$0-28 - JMP syscall·Syscall(SB) - -TEXT ·Syscall6(SB),NOSPLIT,$0-40 - JMP syscall·Syscall6(SB) - -TEXT ·Syscall9(SB),NOSPLIT,$0-52 - JMP syscall·Syscall9(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-28 - JMP syscall·RawSyscall(SB) - -TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 - JMP syscall·RawSyscall6(SB) diff --git a/vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s b/vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s deleted file mode 100644 index 07632c99cea..00000000000 --- a/vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build gc - -#include "textflag.h" - -// -// System call support for AMD64, OpenBSD -// - -// Just jump to package syscall's implementation for all these functions. -// The runtime may know about them. - -TEXT ·Syscall(SB),NOSPLIT,$0-56 - JMP syscall·Syscall(SB) - -TEXT ·Syscall6(SB),NOSPLIT,$0-80 - JMP syscall·Syscall6(SB) - -TEXT ·Syscall9(SB),NOSPLIT,$0-104 - JMP syscall·Syscall9(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-56 - JMP syscall·RawSyscall(SB) - -TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 - JMP syscall·RawSyscall6(SB) diff --git a/vendor/golang.org/x/sys/unix/asm_openbsd_arm.s b/vendor/golang.org/x/sys/unix/asm_openbsd_arm.s deleted file mode 100644 index 73e997320fc..00000000000 --- a/vendor/golang.org/x/sys/unix/asm_openbsd_arm.s +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build gc - -#include "textflag.h" - -// -// System call support for ARM, OpenBSD -// - -// Just jump to package syscall's implementation for all these functions. -// The runtime may know about them. - -TEXT ·Syscall(SB),NOSPLIT,$0-28 - B syscall·Syscall(SB) - -TEXT ·Syscall6(SB),NOSPLIT,$0-40 - B syscall·Syscall6(SB) - -TEXT ·Syscall9(SB),NOSPLIT,$0-52 - B syscall·Syscall9(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-28 - B syscall·RawSyscall(SB) - -TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 - B syscall·RawSyscall6(SB) diff --git a/vendor/golang.org/x/sys/unix/asm_openbsd_arm64.s b/vendor/golang.org/x/sys/unix/asm_openbsd_arm64.s deleted file mode 100644 index c47302aa46d..00000000000 --- a/vendor/golang.org/x/sys/unix/asm_openbsd_arm64.s +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build gc - -#include "textflag.h" - -// -// System call support for arm64, OpenBSD -// - -// Just jump to package syscall's implementation for all these functions. -// The runtime may know about them. - -TEXT ·Syscall(SB),NOSPLIT,$0-56 - JMP syscall·Syscall(SB) - -TEXT ·Syscall6(SB),NOSPLIT,$0-80 - JMP syscall·Syscall6(SB) - -TEXT ·Syscall9(SB),NOSPLIT,$0-104 - JMP syscall·Syscall9(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-56 - JMP syscall·RawSyscall(SB) - -TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 - JMP syscall·RawSyscall6(SB) diff --git a/vendor/golang.org/x/sys/unix/asm_zos_s390x.s b/vendor/golang.org/x/sys/unix/asm_zos_s390x.s new file mode 100644 index 00000000000..3b54e185813 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_zos_s390x.s @@ -0,0 +1,426 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build zos && s390x && gc +// +build zos +// +build s390x +// +build gc + +#include "textflag.h" + +#define PSALAA 1208(R0) +#define GTAB64(x) 80(x) +#define LCA64(x) 88(x) +#define CAA(x) 8(x) +#define EDCHPXV(x) 1016(x) // in the CAA +#define SAVSTACK_ASYNC(x) 336(x) // in the LCA + +// SS_*, where x=SAVSTACK_ASYNC +#define SS_LE(x) 0(x) +#define SS_GO(x) 8(x) +#define SS_ERRNO(x) 16(x) +#define SS_ERRNOJR(x) 20(x) + +#define LE_CALL BYTE $0x0D; BYTE $0x76; // BL R7, R6 + +TEXT ·clearErrno(SB),NOSPLIT,$0-0 + BL addrerrno<>(SB) + MOVD $0, 0(R3) + RET + +// Returns the address of errno in R3. +TEXT addrerrno<>(SB),NOSPLIT|NOFRAME,$0-0 + // Get library control area (LCA). + MOVW PSALAA, R8 + MOVD LCA64(R8), R8 + + // Get __errno FuncDesc. + MOVD CAA(R8), R9 + MOVD EDCHPXV(R9), R9 + ADD $(0x156*16), R9 + LMG 0(R9), R5, R6 + + // Switch to saved LE stack. + MOVD SAVSTACK_ASYNC(R8), R9 + MOVD 0(R9), R4 + MOVD $0, 0(R9) + + // Call __errno function. + LE_CALL + NOPH + + // Switch back to Go stack. + XOR R0, R0 // Restore R0 to $0. + MOVD R4, 0(R9) // Save stack pointer. + RET + +TEXT ·syscall_syscall(SB),NOSPLIT,$0-56 + BL runtime·entersyscall(SB) + MOVD a1+8(FP), R1 + MOVD a2+16(FP), R2 + MOVD a3+24(FP), R3 + + // Get library control area (LCA). + MOVW PSALAA, R8 + MOVD LCA64(R8), R8 + + // Get function. + MOVD CAA(R8), R9 + MOVD EDCHPXV(R9), R9 + MOVD trap+0(FP), R5 + SLD $4, R5 + ADD R5, R9 + LMG 0(R9), R5, R6 + + // Restore LE stack. + MOVD SAVSTACK_ASYNC(R8), R9 + MOVD 0(R9), R4 + MOVD $0, 0(R9) + + // Call function. + LE_CALL + NOPH + XOR R0, R0 // Restore R0 to $0. + MOVD R4, 0(R9) // Save stack pointer. + + MOVD R3, r1+32(FP) + MOVD R0, r2+40(FP) + MOVD R0, err+48(FP) + MOVW R3, R4 + CMP R4, $-1 + BNE done + BL addrerrno<>(SB) + MOVWZ 0(R3), R3 + MOVD R3, err+48(FP) +done: + BL runtime·exitsyscall(SB) + RET + +TEXT ·syscall_rawsyscall(SB),NOSPLIT,$0-56 + MOVD a1+8(FP), R1 + MOVD a2+16(FP), R2 + MOVD a3+24(FP), R3 + + // Get library control area (LCA). + MOVW PSALAA, R8 + MOVD LCA64(R8), R8 + + // Get function. + MOVD CAA(R8), R9 + MOVD EDCHPXV(R9), R9 + MOVD trap+0(FP), R5 + SLD $4, R5 + ADD R5, R9 + LMG 0(R9), R5, R6 + + // Restore LE stack. + MOVD SAVSTACK_ASYNC(R8), R9 + MOVD 0(R9), R4 + MOVD $0, 0(R9) + + // Call function. + LE_CALL + NOPH + XOR R0, R0 // Restore R0 to $0. + MOVD R4, 0(R9) // Save stack pointer. + + MOVD R3, r1+32(FP) + MOVD R0, r2+40(FP) + MOVD R0, err+48(FP) + MOVW R3, R4 + CMP R4, $-1 + BNE done + BL addrerrno<>(SB) + MOVWZ 0(R3), R3 + MOVD R3, err+48(FP) +done: + RET + +TEXT ·syscall_syscall6(SB),NOSPLIT,$0-80 + BL runtime·entersyscall(SB) + MOVD a1+8(FP), R1 + MOVD a2+16(FP), R2 + MOVD a3+24(FP), R3 + + // Get library control area (LCA). + MOVW PSALAA, R8 + MOVD LCA64(R8), R8 + + // Get function. + MOVD CAA(R8), R9 + MOVD EDCHPXV(R9), R9 + MOVD trap+0(FP), R5 + SLD $4, R5 + ADD R5, R9 + LMG 0(R9), R5, R6 + + // Restore LE stack. + MOVD SAVSTACK_ASYNC(R8), R9 + MOVD 0(R9), R4 + MOVD $0, 0(R9) + + // Fill in parameter list. + MOVD a4+32(FP), R12 + MOVD R12, (2176+24)(R4) + MOVD a5+40(FP), R12 + MOVD R12, (2176+32)(R4) + MOVD a6+48(FP), R12 + MOVD R12, (2176+40)(R4) + + // Call function. + LE_CALL + NOPH + XOR R0, R0 // Restore R0 to $0. + MOVD R4, 0(R9) // Save stack pointer. + + MOVD R3, r1+56(FP) + MOVD R0, r2+64(FP) + MOVD R0, err+72(FP) + MOVW R3, R4 + CMP R4, $-1 + BNE done + BL addrerrno<>(SB) + MOVWZ 0(R3), R3 + MOVD R3, err+72(FP) +done: + BL runtime·exitsyscall(SB) + RET + +TEXT ·syscall_rawsyscall6(SB),NOSPLIT,$0-80 + MOVD a1+8(FP), R1 + MOVD a2+16(FP), R2 + MOVD a3+24(FP), R3 + + // Get library control area (LCA). + MOVW PSALAA, R8 + MOVD LCA64(R8), R8 + + // Get function. + MOVD CAA(R8), R9 + MOVD EDCHPXV(R9), R9 + MOVD trap+0(FP), R5 + SLD $4, R5 + ADD R5, R9 + LMG 0(R9), R5, R6 + + // Restore LE stack. + MOVD SAVSTACK_ASYNC(R8), R9 + MOVD 0(R9), R4 + MOVD $0, 0(R9) + + // Fill in parameter list. + MOVD a4+32(FP), R12 + MOVD R12, (2176+24)(R4) + MOVD a5+40(FP), R12 + MOVD R12, (2176+32)(R4) + MOVD a6+48(FP), R12 + MOVD R12, (2176+40)(R4) + + // Call function. + LE_CALL + NOPH + XOR R0, R0 // Restore R0 to $0. + MOVD R4, 0(R9) // Save stack pointer. + + MOVD R3, r1+56(FP) + MOVD R0, r2+64(FP) + MOVD R0, err+72(FP) + MOVW R3, R4 + CMP R4, $-1 + BNE done + BL ·rrno<>(SB) + MOVWZ 0(R3), R3 + MOVD R3, err+72(FP) +done: + RET + +TEXT ·syscall_syscall9(SB),NOSPLIT,$0 + BL runtime·entersyscall(SB) + MOVD a1+8(FP), R1 + MOVD a2+16(FP), R2 + MOVD a3+24(FP), R3 + + // Get library control area (LCA). + MOVW PSALAA, R8 + MOVD LCA64(R8), R8 + + // Get function. + MOVD CAA(R8), R9 + MOVD EDCHPXV(R9), R9 + MOVD trap+0(FP), R5 + SLD $4, R5 + ADD R5, R9 + LMG 0(R9), R5, R6 + + // Restore LE stack. + MOVD SAVSTACK_ASYNC(R8), R9 + MOVD 0(R9), R4 + MOVD $0, 0(R9) + + // Fill in parameter list. + MOVD a4+32(FP), R12 + MOVD R12, (2176+24)(R4) + MOVD a5+40(FP), R12 + MOVD R12, (2176+32)(R4) + MOVD a6+48(FP), R12 + MOVD R12, (2176+40)(R4) + MOVD a7+56(FP), R12 + MOVD R12, (2176+48)(R4) + MOVD a8+64(FP), R12 + MOVD R12, (2176+56)(R4) + MOVD a9+72(FP), R12 + MOVD R12, (2176+64)(R4) + + // Call function. + LE_CALL + NOPH + XOR R0, R0 // Restore R0 to $0. + MOVD R4, 0(R9) // Save stack pointer. + + MOVD R3, r1+80(FP) + MOVD R0, r2+88(FP) + MOVD R0, err+96(FP) + MOVW R3, R4 + CMP R4, $-1 + BNE done + BL addrerrno<>(SB) + MOVWZ 0(R3), R3 + MOVD R3, err+96(FP) +done: + BL runtime·exitsyscall(SB) + RET + +TEXT ·syscall_rawsyscall9(SB),NOSPLIT,$0 + MOVD a1+8(FP), R1 + MOVD a2+16(FP), R2 + MOVD a3+24(FP), R3 + + // Get library control area (LCA). + MOVW PSALAA, R8 + MOVD LCA64(R8), R8 + + // Get function. + MOVD CAA(R8), R9 + MOVD EDCHPXV(R9), R9 + MOVD trap+0(FP), R5 + SLD $4, R5 + ADD R5, R9 + LMG 0(R9), R5, R6 + + // Restore LE stack. + MOVD SAVSTACK_ASYNC(R8), R9 + MOVD 0(R9), R4 + MOVD $0, 0(R9) + + // Fill in parameter list. + MOVD a4+32(FP), R12 + MOVD R12, (2176+24)(R4) + MOVD a5+40(FP), R12 + MOVD R12, (2176+32)(R4) + MOVD a6+48(FP), R12 + MOVD R12, (2176+40)(R4) + MOVD a7+56(FP), R12 + MOVD R12, (2176+48)(R4) + MOVD a8+64(FP), R12 + MOVD R12, (2176+56)(R4) + MOVD a9+72(FP), R12 + MOVD R12, (2176+64)(R4) + + // Call function. + LE_CALL + NOPH + XOR R0, R0 // Restore R0 to $0. + MOVD R4, 0(R9) // Save stack pointer. + + MOVD R3, r1+80(FP) + MOVD R0, r2+88(FP) + MOVD R0, err+96(FP) + MOVW R3, R4 + CMP R4, $-1 + BNE done + BL addrerrno<>(SB) + MOVWZ 0(R3), R3 + MOVD R3, err+96(FP) +done: + RET + +// func svcCall(fnptr unsafe.Pointer, argv *unsafe.Pointer, dsa *uint64) +TEXT ·svcCall(SB),NOSPLIT,$0 + BL runtime·save_g(SB) // Save g and stack pointer + MOVW PSALAA, R8 + MOVD LCA64(R8), R8 + MOVD SAVSTACK_ASYNC(R8), R9 + MOVD R15, 0(R9) + + MOVD argv+8(FP), R1 // Move function arguments into registers + MOVD dsa+16(FP), g + MOVD fnptr+0(FP), R15 + + BYTE $0x0D // Branch to function + BYTE $0xEF + + BL runtime·load_g(SB) // Restore g and stack pointer + MOVW PSALAA, R8 + MOVD LCA64(R8), R8 + MOVD SAVSTACK_ASYNC(R8), R9 + MOVD 0(R9), R15 + + RET + +// func svcLoad(name *byte) unsafe.Pointer +TEXT ·svcLoad(SB),NOSPLIT,$0 + MOVD R15, R2 // Save go stack pointer + MOVD name+0(FP), R0 // Move SVC args into registers + MOVD $0x80000000, R1 + MOVD $0, R15 + BYTE $0x0A // SVC 08 LOAD + BYTE $0x08 + MOVW R15, R3 // Save return code from SVC + MOVD R2, R15 // Restore go stack pointer + CMP R3, $0 // Check SVC return code + BNE error + + MOVD $-2, R3 // Reset last bit of entry point to zero + AND R0, R3 + MOVD R3, addr+8(FP) // Return entry point returned by SVC + CMP R0, R3 // Check if last bit of entry point was set + BNE done + + MOVD R15, R2 // Save go stack pointer + MOVD $0, R15 // Move SVC args into registers (entry point still in r0 from SVC 08) + BYTE $0x0A // SVC 09 DELETE + BYTE $0x09 + MOVD R2, R15 // Restore go stack pointer + +error: + MOVD $0, addr+8(FP) // Return 0 on failure +done: + XOR R0, R0 // Reset r0 to 0 + RET + +// func svcUnload(name *byte, fnptr unsafe.Pointer) int64 +TEXT ·svcUnload(SB),NOSPLIT,$0 + MOVD R15, R2 // Save go stack pointer + MOVD name+0(FP), R0 // Move SVC args into registers + MOVD addr+8(FP), R15 + BYTE $0x0A // SVC 09 + BYTE $0x09 + XOR R0, R0 // Reset r0 to 0 + MOVD R15, R1 // Save SVC return code + MOVD R2, R15 // Restore go stack pointer + MOVD R1, rc+0(FP) // Return SVC return code + RET + +// func gettid() uint64 +TEXT ·gettid(SB), NOSPLIT, $0 + // Get library control area (LCA). + MOVW PSALAA, R8 + MOVD LCA64(R8), R8 + + // Get CEECAATHDID + MOVD CAA(R8), R9 + MOVD 0x3D0(R9), R9 + MOVD R9, ret+0(FP) + + RET diff --git a/vendor/golang.org/x/sys/unix/cap_freebsd.go b/vendor/golang.org/x/sys/unix/cap_freebsd.go index df520487737..0b7c6adb866 100644 --- a/vendor/golang.org/x/sys/unix/cap_freebsd.go +++ b/vendor/golang.org/x/sys/unix/cap_freebsd.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build freebsd // +build freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/constants.go b/vendor/golang.org/x/sys/unix/constants.go index 3a6ac648dd5..394a3965b68 100644 --- a/vendor/golang.org/x/sys/unix/constants.go +++ b/vendor/golang.org/x/sys/unix/constants.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos package unix diff --git a/vendor/golang.org/x/sys/unix/dev_aix_ppc.go b/vendor/golang.org/x/sys/unix/dev_aix_ppc.go index 5e5fb451044..65a998508db 100644 --- a/vendor/golang.org/x/sys/unix/dev_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/dev_aix_ppc.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix -// +build ppc +//go:build aix && ppc +// +build aix,ppc // Functions to access/create device major and minor numbers matching the // encoding used by AIX. diff --git a/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go b/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go index 8b401244c41..8fc08ad0aae 100644 --- a/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix -// +build ppc64 +//go:build aix && ppc64 +// +build aix,ppc64 // Functions to access/create device major and minor numbers matching the // encoding used AIX. diff --git a/vendor/golang.org/x/sys/unix/dev_zos.go b/vendor/golang.org/x/sys/unix/dev_zos.go new file mode 100644 index 00000000000..a388e59a0e0 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/dev_zos.go @@ -0,0 +1,29 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build zos && s390x +// +build zos,s390x + +// Functions to access/create device major and minor numbers matching the +// encoding used by z/OS. +// +// The information below is extracted and adapted from macros. + +package unix + +// Major returns the major component of a z/OS device number. +func Major(dev uint64) uint32 { + return uint32((dev >> 16) & 0x0000FFFF) +} + +// Minor returns the minor component of a z/OS device number. +func Minor(dev uint64) uint32 { + return uint32(dev & 0x0000FFFF) +} + +// Mkdev returns a z/OS device number generated from the given major and minor +// components. +func Mkdev(major, minor uint32) uint64 { + return (uint64(major) << 16) | uint64(minor) +} diff --git a/vendor/golang.org/x/sys/unix/dirent.go b/vendor/golang.org/x/sys/unix/dirent.go index 304016b6886..e74e5eaa3bf 100644 --- a/vendor/golang.org/x/sys/unix/dirent.go +++ b/vendor/golang.org/x/sys/unix/dirent.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package unix diff --git a/vendor/golang.org/x/sys/unix/endian_big.go b/vendor/golang.org/x/sys/unix/endian_big.go index 86781eac221..a5202655768 100644 --- a/vendor/golang.org/x/sys/unix/endian_big.go +++ b/vendor/golang.org/x/sys/unix/endian_big.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +//go:build armbe || arm64be || m68k || mips || mips64 || mips64p32 || ppc || ppc64 || s390 || s390x || shbe || sparc || sparc64 // +build armbe arm64be m68k mips mips64 mips64p32 ppc ppc64 s390 s390x shbe sparc sparc64 package unix diff --git a/vendor/golang.org/x/sys/unix/endian_little.go b/vendor/golang.org/x/sys/unix/endian_little.go index 8822d8541f2..4362f47e2c0 100644 --- a/vendor/golang.org/x/sys/unix/endian_little.go +++ b/vendor/golang.org/x/sys/unix/endian_little.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh // +build 386 amd64 amd64p32 alpha arm arm64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh package unix diff --git a/vendor/golang.org/x/sys/unix/env_unix.go b/vendor/golang.org/x/sys/unix/env_unix.go index 84178b0a134..29ccc4d1334 100644 --- a/vendor/golang.org/x/sys/unix/env_unix.go +++ b/vendor/golang.org/x/sys/unix/env_unix.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos // Unix environment variables. diff --git a/vendor/golang.org/x/sys/unix/epoll_zos.go b/vendor/golang.org/x/sys/unix/epoll_zos.go new file mode 100644 index 00000000000..cedaf7e024b --- /dev/null +++ b/vendor/golang.org/x/sys/unix/epoll_zos.go @@ -0,0 +1,221 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build zos && s390x +// +build zos,s390x + +package unix + +import ( + "sync" +) + +// This file simulates epoll on z/OS using poll. + +// Analogous to epoll_event on Linux. +// TODO(neeilan): Pad is because the Linux kernel expects a 96-bit struct. We never pass this to the kernel; remove? +type EpollEvent struct { + Events uint32 + Fd int32 + Pad int32 +} + +const ( + EPOLLERR = 0x8 + EPOLLHUP = 0x10 + EPOLLIN = 0x1 + EPOLLMSG = 0x400 + EPOLLOUT = 0x4 + EPOLLPRI = 0x2 + EPOLLRDBAND = 0x80 + EPOLLRDNORM = 0x40 + EPOLLWRBAND = 0x200 + EPOLLWRNORM = 0x100 + EPOLL_CTL_ADD = 0x1 + EPOLL_CTL_DEL = 0x2 + EPOLL_CTL_MOD = 0x3 + // The following constants are part of the epoll API, but represent + // currently unsupported functionality on z/OS. + // EPOLL_CLOEXEC = 0x80000 + // EPOLLET = 0x80000000 + // EPOLLONESHOT = 0x40000000 + // EPOLLRDHUP = 0x2000 // Typically used with edge-triggered notis + // EPOLLEXCLUSIVE = 0x10000000 // Exclusive wake-up mode + // EPOLLWAKEUP = 0x20000000 // Relies on Linux's BLOCK_SUSPEND capability +) + +// TODO(neeilan): We can eliminate these epToPoll / pToEpoll calls by using identical mask values for POLL/EPOLL +// constants where possible The lower 16 bits of epoll events (uint32) can fit any system poll event (int16). + +// epToPollEvt converts epoll event field to poll equivalent. +// In epoll, Events is a 32-bit field, while poll uses 16 bits. +func epToPollEvt(events uint32) int16 { + var ep2p = map[uint32]int16{ + EPOLLIN: POLLIN, + EPOLLOUT: POLLOUT, + EPOLLHUP: POLLHUP, + EPOLLPRI: POLLPRI, + EPOLLERR: POLLERR, + } + + var pollEvts int16 = 0 + for epEvt, pEvt := range ep2p { + if (events & epEvt) != 0 { + pollEvts |= pEvt + } + } + + return pollEvts +} + +// pToEpollEvt converts 16 bit poll event bitfields to 32-bit epoll event fields. +func pToEpollEvt(revents int16) uint32 { + var p2ep = map[int16]uint32{ + POLLIN: EPOLLIN, + POLLOUT: EPOLLOUT, + POLLHUP: EPOLLHUP, + POLLPRI: EPOLLPRI, + POLLERR: EPOLLERR, + } + + var epollEvts uint32 = 0 + for pEvt, epEvt := range p2ep { + if (revents & pEvt) != 0 { + epollEvts |= epEvt + } + } + + return epollEvts +} + +// Per-process epoll implementation. +type epollImpl struct { + mu sync.Mutex + epfd2ep map[int]*eventPoll + nextEpfd int +} + +// eventPoll holds a set of file descriptors being watched by the process. A process can have multiple epoll instances. +// On Linux, this is an in-kernel data structure accessed through a fd. +type eventPoll struct { + mu sync.Mutex + fds map[int]*EpollEvent +} + +// epoll impl for this process. +var impl epollImpl = epollImpl{ + epfd2ep: make(map[int]*eventPoll), + nextEpfd: 0, +} + +func (e *epollImpl) epollcreate(size int) (epfd int, err error) { + e.mu.Lock() + defer e.mu.Unlock() + epfd = e.nextEpfd + e.nextEpfd++ + + e.epfd2ep[epfd] = &eventPoll{ + fds: make(map[int]*EpollEvent), + } + return epfd, nil +} + +func (e *epollImpl) epollcreate1(flag int) (fd int, err error) { + return e.epollcreate(4) +} + +func (e *epollImpl) epollctl(epfd int, op int, fd int, event *EpollEvent) (err error) { + e.mu.Lock() + defer e.mu.Unlock() + + ep, ok := e.epfd2ep[epfd] + if !ok { + + return EBADF + } + + switch op { + case EPOLL_CTL_ADD: + // TODO(neeilan): When we make epfds and fds disjoint, detect epoll + // loops here (instances watching each other) and return ELOOP. + if _, ok := ep.fds[fd]; ok { + return EEXIST + } + ep.fds[fd] = event + case EPOLL_CTL_MOD: + if _, ok := ep.fds[fd]; !ok { + return ENOENT + } + ep.fds[fd] = event + case EPOLL_CTL_DEL: + if _, ok := ep.fds[fd]; !ok { + return ENOENT + } + delete(ep.fds, fd) + + } + return nil +} + +// Must be called while holding ep.mu +func (ep *eventPoll) getFds() []int { + fds := make([]int, len(ep.fds)) + for fd := range ep.fds { + fds = append(fds, fd) + } + return fds +} + +func (e *epollImpl) epollwait(epfd int, events []EpollEvent, msec int) (n int, err error) { + e.mu.Lock() // in [rare] case of concurrent epollcreate + epollwait + ep, ok := e.epfd2ep[epfd] + + if !ok { + e.mu.Unlock() + return 0, EBADF + } + + pollfds := make([]PollFd, 4) + for fd, epollevt := range ep.fds { + pollfds = append(pollfds, PollFd{Fd: int32(fd), Events: epToPollEvt(epollevt.Events)}) + } + e.mu.Unlock() + + n, err = Poll(pollfds, msec) + if err != nil { + return n, err + } + + i := 0 + for _, pFd := range pollfds { + if pFd.Revents != 0 { + events[i] = EpollEvent{Fd: pFd.Fd, Events: pToEpollEvt(pFd.Revents)} + i++ + } + + if i == n { + break + } + } + + return n, nil +} + +func EpollCreate(size int) (fd int, err error) { + return impl.epollcreate(size) +} + +func EpollCreate1(flag int) (fd int, err error) { + return impl.epollcreate1(flag) +} + +func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { + return impl.epollctl(epfd, op, fd, event) +} + +// Because EpollWait mutates events, the caller is expected to coordinate +// concurrent access if calling with the same epfd from multiple goroutines. +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + return impl.epollwait(epfd, events, msec) +} diff --git a/vendor/golang.org/x/sys/unix/fcntl.go b/vendor/golang.org/x/sys/unix/fcntl.go index 4dc53486436..e9b991258c1 100644 --- a/vendor/golang.org/x/sys/unix/fcntl.go +++ b/vendor/golang.org/x/sys/unix/fcntl.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build dragonfly || freebsd || linux || netbsd || openbsd // +build dragonfly freebsd linux netbsd openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go b/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go index 8db48e5e062..cb0dfbd09a0 100644 --- a/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go +++ b/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (linux && 386) || (linux && arm) || (linux && mips) || (linux && mipsle) // +build linux,386 linux,arm linux,mips linux,mipsle package unix diff --git a/vendor/golang.org/x/sys/unix/fdset.go b/vendor/golang.org/x/sys/unix/fdset.go index b27be0a014c..b1e07b22023 100644 --- a/vendor/golang.org/x/sys/unix/fdset.go +++ b/vendor/golang.org/x/sys/unix/fdset.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package unix diff --git a/vendor/golang.org/x/sys/unix/fstatfs_zos.go b/vendor/golang.org/x/sys/unix/fstatfs_zos.go new file mode 100644 index 00000000000..e377cc9f49c --- /dev/null +++ b/vendor/golang.org/x/sys/unix/fstatfs_zos.go @@ -0,0 +1,164 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build zos && s390x +// +build zos,s390x + +package unix + +import ( + "unsafe" +) + +// This file simulates fstatfs on z/OS using fstatvfs and w_getmntent. + +func Fstatfs(fd int, stat *Statfs_t) (err error) { + var stat_v Statvfs_t + err = Fstatvfs(fd, &stat_v) + if err == nil { + // populate stat + stat.Type = 0 + stat.Bsize = stat_v.Bsize + stat.Blocks = stat_v.Blocks + stat.Bfree = stat_v.Bfree + stat.Bavail = stat_v.Bavail + stat.Files = stat_v.Files + stat.Ffree = stat_v.Ffree + stat.Fsid = stat_v.Fsid + stat.Namelen = stat_v.Namemax + stat.Frsize = stat_v.Frsize + stat.Flags = stat_v.Flag + for passn := 0; passn < 5; passn++ { + switch passn { + case 0: + err = tryGetmntent64(stat) + break + case 1: + err = tryGetmntent128(stat) + break + case 2: + err = tryGetmntent256(stat) + break + case 3: + err = tryGetmntent512(stat) + break + case 4: + err = tryGetmntent1024(stat) + break + default: + break + } + //proceed to return if: err is nil (found), err is nonnil but not ERANGE (another error occurred) + if err == nil || err != nil && err != ERANGE { + break + } + } + } + return err +} + +func tryGetmntent64(stat *Statfs_t) (err error) { + var mnt_ent_buffer struct { + header W_Mnth + filesys_info [64]W_Mntent + } + var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer)) + fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size) + if err != nil { + return err + } + err = ERANGE //return ERANGE if no match is found in this batch + for i := 0; i < fs_count; i++ { + if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) { + stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0]) + err = nil + break + } + } + return err +} + +func tryGetmntent128(stat *Statfs_t) (err error) { + var mnt_ent_buffer struct { + header W_Mnth + filesys_info [128]W_Mntent + } + var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer)) + fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size) + if err != nil { + return err + } + err = ERANGE //return ERANGE if no match is found in this batch + for i := 0; i < fs_count; i++ { + if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) { + stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0]) + err = nil + break + } + } + return err +} + +func tryGetmntent256(stat *Statfs_t) (err error) { + var mnt_ent_buffer struct { + header W_Mnth + filesys_info [256]W_Mntent + } + var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer)) + fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size) + if err != nil { + return err + } + err = ERANGE //return ERANGE if no match is found in this batch + for i := 0; i < fs_count; i++ { + if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) { + stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0]) + err = nil + break + } + } + return err +} + +func tryGetmntent512(stat *Statfs_t) (err error) { + var mnt_ent_buffer struct { + header W_Mnth + filesys_info [512]W_Mntent + } + var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer)) + fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size) + if err != nil { + return err + } + err = ERANGE //return ERANGE if no match is found in this batch + for i := 0; i < fs_count; i++ { + if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) { + stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0]) + err = nil + break + } + } + return err +} + +func tryGetmntent1024(stat *Statfs_t) (err error) { + var mnt_ent_buffer struct { + header W_Mnth + filesys_info [1024]W_Mntent + } + var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer)) + fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size) + if err != nil { + return err + } + err = ERANGE //return ERANGE if no match is found in this batch + for i := 0; i < fs_count; i++ { + if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) { + stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0]) + err = nil + break + } + } + return err +} diff --git a/vendor/golang.org/x/sys/unix/gccgo.go b/vendor/golang.org/x/sys/unix/gccgo.go index 86032c11ef3..0dee23222ca 100644 --- a/vendor/golang.org/x/sys/unix/gccgo.go +++ b/vendor/golang.org/x/sys/unix/gccgo.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build gccgo -// +build !aix +//go:build gccgo && !aix +// +build gccgo,!aix package unix diff --git a/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go b/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go index 251a977a811..e60e49a3d9c 100644 --- a/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build gccgo && linux && amd64 // +build gccgo,linux,amd64 package unix diff --git a/vendor/golang.org/x/sys/unix/ioctl.go b/vendor/golang.org/x/sys/unix/ioctl.go index 5641678613c..6c7ad052e6b 100644 --- a/vendor/golang.org/x/sys/unix/ioctl.go +++ b/vendor/golang.org/x/sys/unix/ioctl.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package unix diff --git a/vendor/golang.org/x/sys/unix/ioctl_zos.go b/vendor/golang.org/x/sys/unix/ioctl_zos.go new file mode 100644 index 00000000000..5384e7d91d7 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ioctl_zos.go @@ -0,0 +1,74 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build zos && s390x +// +build zos,s390x + +package unix + +import ( + "runtime" + "unsafe" +) + +// ioctl itself should not be exposed directly, but additional get/set +// functions for specific types are permissible. + +// IoctlSetInt performs an ioctl operation which sets an integer value +// on fd, using the specified request number. +func IoctlSetInt(fd int, req uint, value int) error { + return ioctl(fd, req, uintptr(value)) +} + +// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. +// +// To change fd's window size, the req argument should be TIOCSWINSZ. +func IoctlSetWinsize(fd int, req uint, value *Winsize) error { + // TODO: if we get the chance, remove the req parameter and + // hardcode TIOCSWINSZ. + err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) + runtime.KeepAlive(value) + return err +} + +// IoctlSetTermios performs an ioctl on fd with a *Termios. +// +// The req value is expected to be TCSETS, TCSETSW, or TCSETSF +func IoctlSetTermios(fd int, req uint, value *Termios) error { + if (req != TCSETS) && (req != TCSETSW) && (req != TCSETSF) { + return ENOSYS + } + err := Tcsetattr(fd, int(req), value) + runtime.KeepAlive(value) + return err +} + +// IoctlGetInt performs an ioctl operation which gets an integer value +// from fd, using the specified request number. +// +// A few ioctl requests use the return value as an output parameter; +// for those, IoctlRetInt should be used instead of this function. +func IoctlGetInt(fd int, req uint) (int, error) { + var value int + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return value, err +} + +func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { + var value Winsize + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return &value, err +} + +// IoctlGetTermios performs an ioctl on fd with a *Termios. +// +// The req value is expected to be TCGETS +func IoctlGetTermios(fd int, req uint) (*Termios, error) { + var value Termios + if req != TCGETS { + return &value, ENOSYS + } + err := Tcgetattr(fd, &value) + return &value, err +} diff --git a/vendor/golang.org/x/sys/unix/mkall.sh b/vendor/golang.org/x/sys/unix/mkall.sh index d257fac5057..d727cad19c1 100644 --- a/vendor/golang.org/x/sys/unix/mkall.sh +++ b/vendor/golang.org/x/sys/unix/mkall.sh @@ -199,7 +199,7 @@ illumos_amd64) mksyscall="go run mksyscall_solaris.go" mkerrors= mksysnum= - mktypes= + mktypes="GOARCH=$GOARCH go tool cgo -godefs" ;; *) echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2 diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index c0f9f2d523f..f2bc8631494 100644 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -56,6 +56,7 @@ includes_Darwin=' #define _DARWIN_C_SOURCE #define KERNEL #define _DARWIN_USE_64_BIT_INODE +#define __APPLE_USE_RFC_3542 #include #include #include @@ -65,6 +66,7 @@ includes_Darwin=' #include #include #include +#include #include #include #include @@ -114,6 +116,7 @@ includes_FreeBSD=' #include #include #include +#include #include #include #include @@ -204,6 +207,7 @@ struct ltchars { #include #include #include +#include #include #include #include @@ -212,6 +216,8 @@ struct ltchars { #include #include #include +#include +#include #include #include #include @@ -222,6 +228,7 @@ struct ltchars { #include #include #include +#include #include #include #include @@ -298,6 +305,17 @@ struct ltchars { // Including linux/l2tp.h here causes conflicts between linux/in.h // and netinet/in.h included via net/route.h above. #define IPPROTO_L2TP 115 + +// Copied from linux/hid.h. +// Keep in sync with the size of the referenced fields. +#define _HIDIOCGRAWNAME_LEN 128 // sizeof_field(struct hid_device, name) +#define _HIDIOCGRAWPHYS_LEN 64 // sizeof_field(struct hid_device, phys) +#define _HIDIOCGRAWUNIQ_LEN 64 // sizeof_field(struct hid_device, uniq) + +#define _HIDIOCGRAWNAME HIDIOCGRAWNAME(_HIDIOCGRAWNAME_LEN) +#define _HIDIOCGRAWPHYS HIDIOCGRAWPHYS(_HIDIOCGRAWPHYS_LEN) +#define _HIDIOCGRAWUNIQ HIDIOCGRAWUNIQ(_HIDIOCGRAWUNIQ_LEN) + ' includes_NetBSD=' @@ -445,6 +463,8 @@ ccflags="$@" $2 !~ /^EPROC_/ && $2 !~ /^EQUIV_/ && $2 !~ /^EXPR_/ && + $2 !~ /^EVIOC/ && + $2 !~ /^EV_/ && $2 ~ /^E[A-Z0-9_]+$/ || $2 ~ /^B[0-9_]+$/ || $2 ~ /^(OLD|NEW)DEV$/ || @@ -479,10 +499,10 @@ ccflags="$@" $2 ~ /^LOCK_(SH|EX|NB|UN)$/ || $2 ~ /^LO_(KEY|NAME)_SIZE$/ || $2 ~ /^LOOP_(CLR|CTL|GET|SET)_/ || - $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|MCAST|EVFILT|NOTE|EV|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ || + $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL)_/ || $2 ~ /^TP_STATUS_/ || $2 ~ /^FALLOC_/ || - $2 == "ICMPV6_FILTER" || + $2 ~ /^ICMP(V6)?_FILTER/ || $2 == "SOMAXCONN" || $2 == "NAME_MAX" || $2 == "IFNAMSIZ" || @@ -561,12 +581,17 @@ ccflags="$@" $2 ~ /^(HDIO|WIN|SMART)_/ || $2 ~ /^CRYPTO_/ || $2 ~ /^TIPC_/ || + $2 !~ "DEVLINK_RELOAD_LIMITS_VALID_MASK" && $2 ~ /^DEVLINK_/ || + $2 ~ /^ETHTOOL_/ || $2 ~ /^LWTUNNEL_IP/ || $2 !~ "WMESGLEN" && $2 ~ /^W[A-Z0-9]+$/ || $2 ~/^PPPIOC/ || $2 ~ /^FAN_|FANOTIFY_/ || + $2 == "HID_MAX_DESCRIPTOR_SIZE" || + $2 ~ /^_?HIDIOC/ || + $2 ~ /^BUS_(USB|HIL|BLUETOOTH|VIRTUAL)$/ || $2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE)/ {printf("\t%s = C.%s\n", $2, $2)} $2 ~ /^__WCOREFLAG$/ {next} $2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)} @@ -604,6 +629,7 @@ echo '#include ' | $CC -x c - -E -dM $ccflags | echo '// mkerrors.sh' "$@" echo '// Code generated by the command above; see README.md. DO NOT EDIT.' echo +echo "//go:build ${GOARCH} && ${GOOS}" echo "// +build ${GOARCH},${GOOS}" echo go tool cgo -godefs -- "$@" _const.go >_error.out diff --git a/vendor/golang.org/x/sys/unix/pagesize_unix.go b/vendor/golang.org/x/sys/unix/pagesize_unix.go index bc2f3629a7a..53f1b4c5b81 100644 --- a/vendor/golang.org/x/sys/unix/pagesize_unix.go +++ b/vendor/golang.org/x/sys/unix/pagesize_unix.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris // For Unix, get the pagesize from the runtime. diff --git a/vendor/golang.org/x/sys/unix/ptrace_darwin.go b/vendor/golang.org/x/sys/unix/ptrace_darwin.go new file mode 100644 index 00000000000..463c3eff7fd --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ptrace_darwin.go @@ -0,0 +1,12 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build darwin && !ios +// +build darwin,!ios + +package unix + +func ptrace(request int, pid int, addr uintptr, data uintptr) error { + return ptrace1(request, pid, addr, data) +} diff --git a/vendor/golang.org/x/sys/unix/ptrace_ios.go b/vendor/golang.org/x/sys/unix/ptrace_ios.go new file mode 100644 index 00000000000..ed0509a0117 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ptrace_ios.go @@ -0,0 +1,12 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build ios +// +build ios + +package unix + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + return ENOTSUP +} diff --git a/vendor/golang.org/x/sys/unix/race.go b/vendor/golang.org/x/sys/unix/race.go index 61712b51c96..6f6c5fec5ae 100644 --- a/vendor/golang.org/x/sys/unix/race.go +++ b/vendor/golang.org/x/sys/unix/race.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (darwin && race) || (linux && race) || (freebsd && race) // +build darwin,race linux,race freebsd,race package unix diff --git a/vendor/golang.org/x/sys/unix/race0.go b/vendor/golang.org/x/sys/unix/race0.go index ad026678c7c..706e1322ae4 100644 --- a/vendor/golang.org/x/sys/unix/race0.go +++ b/vendor/golang.org/x/sys/unix/race0.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly +//go:build aix || (darwin && !race) || (linux && !race) || (freebsd && !race) || netbsd || openbsd || solaris || dragonfly || zos +// +build aix darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly zos package unix diff --git a/vendor/golang.org/x/sys/unix/readdirent_getdents.go b/vendor/golang.org/x/sys/unix/readdirent_getdents.go index 3a90aa6dfae..4d6257569ea 100644 --- a/vendor/golang.org/x/sys/unix/readdirent_getdents.go +++ b/vendor/golang.org/x/sys/unix/readdirent_getdents.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || dragonfly || freebsd || linux || netbsd || openbsd // +build aix dragonfly freebsd linux netbsd openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/readdirent_getdirentries.go b/vendor/golang.org/x/sys/unix/readdirent_getdirentries.go index 5fdae40b3a8..2a4ba47c45b 100644 --- a/vendor/golang.org/x/sys/unix/readdirent_getdirentries.go +++ b/vendor/golang.org/x/sys/unix/readdirent_getdirentries.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin // +build darwin package unix diff --git a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go index 003916ed7a0..453a942c5db 100644 --- a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go +++ b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos // Socket control messages diff --git a/vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go b/vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go index 57a0021da55..0840fe4a574 100644 --- a/vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go +++ b/vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin freebsd linux netbsd openbsd solaris +//go:build aix || darwin || freebsd || linux || netbsd || openbsd || solaris || zos +// +build aix darwin freebsd linux netbsd openbsd solaris zos package unix @@ -36,6 +37,10 @@ func cmsgAlignOf(salen int) int { if runtime.GOOS == "netbsd" && runtime.GOARCH == "arm64" { salign = 16 } + case "zos": + // z/OS socket macros use [32-bit] sizeof(int) alignment, + // not pointer width. + salign = SizeofInt } return (salen + salign - 1) & ^(salign - 1) diff --git a/vendor/golang.org/x/sys/unix/str.go b/vendor/golang.org/x/sys/unix/str.go index 17fb6986831..8ba89ed8694 100644 --- a/vendor/golang.org/x/sys/unix/str.go +++ b/vendor/golang.org/x/sys/unix/str.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package unix diff --git a/vendor/golang.org/x/sys/unix/syscall.go b/vendor/golang.org/x/sys/unix/syscall.go index ab75ef9cc62..649fa87405d 100644 --- a/vendor/golang.org/x/sys/unix/syscall.go +++ b/vendor/golang.org/x/sys/unix/syscall.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos // Package unix contains an interface to the low-level operating system // primitives. OS details vary depending on the underlying system, and diff --git a/vendor/golang.org/x/sys/unix/syscall_aix.go b/vendor/golang.org/x/sys/unix/syscall_aix.go index 4408153822d..d8efb715ff1 100644 --- a/vendor/golang.org/x/sys/unix/syscall_aix.go +++ b/vendor/golang.org/x/sys/unix/syscall_aix.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix // +build aix // Aix system calls. @@ -251,7 +252,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { } } - bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] + bytes := (*[len(pp.Path)]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] sa.Name = string(bytes) return sa, nil @@ -419,8 +420,8 @@ func (w WaitStatus) TrapCause() int { return -1 } //sys Mknod(path string, mode uint32, dev int) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) -//sys Open(path string, mode int, perm uint32) (fd int, err error) = open64 -//sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) +//sys Open(path string, mode int, perm uint32) (fd int, err error) = open64 +//sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) //sys read(fd int, p []byte) (n int, err error) //sys Readlink(path string, buf []byte) (n int, err error) //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) @@ -439,8 +440,8 @@ func (w WaitStatus) TrapCause() int { return -1 } //sysnb Times(tms *Tms) (ticks uintptr, err error) //sysnb Umask(mask int) (oldmask int) //sysnb Uname(buf *Utsname) (err error) -//sys Unlink(path string) (err error) -//sys Unlinkat(dirfd int, path string, flags int) (err error) +//sys Unlink(path string) (err error) +//sys Unlinkat(dirfd int, path string, flags int) (err error) //sys Ustat(dev int, ubuf *Ustat_t) (err error) //sys write(fd int, p []byte) (n int, err error) //sys readlen(fd int, p *byte, np int) (n int, err error) = read @@ -514,7 +515,7 @@ func Munmap(b []byte) (err error) { //sys Munlock(b []byte) (err error) //sys Munlockall() (err error) -//sysnb pipe(p *[2]_C_int) (err error) +//sysnb pipe(p *[2]_C_int) (err error) func Pipe(p []int) (err error) { if len(p) != 2 { diff --git a/vendor/golang.org/x/sys/unix/syscall_aix_ppc.go b/vendor/golang.org/x/sys/unix/syscall_aix_ppc.go index b3c8e3301ce..e92a0be1630 100644 --- a/vendor/golang.org/x/sys/unix/syscall_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/syscall_aix_ppc.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix -// +build ppc +//go:build aix && ppc +// +build aix,ppc package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go b/vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go index 9a6e024179d..16eed17098e 100644 --- a/vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix -// +build ppc64 +//go:build aix && ppc64 +// +build aix,ppc64 package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_bsd.go b/vendor/golang.org/x/sys/unix/syscall_bsd.go index bc634a280a0..95ac3946b5c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_bsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_bsd.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin || dragonfly || freebsd || netbsd || openbsd // +build darwin dragonfly freebsd netbsd openbsd // BSD system call wrappers shared by *BSD based systems @@ -318,7 +319,7 @@ func Getsockname(fd int) (sa Sockaddr, err error) { return anyToSockaddr(fd, &rsa) } -//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) +//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) // GetsockoptString returns the string value of the socket option opt for the // socket associated with fd at the given socket level. @@ -332,8 +333,8 @@ func GetsockoptString(fd, level, opt int) (string, error) { return string(buf[:vallen-1]), nil } -//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) -//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) +//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) +//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { @@ -626,7 +627,7 @@ func Futimes(fd int, tv []Timeval) error { return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) } -//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) +//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) func Poll(fds []PollFd, timeout int) (n int, err error) { if len(fds) == 0 { diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.1_12.go b/vendor/golang.org/x/sys/unix/syscall_darwin.1_12.go index b31ef035881..b0098607c70 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.1_12.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin.1_12.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin && go1.12 && !go1.13 // +build darwin,go1.12,!go1.13 package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.1_13.go b/vendor/golang.org/x/sys/unix/syscall_darwin.1_13.go index dc0befee37e..5fc3cda6fc8 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.1_13.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin.1_13.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin && go1.13 // +build darwin,go1.13 package unix @@ -26,7 +27,6 @@ func fdopendir(fd int) (dir uintptr, err error) { func libc_fdopendir_trampoline() -//go:linkname libc_fdopendir libc_fdopendir //go:cgo_import_dynamic libc_fdopendir fdopendir "/usr/lib/libSystem.B.dylib" func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.go b/vendor/golang.org/x/sys/unix/syscall_darwin.go index b6257389008..1223d7aed1c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -119,13 +119,16 @@ type attrList struct { Forkattr uint32 } -//sysnb pipe() (r int, w int, err error) +//sysnb pipe(p *[2]int32) (err error) func Pipe(p []int) (err error) { if len(p) != 2 { return EINVAL } - p[0], p[1], err = pipe() + var x [2]int32 + err = pipe(&x) + p[0] = int(x[0]) + p[1] = int(x[1]) return } @@ -269,7 +272,7 @@ func setattrlistTimes(path string, times []Timespec, flags int) error { options) } -//sys setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) +//sys setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) func utimensat(dirfd int, path string, times *[2]Timespec, flags int) error { // Darwin doesn't support SYS_UTIMENSAT @@ -317,7 +320,7 @@ func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error { return err } -//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL +//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL func Uname(uname *Utsname) error { mib := []_C_int{CTL_KERN, KERN_OSTYPE} @@ -375,6 +378,15 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e return } +// GetsockoptXucred is a getsockopt wrapper that returns an Xucred struct. +// The usual level and opt are SOL_LOCAL and LOCAL_PEERCRED, respectively. +func GetsockoptXucred(fd, level, opt int) (*Xucred, error) { + x := new(Xucred) + vallen := _Socklen(SizeofXucred) + err := getsockopt(fd, level, opt, unsafe.Pointer(x), &vallen) + return x, err +} + //sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) /* @@ -469,8 +481,8 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e //sys Unlinkat(dirfd int, path string, flags int) (err error) //sys Unmount(path string, flags int) (err error) //sys write(fd int, p []byte) (n int, err error) -//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) -//sys munmap(addr uintptr, length uintptr) (err error) +//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) +//sys munmap(addr uintptr, length uintptr) (err error) //sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ //sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_386.go b/vendor/golang.org/x/sys/unix/syscall_darwin_386.go index 6c1f4ab95b4..64746771226 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_386.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build 386 && darwin // +build 386,darwin package unix @@ -45,6 +46,6 @@ func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, //sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64 //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 -//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error) +//sys ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) = SYS_ptrace //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64 diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go index 0582ae256ef..b37310ce9b4 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build amd64 && darwin // +build amd64,darwin package unix @@ -45,6 +46,6 @@ func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, //sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64 //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 -//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error) +//sys ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) = SYS_ptrace //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64 diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go b/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go index c6a9733b4cb..d30735c5d63 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go @@ -6,7 +6,7 @@ package unix import "syscall" -func ptrace(request int, pid int, addr uintptr, data uintptr) error { +func ptrace1(request int, pid int, addr uintptr, data uintptr) error { return ENOTSUP } diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go index 253afa4de55..d51ec996304 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build arm64 && darwin // +build arm64,darwin package unix @@ -45,6 +46,6 @@ func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, //sys Fstatfs(fd int, stat *Statfs_t) (err error) //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT //sys Lstat(path string, stat *Stat_t) (err error) -//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error) +//sys ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) = SYS_ptrace //sys Stat(path string, stat *Stat_t) (err error) //sys Statfs(path string, stat *Statfs_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go b/vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go index f34c86c899a..38bec300262 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin && go1.12 // +build darwin,go1.12 package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go index a4f2944a24e..5af108a5038 100644 --- a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go +++ b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go @@ -95,7 +95,7 @@ func direntNamlen(buf []byte) (uint64, bool) { return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen)) } -//sysnb pipe() (r int, w int, err error) +//sysnb pipe() (r int, w int, err error) func Pipe(p []int) (err error) { if len(p) != 2 { @@ -105,16 +105,16 @@ func Pipe(p []int) (err error) { return } -//sysnb pipe2(p *[2]_C_int, flags int) (err error) +//sysnb pipe2(p *[2]_C_int, flags int) (r int, w int, err error) -func Pipe2(p []int, flags int) error { +func Pipe2(p []int, flags int) (err error) { if len(p) != 2 { return EINVAL } var pp [2]_C_int - err := pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) + // pipe2 on dragonfly takes an fds array as an argument, but still + // returns the file descriptors. + p[0], p[1], err = pipe2(&pp, flags) return err } @@ -170,7 +170,7 @@ func setattrlistTimes(path string, times []Timespec, flags int) error { //sys ioctl(fd int, req uint, arg uintptr) (err error) -//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL +//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL func sysctlUname(mib []_C_int, old *byte, oldlen *uintptr) error { err := sysctl(mib, old, oldlen, nil, 0) @@ -337,8 +337,8 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e //sys Unlinkat(dirfd int, path string, flags int) (err error) //sys Unmount(path string, flags int) (err error) //sys write(fd int, p []byte) (n int, err error) -//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) -//sys munmap(addr uintptr, length uintptr) (err error) +//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) +//sys munmap(addr uintptr, length uintptr) (err error) //sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ //sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE //sys accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go index a6b4830ac8a..4e2d32120a8 100644 --- a/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build amd64 && dragonfly // +build amd64,dragonfly package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd.go b/vendor/golang.org/x/sys/unix/syscall_freebsd.go index acc00c2e6a1..18c392cf369 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd.go @@ -126,6 +126,15 @@ func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) { return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq)) } +// GetsockoptXucred is a getsockopt wrapper that returns an Xucred struct. +// The usual level and opt are SOL_LOCAL and LOCAL_PEERCRED, respectively. +func GetsockoptXucred(fd, level, opt int) (*Xucred, error) { + x := new(Xucred) + vallen := _Socklen(SizeofXucred) + err := getsockopt(fd, level, opt, unsafe.Pointer(x), &vallen) + return x, err +} + func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) { var rsa RawSockaddrAny var len _Socklen = SizeofSockaddrAny @@ -188,9 +197,9 @@ func setattrlistTimes(path string, times []Timespec, flags int) error { return ENOSYS } -//sys ioctl(fd int, req uint, arg uintptr) (err error) +//sys ioctl(fd int, req uint, arg uintptr) (err error) -//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL +//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL func Uname(uname *Utsname) error { mib := []_C_int{CTL_KERN, KERN_OSTYPE} @@ -665,8 +674,8 @@ func PtraceSingleStep(pid int) (err error) { //sys Unlinkat(dirfd int, path string, flags int) (err error) //sys Unmount(path string, flags int) (err error) //sys write(fd int, p []byte) (n int, err error) -//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) -//sys munmap(addr uintptr, length uintptr) (err error) +//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) +//sys munmap(addr uintptr, length uintptr) (err error) //sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ //sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE //sys accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go index 72a506ddcb5..342fc32b168 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build 386 && freebsd // +build 386,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go index d5e376acaea..a32d5aa4aed 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build amd64 && freebsd // +build amd64,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go index 4ea45bce52b..1e36d39abe0 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build arm && freebsd // +build arm,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go index aa5326db193..a09a1537bd6 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build arm64 && freebsd // +build arm64,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_illumos.go b/vendor/golang.org/x/sys/unix/syscall_illumos.go index bbc4f3ea543..c5c58806ca8 100644 --- a/vendor/golang.org/x/sys/unix/syscall_illumos.go +++ b/vendor/golang.org/x/sys/unix/syscall_illumos.go @@ -4,11 +4,14 @@ // illumos system calls not present on Solaris. +//go:build amd64 && illumos // +build amd64,illumos package unix -import "unsafe" +import ( + "unsafe" +) func bytes2iovec(bs [][]byte) []Iovec { iovecs := make([]Iovec, len(bs)) @@ -76,15 +79,51 @@ func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) { return } -//sysnb pipe2(p *[2]_C_int, flags int) (err error) +//sys putmsg(fd int, clptr *strbuf, dataptr *strbuf, flags int) (err error) -func Pipe2(p []int, flags int) error { - if len(p) != 2 { - return EINVAL +func Putmsg(fd int, cl []byte, data []byte, flags int) (err error) { + var clp, datap *strbuf + if len(cl) > 0 { + clp = &strbuf{ + Len: int32(len(cl)), + Buf: (*int8)(unsafe.Pointer(&cl[0])), + } + } + if len(data) > 0 { + datap = &strbuf{ + Len: int32(len(data)), + Buf: (*int8)(unsafe.Pointer(&data[0])), + } + } + return putmsg(fd, clp, datap, flags) +} + +//sys getmsg(fd int, clptr *strbuf, dataptr *strbuf, flags *int) (err error) + +func Getmsg(fd int, cl []byte, data []byte) (retCl []byte, retData []byte, flags int, err error) { + var clp, datap *strbuf + if len(cl) > 0 { + clp = &strbuf{ + Maxlen: int32(len(cl)), + Buf: (*int8)(unsafe.Pointer(&cl[0])), + } + } + if len(data) > 0 { + datap = &strbuf{ + Maxlen: int32(len(data)), + Buf: (*int8)(unsafe.Pointer(&data[0])), + } + } + + if err = getmsg(fd, clp, datap, &flags); err != nil { + return nil, nil, 0, err + } + + if len(cl) > 0 { + retCl = cl[:clp.Len] + } + if len(data) > 0 { + retData = data[:datap.Len] } - var pp [2]_C_int - err := pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return err + return retCl, retData, flags, nil } diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index 84a9e5277ac..44ea96e39c6 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -137,12 +137,61 @@ func IoctlFileClone(destFd, srcFd int) error { return ioctl(destFd, FICLONE, uintptr(srcFd)) } +type FileDedupeRange struct { + Src_offset uint64 + Src_length uint64 + Reserved1 uint16 + Reserved2 uint32 + Info []FileDedupeRangeInfo +} + +type FileDedupeRangeInfo struct { + Dest_fd int64 + Dest_offset uint64 + Bytes_deduped uint64 + Status int32 + Reserved uint32 +} + // IoctlFileDedupeRange performs an FIDEDUPERANGE ioctl operation to share the -// range of data conveyed in value with the file associated with the file -// descriptor destFd. See the ioctl_fideduperange(2) man page for details. -func IoctlFileDedupeRange(destFd int, value *FileDedupeRange) error { - err := ioctl(destFd, FIDEDUPERANGE, uintptr(unsafe.Pointer(value))) - runtime.KeepAlive(value) +// range of data conveyed in value from the file associated with the file +// descriptor srcFd to the value.Info destinations. See the +// ioctl_fideduperange(2) man page for details. +func IoctlFileDedupeRange(srcFd int, value *FileDedupeRange) error { + buf := make([]byte, SizeofRawFileDedupeRange+ + len(value.Info)*SizeofRawFileDedupeRangeInfo) + rawrange := (*RawFileDedupeRange)(unsafe.Pointer(&buf[0])) + rawrange.Src_offset = value.Src_offset + rawrange.Src_length = value.Src_length + rawrange.Dest_count = uint16(len(value.Info)) + rawrange.Reserved1 = value.Reserved1 + rawrange.Reserved2 = value.Reserved2 + + for i := range value.Info { + rawinfo := (*RawFileDedupeRangeInfo)(unsafe.Pointer( + uintptr(unsafe.Pointer(&buf[0])) + uintptr(SizeofRawFileDedupeRange) + + uintptr(i*SizeofRawFileDedupeRangeInfo))) + rawinfo.Dest_fd = value.Info[i].Dest_fd + rawinfo.Dest_offset = value.Info[i].Dest_offset + rawinfo.Bytes_deduped = value.Info[i].Bytes_deduped + rawinfo.Status = value.Info[i].Status + rawinfo.Reserved = value.Info[i].Reserved + } + + err := ioctl(srcFd, FIDEDUPERANGE, uintptr(unsafe.Pointer(&buf[0]))) + + // Output + for i := range value.Info { + rawinfo := (*RawFileDedupeRangeInfo)(unsafe.Pointer( + uintptr(unsafe.Pointer(&buf[0])) + uintptr(SizeofRawFileDedupeRange) + + uintptr(i*SizeofRawFileDedupeRangeInfo))) + value.Info[i].Dest_fd = rawinfo.Dest_fd + value.Info[i].Dest_offset = rawinfo.Dest_offset + value.Info[i].Bytes_deduped = rawinfo.Bytes_deduped + value.Info[i].Status = rawinfo.Status + value.Info[i].Reserved = rawinfo.Reserved + } + return err } @@ -153,6 +202,36 @@ func IoctlWatchdogKeepalive(fd int) error { return ioctl(fd, WDIOC_KEEPALIVE, 0) } +func IoctlHIDGetDesc(fd int, value *HIDRawReportDescriptor) error { + err := ioctl(fd, HIDIOCGRDESC, uintptr(unsafe.Pointer(value))) + runtime.KeepAlive(value) + return err +} + +func IoctlHIDGetRawInfo(fd int) (*HIDRawDevInfo, error) { + var value HIDRawDevInfo + err := ioctl(fd, HIDIOCGRAWINFO, uintptr(unsafe.Pointer(&value))) + return &value, err +} + +func IoctlHIDGetRawName(fd int) (string, error) { + var value [_HIDIOCGRAWNAME_LEN]byte + err := ioctl(fd, _HIDIOCGRAWNAME, uintptr(unsafe.Pointer(&value[0]))) + return ByteSliceToString(value[:]), err +} + +func IoctlHIDGetRawPhys(fd int) (string, error) { + var value [_HIDIOCGRAWPHYS_LEN]byte + err := ioctl(fd, _HIDIOCGRAWPHYS, uintptr(unsafe.Pointer(&value[0]))) + return ByteSliceToString(value[:]), err +} + +func IoctlHIDGetRawUniq(fd int) (string, error) { + var value [_HIDIOCGRAWUNIQ_LEN]byte + err := ioctl(fd, _HIDIOCGRAWUNIQ, uintptr(unsafe.Pointer(&value[0]))) + return ByteSliceToString(value[:]), err +} + //sys Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) func Link(oldpath string, newpath string) (err error) { @@ -641,6 +720,36 @@ func (sa *SockaddrCAN) sockaddr() (unsafe.Pointer, _Socklen, error) { return unsafe.Pointer(&sa.raw), SizeofSockaddrCAN, nil } +// SockaddrCANJ1939 implements the Sockaddr interface for AF_CAN using J1939 +// protocol (https://en.wikipedia.org/wiki/SAE_J1939). For more information +// on the purposes of the fields, check the official linux kernel documentation +// available here: https://www.kernel.org/doc/Documentation/networking/j1939.rst +type SockaddrCANJ1939 struct { + Ifindex int + Name uint64 + PGN uint32 + Addr uint8 + raw RawSockaddrCAN +} + +func (sa *SockaddrCANJ1939) sockaddr() (unsafe.Pointer, _Socklen, error) { + if sa.Ifindex < 0 || sa.Ifindex > 0x7fffffff { + return nil, 0, EINVAL + } + sa.raw.Family = AF_CAN + sa.raw.Ifindex = int32(sa.Ifindex) + n := (*[8]byte)(unsafe.Pointer(&sa.Name)) + for i := 0; i < 8; i++ { + sa.raw.Addr[i] = n[i] + } + p := (*[4]byte)(unsafe.Pointer(&sa.PGN)) + for i := 0; i < 4; i++ { + sa.raw.Addr[i+8] = p[i] + } + sa.raw.Addr[12] = sa.Addr + return unsafe.Pointer(&sa.raw), SizeofSockaddrCAN, nil +} + // SockaddrALG implements the Sockaddr interface for AF_ALG type sockets. // SockaddrALG enables userspace access to the Linux kernel's cryptography // subsystem. The Type and Name fields specify which type of hash or cipher @@ -952,6 +1061,10 @@ func (sa *SockaddrIUCV) sockaddr() (unsafe.Pointer, _Socklen, error) { return unsafe.Pointer(&sa.raw), SizeofSockaddrIUCV, nil } +var socketProtocol = func(fd int) (int, error) { + return GetsockoptInt(fd, SOL_SOCKET, SO_PROTOCOL) +} + func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { switch rsa.Addr.Family { case AF_NETLINK: @@ -1002,7 +1115,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { return sa, nil case AF_INET: - proto, err := GetsockoptInt(fd, SOL_SOCKET, SO_PROTOCOL) + proto, err := socketProtocol(fd) if err != nil { return nil, err } @@ -1028,7 +1141,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { } case AF_INET6: - proto, err := GetsockoptInt(fd, SOL_SOCKET, SO_PROTOCOL) + proto, err := socketProtocol(fd) if err != nil { return nil, err } @@ -1063,7 +1176,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { } return sa, nil case AF_BLUETOOTH: - proto, err := GetsockoptInt(fd, SOL_SOCKET, SO_PROTOCOL) + proto, err := socketProtocol(fd) if err != nil { return nil, err } @@ -1150,20 +1263,43 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { return sa, nil case AF_CAN: - pp := (*RawSockaddrCAN)(unsafe.Pointer(rsa)) - sa := &SockaddrCAN{ - Ifindex: int(pp.Ifindex), - } - rx := (*[4]byte)(unsafe.Pointer(&sa.RxID)) - for i := 0; i < 4; i++ { - rx[i] = pp.Addr[i] - } - tx := (*[4]byte)(unsafe.Pointer(&sa.TxID)) - for i := 0; i < 4; i++ { - tx[i] = pp.Addr[i+4] + proto, err := socketProtocol(fd) + if err != nil { + return nil, err } - return sa, nil + pp := (*RawSockaddrCAN)(unsafe.Pointer(rsa)) + + switch proto { + case CAN_J1939: + sa := &SockaddrCANJ1939{ + Ifindex: int(pp.Ifindex), + } + name := (*[8]byte)(unsafe.Pointer(&sa.Name)) + for i := 0; i < 8; i++ { + name[i] = pp.Addr[i] + } + pgn := (*[4]byte)(unsafe.Pointer(&sa.PGN)) + for i := 0; i < 4; i++ { + pgn[i] = pp.Addr[i+8] + } + addr := (*[1]byte)(unsafe.Pointer(&sa.Addr)) + addr[0] = pp.Addr[12] + return sa, nil + default: + sa := &SockaddrCAN{ + Ifindex: int(pp.Ifindex), + } + rx := (*[4]byte)(unsafe.Pointer(&sa.RxID)) + for i := 0; i < 4; i++ { + rx[i] = pp.Addr[i] + } + tx := (*[4]byte)(unsafe.Pointer(&sa.TxID)) + for i := 0; i < 4; i++ { + tx[i] = pp.Addr[i+4] + } + return sa, nil + } } return nil, EAFNOSUPPORT } @@ -1425,8 +1561,8 @@ func KeyctlRestrictKeyring(ringid int, keyType string, restriction string) error return keyctlRestrictKeyringByType(KEYCTL_RESTRICT_KEYRING, ringid, keyType, restriction) } -//sys keyctlRestrictKeyringByType(cmd int, arg2 int, keyType string, restriction string) (err error) = SYS_KEYCTL -//sys keyctlRestrictKeyring(cmd int, arg2 int) (err error) = SYS_KEYCTL +//sys keyctlRestrictKeyringByType(cmd int, arg2 int, keyType string, restriction string) (err error) = SYS_KEYCTL +//sys keyctlRestrictKeyring(cmd int, arg2 int) (err error) = SYS_KEYCTL func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { var msg Msghdr @@ -1741,6 +1877,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e //sys ClockGettime(clockid int32, time *Timespec) (err error) //sys ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error) //sys Close(fd int) (err error) +//sys CloseRange(first uint, last uint, flags uint) (err error) //sys CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) //sys DeleteModule(name string, flags int) (err error) //sys Dup(oldfd int) (fd int, err error) @@ -1803,8 +1940,8 @@ func Getpgrp() (pid int) { //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys PerfEventOpen(attr *PerfEventAttr, pid int, cpu int, groupFd int, flags int) (fd int, err error) //sys PivotRoot(newroot string, putold string) (err error) = SYS_PIVOT_ROOT -//sysnb prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) = SYS_PRLIMIT64 -//sys Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) +//sysnb prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) = SYS_PRLIMIT64 +//sys Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) //sys Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) = SYS_PSELECT6 //sys read(fd int, p []byte) (n int, err error) //sys Removexattr(path string, attr string) (err error) @@ -1877,9 +2014,9 @@ func Signalfd(fd int, sigmask *Sigset_t, flags int) (newfd int, err error) { //sys Syncfs(fd int) (err error) //sysnb Sysinfo(info *Sysinfo_t) (err error) //sys Tee(rfd int, wfd int, len int, flags int) (n int64, err error) -//sysnb TimerfdCreate(clockid int, flags int) (fd int, err error) -//sysnb TimerfdGettime(fd int, currValue *ItimerSpec) (err error) -//sysnb TimerfdSettime(fd int, flags int, newValue *ItimerSpec, oldValue *ItimerSpec) (err error) +//sysnb TimerfdCreate(clockid int, flags int) (fd int, err error) +//sysnb TimerfdGettime(fd int, currValue *ItimerSpec) (err error) +//sysnb TimerfdSettime(fd int, flags int, newValue *ItimerSpec, oldValue *ItimerSpec) (err error) //sysnb Tgkill(tgid int, tid int, sig syscall.Signal) (err error) //sysnb Times(tms *Tms) (ticks uintptr, err error) //sysnb Umask(mask int) (oldmask int) @@ -2139,8 +2276,8 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { return EACCES } -//sys nameToHandleAt(dirFD int, pathname string, fh *fileHandle, mountID *_C_int, flags int) (err error) = SYS_NAME_TO_HANDLE_AT -//sys openByHandleAt(mountFD int, fh *fileHandle, flags int) (fd int, err error) = SYS_OPEN_BY_HANDLE_AT +//sys nameToHandleAt(dirFD int, pathname string, fh *fileHandle, mountID *_C_int, flags int) (err error) = SYS_NAME_TO_HANDLE_AT +//sys openByHandleAt(mountFD int, fh *fileHandle, flags int) (fd int, err error) = SYS_OPEN_BY_HANDLE_AT // fileHandle is the argument to nameToHandleAt and openByHandleAt. We // originally tried to generate it via unix/linux/types.go with "type diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_386.go b/vendor/golang.org/x/sys/unix/syscall_linux_386.go index c97c2ee53e5..7b52e5d8a40 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_386.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build 386 && linux // +build 386,linux package unix @@ -31,7 +32,7 @@ func Pipe(p []int) (err error) { return } -//sysnb pipe2(p *[2]_C_int, flags int) (err error) +//sysnb pipe2(p *[2]_C_int, flags int) (err error) func Pipe2(p []int, flags int) (err error) { if len(p) != 2 { @@ -98,7 +99,7 @@ type rlimit32 struct { Max uint32 } -//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_GETRLIMIT +//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_GETRLIMIT const rlimInf32 = ^uint32(0) const rlimInf64 = ^uint64(0) @@ -129,7 +130,7 @@ func Getrlimit(resource int, rlim *Rlimit) (err error) { return } -//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT +//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT func Setrlimit(resource int, rlim *Rlimit) (err error) { err = prlimit(0, resource, rlim, nil) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go index 72efe86ed4f..28b76411522 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build amd64 && linux // +build amd64,linux package unix @@ -138,7 +139,7 @@ func Pipe(p []int) (err error) { return } -//sysnb pipe2(p *[2]_C_int, flags int) (err error) +//sysnb pipe2(p *[2]_C_int, flags int) (err error) func Pipe2(p []int, flags int) (err error) { if len(p) != 2 { diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go b/vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go index baa771f8ad9..8b0f0f3aa56 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build amd64,linux -// +build gc +//go:build amd64 && linux && gc +// +build amd64,linux,gc package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_arm.go b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go index 496837b1e37..68877728ec6 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build arm && linux // +build arm,linux package unix @@ -35,7 +36,7 @@ func Pipe(p []int) (err error) { return } -//sysnb pipe2(p *[2]_C_int, flags int) (err error) +//sysnb pipe2(p *[2]_C_int, flags int) (err error) func Pipe2(p []int, flags int) (err error) { if len(p) != 2 { @@ -129,8 +130,8 @@ func Utime(path string, buf *Utimbuf) error { //sys utimes(path string, times *[2]Timeval) (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64 //sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64 @@ -177,7 +178,7 @@ type rlimit32 struct { Max uint32 } -//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_UGETRLIMIT +//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_UGETRLIMIT const rlimInf32 = ^uint32(0) const rlimInf64 = ^uint64(0) @@ -208,7 +209,7 @@ func Getrlimit(resource int, rlim *Rlimit) (err error) { return } -//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT +//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT func Setrlimit(resource int, rlim *Rlimit) (err error) { err = prlimit(0, resource, rlim, nil) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go index c6de6b91345..7ed7034761c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build arm64 && linux // +build arm64,linux package unix @@ -155,7 +156,7 @@ func Pipe(p []int) (err error) { return } -//sysnb pipe2(p *[2]_C_int, flags int) (err error) +//sysnb pipe2(p *[2]_C_int, flags int) (err error) func Pipe2(p []int, flags int) (err error) { if len(p) != 2 { diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_gc.go b/vendor/golang.org/x/sys/unix/syscall_linux_gc.go index 9edf3961b01..2b1168d7d19 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_gc.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_gc.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && gc // +build linux,gc package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go b/vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go index 90e33d8cf75..9843fb48960 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && gc && 386 // +build linux,gc,386 package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_gc_arm.go b/vendor/golang.org/x/sys/unix/syscall_linux_gc_arm.go index 1a97baae732..a6008fccd59 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_gc_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_gc_arm.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build arm && gc && linux // +build arm,gc,linux package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go b/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go index 308eb7aecfa..7740af2428b 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && gccgo && 386 // +build linux,gccgo,386 package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go b/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go index aa7fc9e1997..e16a12299ae 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && gccgo && arm // +build linux,gccgo,arm package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go index f0287476cd5..06dec06fa19 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && (mips64 || mips64le) // +build linux // +build mips64 mips64le @@ -104,7 +105,7 @@ func Pipe(p []int) (err error) { return } -//sysnb pipe2(p *[2]_C_int, flags int) (err error) +//sysnb pipe2(p *[2]_C_int, flags int) (err error) func Pipe2(p []int, flags int) (err error) { if len(p) != 2 { diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go b/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go index c11328111d1..8f0d0a5b592 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && (mips || mipsle) // +build linux // +build mips mipsle @@ -112,7 +113,7 @@ func setTimeval(sec, usec int64) Timeval { return Timeval{Sec: int32(sec), Usec: int32(usec)} } -//sysnb pipe2(p *[2]_C_int, flags int) (err error) +//sysnb pipe2(p *[2]_C_int, flags int) (err error) func Pipe2(p []int, flags int) (err error) { if len(p) != 2 { @@ -125,7 +126,7 @@ func Pipe2(p []int, flags int) (err error) { return } -//sysnb pipe() (p1 int, p2 int, err error) +//sysnb pipe() (p1 int, p2 int, err error) func Pipe(p []int) (err error) { if len(p) != 2 { @@ -153,7 +154,7 @@ type rlimit32 struct { Max uint32 } -//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_GETRLIMIT +//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_GETRLIMIT func Getrlimit(resource int, rlim *Rlimit) (err error) { err = prlimit(0, resource, nil, rlim) @@ -181,7 +182,7 @@ func Getrlimit(resource int, rlim *Rlimit) (err error) { return } -//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT +//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT func Setrlimit(resource int, rlim *Rlimit) (err error) { err = prlimit(0, resource, rlim, nil) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go index 349374409ba..0b1f0d6da57 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && (ppc64 || ppc64le) // +build linux // +build ppc64 ppc64le @@ -99,7 +100,7 @@ func (cmsg *Cmsghdr) SetLen(length int) { cmsg.Len = uint64(length) } -//sysnb pipe(p *[2]_C_int) (err error) +//sysnb pipe(p *[2]_C_int) (err error) func Pipe(p []int) (err error) { if len(p) != 2 { @@ -112,7 +113,7 @@ func Pipe(p []int) (err error) { return } -//sysnb pipe2(p *[2]_C_int, flags int) (err error) +//sysnb pipe2(p *[2]_C_int, flags int) (err error) func Pipe2(p []int, flags int) (err error) { if len(p) != 2 { diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go b/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go index b0b1505565b..ce9bcd31717 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build riscv64 && linux // +build riscv64,linux package unix @@ -154,7 +155,7 @@ func Pipe(p []int) (err error) { return } -//sysnb pipe2(p *[2]_C_int, flags int) (err error) +//sysnb pipe2(p *[2]_C_int, flags int) (err error) func Pipe2(p []int, flags int) (err error) { if len(p) != 2 { diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go index 2363f749913..a1e45694b44 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build s390x && linux // +build s390x,linux package unix @@ -76,7 +77,7 @@ func setTimeval(sec, usec int64) Timeval { return Timeval{Sec: sec, Usec: usec} } -//sysnb pipe2(p *[2]_C_int, flags int) (err error) +//sysnb pipe2(p *[2]_C_int, flags int) (err error) func Pipe(p []int) (err error) { if len(p) != 2 { @@ -249,7 +250,7 @@ func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen } func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) error { - args := [4]uintptr{uintptr(s), uintptr(level), uintptr(name), uintptr(val)} + args := [5]uintptr{uintptr(s), uintptr(level), uintptr(name), uintptr(val), vallen} _, _, err := Syscall(SYS_SOCKETCALL, netSetSockOpt, uintptr(unsafe.Pointer(&args)), 0) if err != 0 { return err diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go b/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go index d389f1518fa..49055a3cf51 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build sparc64 && linux // +build sparc64,linux package unix @@ -115,7 +116,7 @@ func (cmsg *Cmsghdr) SetLen(length int) { cmsg.Len = uint64(length) } -//sysnb pipe(p *[2]_C_int) (err error) +//sysnb pipe(p *[2]_C_int) (err error) func Pipe(p []int) (err error) { if len(p) != 2 { @@ -128,7 +129,7 @@ func Pipe(p []int) (err error) { return } -//sysnb pipe2(p *[2]_C_int, flags int) (err error) +//sysnb pipe2(p *[2]_C_int, flags int) (err error) func Pipe2(p []int, flags int) (err error) { if len(p) != 2 { diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd.go b/vendor/golang.org/x/sys/unix/syscall_netbsd.go index 1e6843b4c3d..853d5f0f436 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd.go @@ -110,7 +110,8 @@ func direntNamlen(buf []byte) (uint64, bool) { return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen)) } -//sysnb pipe() (fd1 int, fd2 int, err error) +//sysnb pipe() (fd1 int, fd2 int, err error) + func Pipe(p []int) (err error) { if len(p) != 2 { return EINVAL @@ -119,7 +120,21 @@ func Pipe(p []int) (err error) { return } -//sys Getdents(fd int, buf []byte) (n int, err error) +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe2(p []int, flags int) error { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err := pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return err +} + +//sys Getdents(fd int, buf []byte) (n int, err error) + func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { n, err = Getdents(fd, buf) if err != nil || basep == nil { @@ -159,7 +174,7 @@ func setattrlistTimes(path string, times []Timespec, flags int) error { //sys ioctl(fd int, req uint, arg uintptr) (err error) -//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL +//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL func IoctlGetPtmget(fd int, req uint) (*Ptmget, error) { var value Ptmget diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go b/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go index 24da8b52454..5199d282fd0 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build 386 && netbsd // +build 386,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go index 25a0ac82589..70a9c52e980 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build amd64 && netbsd // +build amd64,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go b/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go index 21591ecd4d1..3eb5942f93f 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build arm && netbsd // +build arm,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd_arm64.go b/vendor/golang.org/x/sys/unix/syscall_netbsd_arm64.go index 80474963500..fc6ccfd810d 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd_arm64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build arm64 && netbsd // +build arm64,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/vendor/golang.org/x/sys/unix/syscall_openbsd.go index 6a50b50bd69..22b55038501 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -92,7 +92,7 @@ func Pipe2(p []int, flags int) error { return err } -//sys Getdents(fd int, buf []byte) (n int, err error) +//sys Getdents(fd int, buf []byte) (n int, err error) func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { n, err = Getdents(fd, buf) if err != nil || basep == nil { @@ -154,7 +154,7 @@ func setattrlistTimes(path string, times []Timespec, flags int) error { //sys ioctl(fd int, req uint, arg uintptr) (err error) -//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL +//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL //sys ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go index 42b5a0e51e8..6baabcdcb06 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build 386 && openbsd // +build 386,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go index 6ea4b48831b..bab25360eae 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build amd64 && openbsd // +build amd64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go index 1c3d26fa2c9..8eed3c4d4e7 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build arm && openbsd // +build arm,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_arm64.go index a8c458cb031..483dde99d4c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_arm64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build arm64 && openbsd // +build arm64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_solaris.go b/vendor/golang.org/x/sys/unix/syscall_solaris.go index fee6e995289..77fcde7c180 100644 --- a/vendor/golang.org/x/sys/unix/syscall_solaris.go +++ b/vendor/golang.org/x/sys/unix/syscall_solaris.go @@ -68,6 +68,19 @@ func Pipe(p []int) (err error) { return nil } +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe2(p []int, flags int) error { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err := pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return err +} + func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { if sa.Port < 0 || sa.Port > 0xFFFF { return nil, 0, EINVAL @@ -552,7 +565,12 @@ func Minor(dev uint64) uint32 { * Expose the ioctl function */ -//sys ioctl(fd int, req uint, arg uintptr) (err error) +//sys ioctlRet(fd int, req uint, arg uintptr) (ret int, err error) = libc.ioctl + +func ioctl(fd int, req uint, arg uintptr) (err error) { + _, err = ioctlRet(fd, req, arg) + return err +} func IoctlSetTermio(fd int, req uint, value *Termio) error { err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) @@ -566,7 +584,7 @@ func IoctlGetTermio(fd int, req uint) (*Termio, error) { return &value, err } -//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) +//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) func Poll(fds []PollFd, timeout int) (n int, err error) { if len(fds) == 0 { @@ -669,6 +687,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e //sys Statvfs(path string, vfsstat *Statvfs_t) (err error) //sys Symlink(path string, link string) (err error) //sys Sync() (err error) +//sys Sysconf(which int) (n int64, err error) //sysnb Times(tms *Tms) (ticks uintptr, err error) //sys Truncate(path string, length int64) (err error) //sys Fsync(fd int) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go b/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go index b22a34d7ae9..0bd25ef81f2 100644 --- a/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build amd64 && solaris // +build amd64,solaris package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_unix.go b/vendor/golang.org/x/sys/unix/syscall_unix.go index 400ba9fbc90..a7618ceb55e 100644 --- a/vendor/golang.org/x/sys/unix/syscall_unix.go +++ b/vendor/golang.org/x/sys/unix/syscall_unix.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_unix_gc.go b/vendor/golang.org/x/sys/unix/syscall_unix_gc.go index 87bd161cefc..5898e9a52b7 100644 --- a/vendor/golang.org/x/sys/unix/syscall_unix_gc.go +++ b/vendor/golang.org/x/sys/unix/syscall_unix_gc.go @@ -2,8 +2,11 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris) && gc && !ppc64le && !ppc64 // +build darwin dragonfly freebsd linux netbsd openbsd solaris -// +build gc,!ppc64le,!ppc64 +// +build gc +// +build !ppc64le +// +build !ppc64 package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go b/vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go index d36216c3ca7..f6f707acf2c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && (ppc64le || ppc64) && gc // +build linux // +build ppc64le ppc64 // +build gc diff --git a/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go b/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go new file mode 100644 index 00000000000..13f58d2b2fb --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go @@ -0,0 +1,1781 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build zos && s390x +// +build zos,s390x + +package unix + +import ( + "bytes" + "runtime" + "sort" + "sync" + "syscall" + "unsafe" +) + +const ( + O_CLOEXEC = 0 // Dummy value (not supported). + AF_LOCAL = AF_UNIX // AF_LOCAL is an alias for AF_UNIX +) + +func syscall_syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) +func syscall_rawsyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) +func syscall_syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) +func syscall_rawsyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) +func syscall_syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) +func syscall_rawsyscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) + +func copyStat(stat *Stat_t, statLE *Stat_LE_t) { + stat.Dev = uint64(statLE.Dev) + stat.Ino = uint64(statLE.Ino) + stat.Nlink = uint64(statLE.Nlink) + stat.Mode = uint32(statLE.Mode) + stat.Uid = uint32(statLE.Uid) + stat.Gid = uint32(statLE.Gid) + stat.Rdev = uint64(statLE.Rdev) + stat.Size = statLE.Size + stat.Atim.Sec = int64(statLE.Atim) + stat.Atim.Nsec = 0 //zos doesn't return nanoseconds + stat.Mtim.Sec = int64(statLE.Mtim) + stat.Mtim.Nsec = 0 //zos doesn't return nanoseconds + stat.Ctim.Sec = int64(statLE.Ctim) + stat.Ctim.Nsec = 0 //zos doesn't return nanoseconds + stat.Blksize = int64(statLE.Blksize) + stat.Blocks = statLE.Blocks +} + +func svcCall(fnptr unsafe.Pointer, argv *unsafe.Pointer, dsa *uint64) +func svcLoad(name *byte) unsafe.Pointer +func svcUnload(name *byte, fnptr unsafe.Pointer) int64 + +func (d *Dirent) NameString() string { + if d == nil { + return "" + } + return string(d.Name[:d.Namlen]) +} + +func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { + if sa.Port < 0 || sa.Port > 0xFFFF { + return nil, 0, EINVAL + } + sa.raw.Len = SizeofSockaddrInet4 + sa.raw.Family = AF_INET + p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) + p[0] = byte(sa.Port >> 8) + p[1] = byte(sa.Port) + for i := 0; i < len(sa.Addr); i++ { + sa.raw.Addr[i] = sa.Addr[i] + } + return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil +} + +func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { + if sa.Port < 0 || sa.Port > 0xFFFF { + return nil, 0, EINVAL + } + sa.raw.Len = SizeofSockaddrInet6 + sa.raw.Family = AF_INET6 + p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) + p[0] = byte(sa.Port >> 8) + p[1] = byte(sa.Port) + sa.raw.Scope_id = sa.ZoneId + for i := 0; i < len(sa.Addr); i++ { + sa.raw.Addr[i] = sa.Addr[i] + } + return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil +} + +func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) { + name := sa.Name + n := len(name) + if n >= len(sa.raw.Path) || n == 0 { + return nil, 0, EINVAL + } + sa.raw.Len = byte(3 + n) // 2 for Family, Len; 1 for NUL + sa.raw.Family = AF_UNIX + for i := 0; i < n; i++ { + sa.raw.Path[i] = int8(name[i]) + } + return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil +} + +func anyToSockaddr(_ int, rsa *RawSockaddrAny) (Sockaddr, error) { + // TODO(neeilan): Implement use of first param (fd) + switch rsa.Addr.Family { + case AF_UNIX: + pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa)) + sa := new(SockaddrUnix) + // For z/OS, only replace NUL with @ when the + // length is not zero. + if pp.Len != 0 && pp.Path[0] == 0 { + // "Abstract" Unix domain socket. + // Rewrite leading NUL as @ for textual display. + // (This is the standard convention.) + // Not friendly to overwrite in place, + // but the callers below don't care. + pp.Path[0] = '@' + } + + // Assume path ends at NUL. + // + // For z/OS, the length of the name is a field + // in the structure. To be on the safe side, we + // will still scan the name for a NUL but only + // to the length provided in the structure. + // + // This is not technically the Linux semantics for + // abstract Unix domain sockets--they are supposed + // to be uninterpreted fixed-size binary blobs--but + // everyone uses this convention. + n := 0 + for n < int(pp.Len) && pp.Path[n] != 0 { + n++ + } + bytes := (*[len(pp.Path)]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] + sa.Name = string(bytes) + return sa, nil + + case AF_INET: + pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa)) + sa := new(SockaddrInet4) + p := (*[2]byte)(unsafe.Pointer(&pp.Port)) + sa.Port = int(p[0])<<8 + int(p[1]) + for i := 0; i < len(sa.Addr); i++ { + sa.Addr[i] = pp.Addr[i] + } + return sa, nil + + case AF_INET6: + pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa)) + sa := new(SockaddrInet6) + p := (*[2]byte)(unsafe.Pointer(&pp.Port)) + sa.Port = int(p[0])<<8 + int(p[1]) + sa.ZoneId = pp.Scope_id + for i := 0; i < len(sa.Addr); i++ { + sa.Addr[i] = pp.Addr[i] + } + return sa, nil + } + return nil, EAFNOSUPPORT +} + +func Accept(fd int) (nfd int, sa Sockaddr, err error) { + var rsa RawSockaddrAny + var len _Socklen = SizeofSockaddrAny + nfd, err = accept(fd, &rsa, &len) + if err != nil { + return + } + // TODO(neeilan): Remove 0 in call + sa, err = anyToSockaddr(0, &rsa) + if err != nil { + Close(nfd) + nfd = 0 + } + return +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = int32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = int32(length) +} + +//sys fcntl(fd int, cmd int, arg int) (val int, err error) +//sys read(fd int, p []byte) (n int, err error) +//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ +//sys write(fd int, p []byte) (n int, err error) + +//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) = SYS___ACCEPT_A +//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = SYS___BIND_A +//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = SYS___CONNECT_A +//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) +//sysnb setgroups(n int, list *_Gid_t) (err error) +//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) +//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) +//sysnb socket(domain int, typ int, proto int) (fd int, err error) +//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) +//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = SYS___GETPEERNAME_A +//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = SYS___GETSOCKNAME_A +//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) = SYS___RECVFROM_A +//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) = SYS___SENDTO_A +//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) = SYS___RECVMSG_A +//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) = SYS___SENDMSG_A +//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) = SYS_MMAP +//sys munmap(addr uintptr, length uintptr) (err error) = SYS_MUNMAP +//sys ioctl(fd int, req uint, arg uintptr) (err error) = SYS_IOCTL + +//sys Access(path string, mode uint32) (err error) = SYS___ACCESS_A +//sys Chdir(path string) (err error) = SYS___CHDIR_A +//sys Chown(path string, uid int, gid int) (err error) = SYS___CHOWN_A +//sys Chmod(path string, mode uint32) (err error) = SYS___CHMOD_A +//sys Creat(path string, mode uint32) (fd int, err error) = SYS___CREAT_A +//sys Dup(oldfd int) (fd int, err error) +//sys Dup2(oldfd int, newfd int) (err error) +//sys Exit(code int) +//sys Fchdir(fd int) (err error) +//sys Fchmod(fd int, mode uint32) (err error) +//sys Fchown(fd int, uid int, gid int) (err error) +//sys FcntlInt(fd uintptr, cmd int, arg int) (retval int, err error) = SYS_FCNTL +//sys fstat(fd int, stat *Stat_LE_t) (err error) + +func Fstat(fd int, stat *Stat_t) (err error) { + var statLE Stat_LE_t + err = fstat(fd, &statLE) + copyStat(stat, &statLE) + return +} + +//sys Fstatvfs(fd int, stat *Statvfs_t) (err error) = SYS_FSTATVFS +//sys Fsync(fd int) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sys Getpagesize() (pgsize int) = SYS_GETPAGESIZE +//sys Mprotect(b []byte, prot int) (err error) = SYS_MPROTECT +//sys Msync(b []byte, flags int) (err error) = SYS_MSYNC +//sys Poll(fds []PollFd, timeout int) (n int, err error) = SYS_POLL +//sys Times(tms *Tms) (ticks uintptr, err error) = SYS_TIMES +//sys W_Getmntent(buff *byte, size int) (lastsys int, err error) = SYS_W_GETMNTENT + +//sys Mount(path string, filesystem string, fstype string, mtm uint32, parmlen int32, parm string) (err error) = SYS___MOUNT_A +//sys Unmount(filesystem string, mtm int) (err error) = SYS___UMOUNT_A +//sys Chroot(path string) (err error) = SYS___CHROOT_A +//sysnb Uname(buf *Utsname) (err error) = SYS___UNAME_A + +func Ptsname(fd int) (name string, err error) { + r0, _, e1 := syscall_syscall(SYS___PTSNAME_A, uintptr(fd), 0, 0) + name = u2s(unsafe.Pointer(r0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +func u2s(cstr unsafe.Pointer) string { + str := (*[1024]uint8)(cstr) + i := 0 + for str[i] != 0 { + i++ + } + return string(str[:i]) +} + +func Close(fd int) (err error) { + _, _, e1 := syscall_syscall(SYS_CLOSE, uintptr(fd), 0, 0) + for i := 0; e1 == EAGAIN && i < 10; i++ { + _, _, _ = syscall_syscall(SYS_USLEEP, uintptr(10), 0, 0) + _, _, e1 = syscall_syscall(SYS_CLOSE, uintptr(fd), 0, 0) + } + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var mapper = &mmapper{ + active: make(map[*byte][]byte), + mmap: mmap, + munmap: munmap, +} + +// Dummy function: there are no semantics for Madvise on z/OS +func Madvise(b []byte, advice int) (err error) { + return +} + +func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { + return mapper.Mmap(fd, offset, length, prot, flags) +} + +func Munmap(b []byte) (err error) { + return mapper.Munmap(b) +} + +//sys Gethostname(buf []byte) (err error) = SYS___GETHOSTNAME_A +//sysnb Getegid() (egid int) +//sysnb Geteuid() (uid int) +//sysnb Getgid() (gid int) +//sysnb Getpid() (pid int) +//sysnb Getpgid(pid int) (pgid int, err error) = SYS_GETPGID + +func Getpgrp() (pid int) { + pid, _ = Getpgid(0) + return +} + +//sysnb Getppid() (pid int) +//sys Getpriority(which int, who int) (prio int, err error) +//sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_GETRLIMIT + +//sysnb getrusage(who int, rusage *rusage_zos) (err error) = SYS_GETRUSAGE + +func Getrusage(who int, rusage *Rusage) (err error) { + var ruz rusage_zos + err = getrusage(who, &ruz) + //Only the first two fields of Rusage are set + rusage.Utime.Sec = ruz.Utime.Sec + rusage.Utime.Usec = int64(ruz.Utime.Usec) + rusage.Stime.Sec = ruz.Stime.Sec + rusage.Stime.Usec = int64(ruz.Stime.Usec) + return +} + +//sysnb Getsid(pid int) (sid int, err error) = SYS_GETSID +//sysnb Getuid() (uid int) +//sysnb Kill(pid int, sig Signal) (err error) +//sys Lchown(path string, uid int, gid int) (err error) = SYS___LCHOWN_A +//sys Link(path string, link string) (err error) = SYS___LINK_A +//sys Listen(s int, n int) (err error) +//sys lstat(path string, stat *Stat_LE_t) (err error) = SYS___LSTAT_A + +func Lstat(path string, stat *Stat_t) (err error) { + var statLE Stat_LE_t + err = lstat(path, &statLE) + copyStat(stat, &statLE) + return +} + +//sys Mkdir(path string, mode uint32) (err error) = SYS___MKDIR_A +//sys Mkfifo(path string, mode uint32) (err error) = SYS___MKFIFO_A +//sys Mknod(path string, mode uint32, dev int) (err error) = SYS___MKNOD_A +//sys Pread(fd int, p []byte, offset int64) (n int, err error) +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +//sys Readlink(path string, buf []byte) (n int, err error) = SYS___READLINK_A +//sys Rename(from string, to string) (err error) = SYS___RENAME_A +//sys Rmdir(path string) (err error) = SYS___RMDIR_A +//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK +//sys Setpriority(which int, who int, prio int) (err error) +//sysnb Setpgid(pid int, pgid int) (err error) = SYS_SETPGID +//sysnb Setrlimit(resource int, lim *Rlimit) (err error) +//sysnb Setregid(rgid int, egid int) (err error) = SYS_SETREGID +//sysnb Setreuid(ruid int, euid int) (err error) = SYS_SETREUID +//sysnb Setsid() (pid int, err error) = SYS_SETSID +//sys Setuid(uid int) (err error) = SYS_SETUID +//sys Setgid(uid int) (err error) = SYS_SETGID +//sys Shutdown(fd int, how int) (err error) +//sys stat(path string, statLE *Stat_LE_t) (err error) = SYS___STAT_A + +func Stat(path string, sta *Stat_t) (err error) { + var statLE Stat_LE_t + err = stat(path, &statLE) + copyStat(sta, &statLE) + return +} + +//sys Symlink(path string, link string) (err error) = SYS___SYMLINK_A +//sys Sync() = SYS_SYNC +//sys Truncate(path string, length int64) (err error) = SYS___TRUNCATE_A +//sys Tcgetattr(fildes int, termptr *Termios) (err error) = SYS_TCGETATTR +//sys Tcsetattr(fildes int, when int, termptr *Termios) (err error) = SYS_TCSETATTR +//sys Umask(mask int) (oldmask int) +//sys Unlink(path string) (err error) = SYS___UNLINK_A +//sys Utime(path string, utim *Utimbuf) (err error) = SYS___UTIME_A + +//sys open(path string, mode int, perm uint32) (fd int, err error) = SYS___OPEN_A + +func Open(path string, mode int, perm uint32) (fd int, err error) { + return open(path, mode, perm) +} + +func Mkfifoat(dirfd int, path string, mode uint32) (err error) { + wd, err := Getwd() + if err != nil { + return err + } + + if err := Fchdir(dirfd); err != nil { + return err + } + defer Chdir(wd) + + return Mkfifo(path, mode) +} + +//sys remove(path string) (err error) + +func Remove(path string) error { + return remove(path) +} + +const ImplementsGetwd = true + +func Getcwd(buf []byte) (n int, err error) { + var p unsafe.Pointer + if len(buf) > 0 { + p = unsafe.Pointer(&buf[0]) + } else { + p = unsafe.Pointer(&_zero) + } + _, _, e := syscall_syscall(SYS___GETCWD_A, uintptr(p), uintptr(len(buf)), 0) + n = clen(buf) + 1 + if e != 0 { + err = errnoErr(e) + } + return +} + +func Getwd() (wd string, err error) { + var buf [PathMax]byte + n, err := Getcwd(buf[0:]) + if err != nil { + return "", err + } + // Getcwd returns the number of bytes written to buf, including the NUL. + if n < 1 || n > len(buf) || buf[n-1] != 0 { + return "", EINVAL + } + return string(buf[0 : n-1]), nil +} + +func Getgroups() (gids []int, err error) { + n, err := getgroups(0, nil) + if err != nil { + return nil, err + } + if n == 0 { + return nil, nil + } + + // Sanity check group count. Max is 1<<16 on Linux. + if n < 0 || n > 1<<20 { + return nil, EINVAL + } + + a := make([]_Gid_t, n) + n, err = getgroups(n, &a[0]) + if err != nil { + return nil, err + } + gids = make([]int, n) + for i, v := range a[0:n] { + gids[i] = int(v) + } + return +} + +func Setgroups(gids []int) (err error) { + if len(gids) == 0 { + return setgroups(0, nil) + } + + a := make([]_Gid_t, len(gids)) + for i, v := range gids { + a[i] = _Gid_t(v) + } + return setgroups(len(a), &a[0]) +} + +func gettid() uint64 + +func Gettid() (tid int) { + return int(gettid()) +} + +type WaitStatus uint32 + +// Wait status is 7 bits at bottom, either 0 (exited), +// 0x7F (stopped), or a signal number that caused an exit. +// The 0x80 bit is whether there was a core dump. +// An extra number (exit code, signal causing a stop) +// is in the high bits. At least that's the idea. +// There are various irregularities. For example, the +// "continued" status is 0xFFFF, distinguishing itself +// from stopped via the core dump bit. + +const ( + mask = 0x7F + core = 0x80 + exited = 0x00 + stopped = 0x7F + shift = 8 +) + +func (w WaitStatus) Exited() bool { return w&mask == exited } + +func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != exited } + +func (w WaitStatus) Stopped() bool { return w&0xFF == stopped } + +func (w WaitStatus) Continued() bool { return w == 0xFFFF } + +func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 } + +func (w WaitStatus) ExitStatus() int { + if !w.Exited() { + return -1 + } + return int(w>>shift) & 0xFF +} + +func (w WaitStatus) Signal() Signal { + if !w.Signaled() { + return -1 + } + return Signal(w & mask) +} + +func (w WaitStatus) StopSignal() Signal { + if !w.Stopped() { + return -1 + } + return Signal(w>>shift) & 0xFF +} + +func (w WaitStatus) TrapCause() int { return -1 } + +//sys waitpid(pid int, wstatus *_C_int, options int) (wpid int, err error) + +func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) { + // TODO(mundaym): z/OS doesn't have wait4. I don't think getrusage does what we want. + // At the moment rusage will not be touched. + var status _C_int + wpid, err = waitpid(pid, &status, options) + if wstatus != nil { + *wstatus = WaitStatus(status) + } + return +} + +//sysnb gettimeofday(tv *timeval_zos) (err error) + +func Gettimeofday(tv *Timeval) (err error) { + var tvz timeval_zos + err = gettimeofday(&tvz) + tv.Sec = tvz.Sec + tv.Usec = int64(tvz.Usec) + return +} + +func Time(t *Time_t) (tt Time_t, err error) { + var tv Timeval + err = Gettimeofday(&tv) + if err != nil { + return 0, err + } + if t != nil { + *t = Time_t(tv.Sec) + } + return Time_t(tv.Sec), nil +} + +func setTimespec(sec, nsec int64) Timespec { + return Timespec{Sec: sec, Nsec: nsec} +} + +func setTimeval(sec, usec int64) Timeval { //fix + return Timeval{Sec: sec, Usec: usec} +} + +//sysnb pipe(p *[2]_C_int) (err error) + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe(&pp) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +//sys utimes(path string, timeval *[2]Timeval) (err error) = SYS___UTIMES_A + +func Utimes(path string, tv []Timeval) (err error) { + if len(tv) != 2 { + return EINVAL + } + return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) +} + +func UtimesNano(path string, ts []Timespec) error { + if len(ts) != 2 { + return EINVAL + } + // Not as efficient as it could be because Timespec and + // Timeval have different types in the different OSes + tv := [2]Timeval{ + NsecToTimeval(TimespecToNsec(ts[0])), + NsecToTimeval(TimespecToNsec(ts[1])), + } + return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) +} + +func Getsockname(fd int) (sa Sockaddr, err error) { + var rsa RawSockaddrAny + var len _Socklen = SizeofSockaddrAny + if err = getsockname(fd, &rsa, &len); err != nil { + return + } + // TODO(neeilan) : Remove this 0 ( added to get sys/unix compiling on z/OS ) + return anyToSockaddr(0, &rsa) +} + +const ( + // identifier constants + nwmHeaderIdentifier = 0xd5e6d4c8 + nwmFilterIdentifier = 0xd5e6d4c6 + nwmTCPConnIdentifier = 0xd5e6d4c3 + nwmRecHeaderIdentifier = 0xd5e6d4d9 + nwmIPStatsIdentifier = 0xd5e6d4c9d7e2e340 + nwmIPGStatsIdentifier = 0xd5e6d4c9d7c7e2e3 + nwmTCPStatsIdentifier = 0xd5e6d4e3c3d7e2e3 + nwmUDPStatsIdentifier = 0xd5e6d4e4c4d7e2e3 + nwmICMPGStatsEntry = 0xd5e6d4c9c3d4d7c7 + nwmICMPTStatsEntry = 0xd5e6d4c9c3d4d7e3 + + // nwmHeader constants + nwmVersion1 = 1 + nwmVersion2 = 2 + nwmCurrentVer = 2 + + nwmTCPConnType = 1 + nwmGlobalStatsType = 14 + + // nwmFilter constants + nwmFilterLclAddrMask = 0x20000000 // Local address + nwmFilterSrcAddrMask = 0x20000000 // Source address + nwmFilterLclPortMask = 0x10000000 // Local port + nwmFilterSrcPortMask = 0x10000000 // Source port + + // nwmConnEntry constants + nwmTCPStateClosed = 1 + nwmTCPStateListen = 2 + nwmTCPStateSynSent = 3 + nwmTCPStateSynRcvd = 4 + nwmTCPStateEstab = 5 + nwmTCPStateFinWait1 = 6 + nwmTCPStateFinWait2 = 7 + nwmTCPStateClosWait = 8 + nwmTCPStateLastAck = 9 + nwmTCPStateClosing = 10 + nwmTCPStateTimeWait = 11 + nwmTCPStateDeletTCB = 12 + + // Existing constants on linux + BPF_TCP_CLOSE = 1 + BPF_TCP_LISTEN = 2 + BPF_TCP_SYN_SENT = 3 + BPF_TCP_SYN_RECV = 4 + BPF_TCP_ESTABLISHED = 5 + BPF_TCP_FIN_WAIT1 = 6 + BPF_TCP_FIN_WAIT2 = 7 + BPF_TCP_CLOSE_WAIT = 8 + BPF_TCP_LAST_ACK = 9 + BPF_TCP_CLOSING = 10 + BPF_TCP_TIME_WAIT = 11 + BPF_TCP_NEW_SYN_RECV = -1 + BPF_TCP_MAX_STATES = -2 +) + +type nwmTriplet struct { + offset uint32 + length uint32 + number uint32 +} + +type nwmQuadruplet struct { + offset uint32 + length uint32 + number uint32 + match uint32 +} + +type nwmHeader struct { + ident uint32 + length uint32 + version uint16 + nwmType uint16 + bytesNeeded uint32 + options uint32 + _ [16]byte + inputDesc nwmTriplet + outputDesc nwmQuadruplet +} + +type nwmFilter struct { + ident uint32 + flags uint32 + resourceName [8]byte + resourceId uint32 + listenerId uint32 + local [28]byte // union of sockaddr4 and sockaddr6 + remote [28]byte // union of sockaddr4 and sockaddr6 + _ uint16 + _ uint16 + asid uint16 + _ [2]byte + tnLuName [8]byte + tnMonGrp uint32 + tnAppl [8]byte + applData [40]byte + nInterface [16]byte + dVipa [16]byte + dVipaPfx uint16 + dVipaPort uint16 + dVipaFamily byte + _ [3]byte + destXCF [16]byte + destXCFPfx uint16 + destXCFFamily byte + _ [1]byte + targIP [16]byte + targIPPfx uint16 + targIPFamily byte + _ [1]byte + _ [20]byte +} + +type nwmRecHeader struct { + ident uint32 + length uint32 + number byte + _ [3]byte +} + +type nwmTCPStatsEntry struct { + ident uint64 + currEstab uint32 + activeOpened uint32 + passiveOpened uint32 + connClosed uint32 + estabResets uint32 + attemptFails uint32 + passiveDrops uint32 + timeWaitReused uint32 + inSegs uint64 + predictAck uint32 + predictData uint32 + inDupAck uint32 + inBadSum uint32 + inBadLen uint32 + inShort uint32 + inDiscOldTime uint32 + inAllBeforeWin uint32 + inSomeBeforeWin uint32 + inAllAfterWin uint32 + inSomeAfterWin uint32 + inOutOfOrder uint32 + inAfterClose uint32 + inWinProbes uint32 + inWinUpdates uint32 + outWinUpdates uint32 + outSegs uint64 + outDelayAcks uint32 + outRsts uint32 + retransSegs uint32 + retransTimeouts uint32 + retransDrops uint32 + pmtuRetrans uint32 + pmtuErrors uint32 + outWinProbes uint32 + probeDrops uint32 + keepAliveProbes uint32 + keepAliveDrops uint32 + finwait2Drops uint32 + acceptCount uint64 + inBulkQSegs uint64 + inDiscards uint64 + connFloods uint32 + connStalls uint32 + cfgEphemDef uint16 + ephemInUse uint16 + ephemHiWater uint16 + flags byte + _ [1]byte + ephemExhaust uint32 + smcRCurrEstabLnks uint32 + smcRLnkActTimeOut uint32 + smcRActLnkOpened uint32 + smcRPasLnkOpened uint32 + smcRLnksClosed uint32 + smcRCurrEstab uint32 + smcRActiveOpened uint32 + smcRPassiveOpened uint32 + smcRConnClosed uint32 + smcRInSegs uint64 + smcROutSegs uint64 + smcRInRsts uint32 + smcROutRsts uint32 + smcDCurrEstabLnks uint32 + smcDActLnkOpened uint32 + smcDPasLnkOpened uint32 + smcDLnksClosed uint32 + smcDCurrEstab uint32 + smcDActiveOpened uint32 + smcDPassiveOpened uint32 + smcDConnClosed uint32 + smcDInSegs uint64 + smcDOutSegs uint64 + smcDInRsts uint32 + smcDOutRsts uint32 +} + +type nwmConnEntry struct { + ident uint32 + local [28]byte // union of sockaddr4 and sockaddr6 + remote [28]byte // union of sockaddr4 and sockaddr6 + startTime [8]byte // uint64, changed to prevent padding from being inserted + lastActivity [8]byte // uint64 + bytesIn [8]byte // uint64 + bytesOut [8]byte // uint64 + inSegs [8]byte // uint64 + outSegs [8]byte // uint64 + state uint16 + activeOpen byte + flag01 byte + outBuffered uint32 + inBuffered uint32 + maxSndWnd uint32 + reXmtCount uint32 + congestionWnd uint32 + ssThresh uint32 + roundTripTime uint32 + roundTripVar uint32 + sendMSS uint32 + sndWnd uint32 + rcvBufSize uint32 + sndBufSize uint32 + outOfOrderCount uint32 + lcl0WindowCount uint32 + rmt0WindowCount uint32 + dupacks uint32 + flag02 byte + sockOpt6Cont byte + asid uint16 + resourceName [8]byte + resourceId uint32 + subtask uint32 + sockOpt byte + sockOpt6 byte + clusterConnFlag byte + proto byte + targetAppl [8]byte + luName [8]byte + clientUserId [8]byte + logMode [8]byte + timeStamp uint32 + timeStampAge uint32 + serverResourceId uint32 + intfName [16]byte + ttlsStatPol byte + ttlsStatConn byte + ttlsSSLProt uint16 + ttlsNegCiph [2]byte + ttlsSecType byte + ttlsFIPS140Mode byte + ttlsUserID [8]byte + applData [40]byte + inOldestTime [8]byte // uint64 + outOldestTime [8]byte // uint64 + tcpTrustedPartner byte + _ [3]byte + bulkDataIntfName [16]byte + ttlsNegCiph4 [4]byte + smcReason uint32 + lclSMCLinkId uint32 + rmtSMCLinkId uint32 + smcStatus byte + smcFlags byte + _ [2]byte + rcvWnd uint32 + lclSMCBufSz uint32 + rmtSMCBufSz uint32 + ttlsSessID [32]byte + ttlsSessIDLen int16 + _ [1]byte + smcDStatus byte + smcDReason uint32 +} + +var svcNameTable [][]byte = [][]byte{ + []byte("\xc5\xe9\xc2\xd5\xd4\xc9\xc6\xf4"), // svc_EZBNMIF4 +} + +const ( + svc_EZBNMIF4 = 0 +) + +func GetsockoptTCPInfo(fd, level, opt int) (*TCPInfo, error) { + jobname := []byte("\x5c\x40\x40\x40\x40\x40\x40\x40") // "*" + responseBuffer := [4096]byte{0} + var bufferAlet, reasonCode uint32 = 0, 0 + var bufferLen, returnValue, returnCode int32 = 4096, 0, 0 + + dsa := [18]uint64{0} + var argv [7]unsafe.Pointer + argv[0] = unsafe.Pointer(&jobname[0]) + argv[1] = unsafe.Pointer(&responseBuffer[0]) + argv[2] = unsafe.Pointer(&bufferAlet) + argv[3] = unsafe.Pointer(&bufferLen) + argv[4] = unsafe.Pointer(&returnValue) + argv[5] = unsafe.Pointer(&returnCode) + argv[6] = unsafe.Pointer(&reasonCode) + + request := (*struct { + header nwmHeader + filter nwmFilter + })(unsafe.Pointer(&responseBuffer[0])) + + EZBNMIF4 := svcLoad(&svcNameTable[svc_EZBNMIF4][0]) + if EZBNMIF4 == nil { + return nil, errnoErr(EINVAL) + } + + // GetGlobalStats EZBNMIF4 call + request.header.ident = nwmHeaderIdentifier + request.header.length = uint32(unsafe.Sizeof(request.header)) + request.header.version = nwmCurrentVer + request.header.nwmType = nwmGlobalStatsType + request.header.options = 0x80000000 + + svcCall(EZBNMIF4, &argv[0], &dsa[0]) + + // outputDesc field is filled by EZBNMIF4 on success + if returnCode != 0 || request.header.outputDesc.offset == 0 { + return nil, errnoErr(EINVAL) + } + + // Check that EZBNMIF4 returned a nwmRecHeader + recHeader := (*nwmRecHeader)(unsafe.Pointer(&responseBuffer[request.header.outputDesc.offset])) + if recHeader.ident != nwmRecHeaderIdentifier { + return nil, errnoErr(EINVAL) + } + + // Parse nwmTriplets to get offsets of returned entries + var sections []*uint64 + var sectionDesc *nwmTriplet = (*nwmTriplet)(unsafe.Pointer(&responseBuffer[0])) + for i := uint32(0); i < uint32(recHeader.number); i++ { + offset := request.header.outputDesc.offset + uint32(unsafe.Sizeof(*recHeader)) + i*uint32(unsafe.Sizeof(*sectionDesc)) + sectionDesc = (*nwmTriplet)(unsafe.Pointer(&responseBuffer[offset])) + for j := uint32(0); j < sectionDesc.number; j++ { + offset = request.header.outputDesc.offset + sectionDesc.offset + j*sectionDesc.length + sections = append(sections, (*uint64)(unsafe.Pointer(&responseBuffer[offset]))) + } + } + + // Find nwmTCPStatsEntry in returned entries + var tcpStats *nwmTCPStatsEntry = nil + for _, ptr := range sections { + switch *ptr { + case nwmTCPStatsIdentifier: + if tcpStats != nil { + return nil, errnoErr(EINVAL) + } + tcpStats = (*nwmTCPStatsEntry)(unsafe.Pointer(ptr)) + case nwmIPStatsIdentifier: + case nwmIPGStatsIdentifier: + case nwmUDPStatsIdentifier: + case nwmICMPGStatsEntry: + case nwmICMPTStatsEntry: + default: + return nil, errnoErr(EINVAL) + } + } + if tcpStats == nil { + return nil, errnoErr(EINVAL) + } + + // GetConnectionDetail EZBNMIF4 call + responseBuffer = [4096]byte{0} + dsa = [18]uint64{0} + bufferAlet, reasonCode = 0, 0 + bufferLen, returnValue, returnCode = 4096, 0, 0 + nameptr := (*uint32)(unsafe.Pointer(uintptr(0x21c))) // Get jobname of current process + nameptr = (*uint32)(unsafe.Pointer(uintptr(*nameptr + 12))) + argv[0] = unsafe.Pointer(uintptr(*nameptr)) + + request.header.ident = nwmHeaderIdentifier + request.header.length = uint32(unsafe.Sizeof(request.header)) + request.header.version = nwmCurrentVer + request.header.nwmType = nwmTCPConnType + request.header.options = 0x80000000 + + request.filter.ident = nwmFilterIdentifier + + var localSockaddr RawSockaddrAny + socklen := _Socklen(SizeofSockaddrAny) + err := getsockname(fd, &localSockaddr, &socklen) + if err != nil { + return nil, errnoErr(EINVAL) + } + if localSockaddr.Addr.Family == AF_INET { + localSockaddr := (*RawSockaddrInet4)(unsafe.Pointer(&localSockaddr.Addr)) + localSockFilter := (*RawSockaddrInet4)(unsafe.Pointer(&request.filter.local[0])) + localSockFilter.Family = AF_INET + var i int + for i = 0; i < 4; i++ { + if localSockaddr.Addr[i] != 0 { + break + } + } + if i != 4 { + request.filter.flags |= nwmFilterLclAddrMask + for i = 0; i < 4; i++ { + localSockFilter.Addr[i] = localSockaddr.Addr[i] + } + } + if localSockaddr.Port != 0 { + request.filter.flags |= nwmFilterLclPortMask + localSockFilter.Port = localSockaddr.Port + } + } else if localSockaddr.Addr.Family == AF_INET6 { + localSockaddr := (*RawSockaddrInet6)(unsafe.Pointer(&localSockaddr.Addr)) + localSockFilter := (*RawSockaddrInet6)(unsafe.Pointer(&request.filter.local[0])) + localSockFilter.Family = AF_INET6 + var i int + for i = 0; i < 16; i++ { + if localSockaddr.Addr[i] != 0 { + break + } + } + if i != 16 { + request.filter.flags |= nwmFilterLclAddrMask + for i = 0; i < 16; i++ { + localSockFilter.Addr[i] = localSockaddr.Addr[i] + } + } + if localSockaddr.Port != 0 { + request.filter.flags |= nwmFilterLclPortMask + localSockFilter.Port = localSockaddr.Port + } + } + + svcCall(EZBNMIF4, &argv[0], &dsa[0]) + + // outputDesc field is filled by EZBNMIF4 on success + if returnCode != 0 || request.header.outputDesc.offset == 0 { + return nil, errnoErr(EINVAL) + } + + // Check that EZBNMIF4 returned a nwmConnEntry + conn := (*nwmConnEntry)(unsafe.Pointer(&responseBuffer[request.header.outputDesc.offset])) + if conn.ident != nwmTCPConnIdentifier { + return nil, errnoErr(EINVAL) + } + + // Copy data from the returned data structures into tcpInfo + // Stats from nwmConnEntry are specific to that connection. + // Stats from nwmTCPStatsEntry are global (to the interface?) + // Fields may not be an exact match. Some fields have no equivalent. + var tcpinfo TCPInfo + tcpinfo.State = uint8(conn.state) + tcpinfo.Ca_state = 0 // dummy + tcpinfo.Retransmits = uint8(tcpStats.retransSegs) + tcpinfo.Probes = uint8(tcpStats.outWinProbes) + tcpinfo.Backoff = 0 // dummy + tcpinfo.Options = 0 // dummy + tcpinfo.Rto = tcpStats.retransTimeouts + tcpinfo.Ato = tcpStats.outDelayAcks + tcpinfo.Snd_mss = conn.sendMSS + tcpinfo.Rcv_mss = conn.sendMSS // dummy + tcpinfo.Unacked = 0 // dummy + tcpinfo.Sacked = 0 // dummy + tcpinfo.Lost = 0 // dummy + tcpinfo.Retrans = conn.reXmtCount + tcpinfo.Fackets = 0 // dummy + tcpinfo.Last_data_sent = uint32(*(*uint64)(unsafe.Pointer(&conn.lastActivity[0]))) + tcpinfo.Last_ack_sent = uint32(*(*uint64)(unsafe.Pointer(&conn.outOldestTime[0]))) + tcpinfo.Last_data_recv = uint32(*(*uint64)(unsafe.Pointer(&conn.inOldestTime[0]))) + tcpinfo.Last_ack_recv = uint32(*(*uint64)(unsafe.Pointer(&conn.inOldestTime[0]))) + tcpinfo.Pmtu = conn.sendMSS // dummy, NWMIfRouteMtu is a candidate + tcpinfo.Rcv_ssthresh = conn.ssThresh + tcpinfo.Rtt = conn.roundTripTime + tcpinfo.Rttvar = conn.roundTripVar + tcpinfo.Snd_ssthresh = conn.ssThresh // dummy + tcpinfo.Snd_cwnd = conn.congestionWnd + tcpinfo.Advmss = conn.sendMSS // dummy + tcpinfo.Reordering = 0 // dummy + tcpinfo.Rcv_rtt = conn.roundTripTime // dummy + tcpinfo.Rcv_space = conn.sendMSS // dummy + tcpinfo.Total_retrans = conn.reXmtCount + + svcUnload(&svcNameTable[svc_EZBNMIF4][0], EZBNMIF4) + + return &tcpinfo, nil +} + +// GetsockoptString returns the string value of the socket option opt for the +// socket associated with fd at the given socket level. +func GetsockoptString(fd, level, opt int) (string, error) { + buf := make([]byte, 256) + vallen := _Socklen(len(buf)) + err := getsockopt(fd, level, opt, unsafe.Pointer(&buf[0]), &vallen) + if err != nil { + return "", err + } + + return string(buf[:vallen-1]), nil +} + +func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { + var msg Msghdr + var rsa RawSockaddrAny + msg.Name = (*byte)(unsafe.Pointer(&rsa)) + msg.Namelen = SizeofSockaddrAny + var iov Iovec + if len(p) > 0 { + iov.Base = (*byte)(unsafe.Pointer(&p[0])) + iov.SetLen(len(p)) + } + var dummy byte + if len(oob) > 0 { + // receive at least one normal byte + if len(p) == 0 { + iov.Base = &dummy + iov.SetLen(1) + } + msg.Control = (*byte)(unsafe.Pointer(&oob[0])) + msg.SetControllen(len(oob)) + } + msg.Iov = &iov + msg.Iovlen = 1 + if n, err = recvmsg(fd, &msg, flags); err != nil { + return + } + oobn = int(msg.Controllen) + recvflags = int(msg.Flags) + // source address is only specified if the socket is unconnected + if rsa.Addr.Family != AF_UNSPEC { + // TODO(neeilan): Remove 0 arg added to get this compiling on z/OS + from, err = anyToSockaddr(0, &rsa) + } + return +} + +func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { + _, err = SendmsgN(fd, p, oob, to, flags) + return +} + +func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { + var ptr unsafe.Pointer + var salen _Socklen + if to != nil { + var err error + ptr, salen, err = to.sockaddr() + if err != nil { + return 0, err + } + } + var msg Msghdr + msg.Name = (*byte)(unsafe.Pointer(ptr)) + msg.Namelen = int32(salen) + var iov Iovec + if len(p) > 0 { + iov.Base = (*byte)(unsafe.Pointer(&p[0])) + iov.SetLen(len(p)) + } + var dummy byte + if len(oob) > 0 { + // send at least one normal byte + if len(p) == 0 { + iov.Base = &dummy + iov.SetLen(1) + } + msg.Control = (*byte)(unsafe.Pointer(&oob[0])) + msg.SetControllen(len(oob)) + } + msg.Iov = &iov + msg.Iovlen = 1 + if n, err = sendmsg(fd, &msg, flags); err != nil { + return 0, err + } + if len(oob) > 0 && len(p) == 0 { + n = 0 + } + return n, nil +} + +func Opendir(name string) (uintptr, error) { + p, err := BytePtrFromString(name) + if err != nil { + return 0, err + } + dir, _, e := syscall_syscall(SYS___OPENDIR_A, uintptr(unsafe.Pointer(p)), 0, 0) + runtime.KeepAlive(unsafe.Pointer(p)) + if e != 0 { + err = errnoErr(e) + } + return dir, err +} + +// clearsyscall.Errno resets the errno value to 0. +func clearErrno() + +func Readdir(dir uintptr) (*Dirent, error) { + var ent Dirent + var res uintptr + // __readdir_r_a returns errno at the end of the directory stream, rather than 0. + // Therefore to avoid false positives we clear errno before calling it. + + // TODO(neeilan): Commented this out to get sys/unix compiling on z/OS. Uncomment and fix. Error: "undefined: clearsyscall" + //clearsyscall.Errno() // TODO(mundaym): check pre-emption rules. + + e, _, _ := syscall_syscall(SYS___READDIR_R_A, dir, uintptr(unsafe.Pointer(&ent)), uintptr(unsafe.Pointer(&res))) + var err error + if e != 0 { + err = errnoErr(Errno(e)) + } + if res == 0 { + return nil, err + } + return &ent, err +} + +func Closedir(dir uintptr) error { + _, _, e := syscall_syscall(SYS_CLOSEDIR, dir, 0, 0) + if e != 0 { + return errnoErr(e) + } + return nil +} + +func Seekdir(dir uintptr, pos int) { + _, _, _ = syscall_syscall(SYS_SEEKDIR, dir, uintptr(pos), 0) +} + +func Telldir(dir uintptr) (int, error) { + p, _, e := syscall_syscall(SYS_TELLDIR, dir, 0, 0) + pos := int(p) + if pos == -1 { + return pos, errnoErr(e) + } + return pos, nil +} + +// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. +func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { + // struct flock is packed on z/OS. We can't emulate that in Go so + // instead we pack it here. + var flock [24]byte + *(*int16)(unsafe.Pointer(&flock[0])) = lk.Type + *(*int16)(unsafe.Pointer(&flock[2])) = lk.Whence + *(*int64)(unsafe.Pointer(&flock[4])) = lk.Start + *(*int64)(unsafe.Pointer(&flock[12])) = lk.Len + *(*int32)(unsafe.Pointer(&flock[20])) = lk.Pid + _, _, errno := syscall_syscall(SYS_FCNTL, fd, uintptr(cmd), uintptr(unsafe.Pointer(&flock))) + lk.Type = *(*int16)(unsafe.Pointer(&flock[0])) + lk.Whence = *(*int16)(unsafe.Pointer(&flock[2])) + lk.Start = *(*int64)(unsafe.Pointer(&flock[4])) + lk.Len = *(*int64)(unsafe.Pointer(&flock[12])) + lk.Pid = *(*int32)(unsafe.Pointer(&flock[20])) + if errno == 0 { + return nil + } + return errno +} + +func Flock(fd int, how int) error { + + var flock_type int16 + var fcntl_cmd int + + switch how { + case LOCK_SH | LOCK_NB: + flock_type = F_RDLCK + fcntl_cmd = F_SETLK + case LOCK_EX | LOCK_NB: + flock_type = F_WRLCK + fcntl_cmd = F_SETLK + case LOCK_EX: + flock_type = F_WRLCK + fcntl_cmd = F_SETLKW + case LOCK_UN: + flock_type = F_UNLCK + fcntl_cmd = F_SETLKW + default: + } + + flock := Flock_t{ + Type: int16(flock_type), + Whence: int16(0), + Start: int64(0), + Len: int64(0), + Pid: int32(Getppid()), + } + + err := FcntlFlock(uintptr(fd), fcntl_cmd, &flock) + return err +} + +func Mlock(b []byte) (err error) { + _, _, e1 := syscall_syscall(SYS___MLOCKALL, _BPX_NONSWAP, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +func Mlock2(b []byte, flags int) (err error) { + _, _, e1 := syscall_syscall(SYS___MLOCKALL, _BPX_NONSWAP, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +func Mlockall(flags int) (err error) { + _, _, e1 := syscall_syscall(SYS___MLOCKALL, _BPX_NONSWAP, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +func Munlock(b []byte) (err error) { + _, _, e1 := syscall_syscall(SYS___MLOCKALL, _BPX_SWAP, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +func Munlockall() (err error) { + _, _, e1 := syscall_syscall(SYS___MLOCKALL, _BPX_SWAP, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +func ClockGettime(clockid int32, ts *Timespec) error { + + var ticks_per_sec uint32 = 100 //TODO(kenan): value is currently hardcoded; need sysconf() call otherwise + var nsec_per_sec int64 = 1000000000 + + if ts == nil { + return EFAULT + } + if clockid == CLOCK_REALTIME || clockid == CLOCK_MONOTONIC { + var nanotime int64 = runtime.Nanotime1() + ts.Sec = nanotime / nsec_per_sec + ts.Nsec = nanotime % nsec_per_sec + } else if clockid == CLOCK_PROCESS_CPUTIME_ID || clockid == CLOCK_THREAD_CPUTIME_ID { + var tm Tms + _, err := Times(&tm) + if err != nil { + return EFAULT + } + ts.Sec = int64(tm.Utime / ticks_per_sec) + ts.Nsec = int64(tm.Utime) * nsec_per_sec / int64(ticks_per_sec) + } else { + return EINVAL + } + return nil +} + +func Statfs(path string, stat *Statfs_t) (err error) { + fd, err := open(path, O_RDONLY, 0) + defer Close(fd) + if err != nil { + return err + } + return Fstatfs(fd, stat) +} + +var ( + Stdin = 0 + Stdout = 1 + Stderr = 2 +) + +// Do the interface allocations only once for common +// Errno values. +var ( + errEAGAIN error = syscall.EAGAIN + errEINVAL error = syscall.EINVAL + errENOENT error = syscall.ENOENT +) + +var ( + signalNameMapOnce sync.Once + signalNameMap map[string]syscall.Signal +) + +// errnoErr returns common boxed Errno values, to prevent +// allocations at runtime. +func errnoErr(e Errno) error { + switch e { + case 0: + return nil + case EAGAIN: + return errEAGAIN + case EINVAL: + return errEINVAL + case ENOENT: + return errENOENT + } + return e +} + +// ErrnoName returns the error name for error number e. +func ErrnoName(e Errno) string { + i := sort.Search(len(errorList), func(i int) bool { + return errorList[i].num >= e + }) + if i < len(errorList) && errorList[i].num == e { + return errorList[i].name + } + return "" +} + +// SignalName returns the signal name for signal number s. +func SignalName(s syscall.Signal) string { + i := sort.Search(len(signalList), func(i int) bool { + return signalList[i].num >= s + }) + if i < len(signalList) && signalList[i].num == s { + return signalList[i].name + } + return "" +} + +// SignalNum returns the syscall.Signal for signal named s, +// or 0 if a signal with such name is not found. +// The signal name should start with "SIG". +func SignalNum(s string) syscall.Signal { + signalNameMapOnce.Do(func() { + signalNameMap = make(map[string]syscall.Signal, len(signalList)) + for _, signal := range signalList { + signalNameMap[signal.name] = signal.num + } + }) + return signalNameMap[s] +} + +// clen returns the index of the first NULL byte in n or len(n) if n contains no NULL byte. +func clen(n []byte) int { + i := bytes.IndexByte(n, 0) + if i == -1 { + i = len(n) + } + return i +} + +// Mmap manager, for use by operating system-specific implementations. + +type mmapper struct { + sync.Mutex + active map[*byte][]byte // active mappings; key is last byte in mapping + mmap func(addr, length uintptr, prot, flags, fd int, offset int64) (uintptr, error) + munmap func(addr uintptr, length uintptr) error +} + +func (m *mmapper) Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { + if length <= 0 { + return nil, EINVAL + } + + // Map the requested memory. + addr, errno := m.mmap(0, uintptr(length), prot, flags, fd, offset) + if errno != nil { + return nil, errno + } + + // Slice memory layout + var sl = struct { + addr uintptr + len int + cap int + }{addr, length, length} + + // Use unsafe to turn sl into a []byte. + b := *(*[]byte)(unsafe.Pointer(&sl)) + + // Register mapping in m and return it. + p := &b[cap(b)-1] + m.Lock() + defer m.Unlock() + m.active[p] = b + return b, nil +} + +func (m *mmapper) Munmap(data []byte) (err error) { + if len(data) == 0 || len(data) != cap(data) { + return EINVAL + } + + // Find the base of the mapping. + p := &data[cap(data)-1] + m.Lock() + defer m.Unlock() + b := m.active[p] + if b == nil || &b[0] != &data[0] { + return EINVAL + } + + // Unmap the memory and update m. + if errno := m.munmap(uintptr(unsafe.Pointer(&b[0])), uintptr(len(b))); errno != nil { + return errno + } + delete(m.active, p) + return nil +} + +func Read(fd int, p []byte) (n int, err error) { + n, err = read(fd, p) + if raceenabled { + if n > 0 { + raceWriteRange(unsafe.Pointer(&p[0]), n) + } + if err == nil { + raceAcquire(unsafe.Pointer(&ioSync)) + } + } + return +} + +func Write(fd int, p []byte) (n int, err error) { + if raceenabled { + raceReleaseMerge(unsafe.Pointer(&ioSync)) + } + n, err = write(fd, p) + if raceenabled && n > 0 { + raceReadRange(unsafe.Pointer(&p[0]), n) + } + return +} + +// For testing: clients can set this flag to force +// creation of IPv6 sockets to return EAFNOSUPPORT. +var SocketDisableIPv6 bool + +// Sockaddr represents a socket address. +type Sockaddr interface { + sockaddr() (ptr unsafe.Pointer, len _Socklen, err error) // lowercase; only we can define Sockaddrs +} + +// SockaddrInet4 implements the Sockaddr interface for AF_INET type sockets. +type SockaddrInet4 struct { + Port int + Addr [4]byte + raw RawSockaddrInet4 +} + +// SockaddrInet6 implements the Sockaddr interface for AF_INET6 type sockets. +type SockaddrInet6 struct { + Port int + ZoneId uint32 + Addr [16]byte + raw RawSockaddrInet6 +} + +// SockaddrUnix implements the Sockaddr interface for AF_UNIX type sockets. +type SockaddrUnix struct { + Name string + raw RawSockaddrUnix +} + +func Bind(fd int, sa Sockaddr) (err error) { + ptr, n, err := sa.sockaddr() + if err != nil { + return err + } + return bind(fd, ptr, n) +} + +func Connect(fd int, sa Sockaddr) (err error) { + ptr, n, err := sa.sockaddr() + if err != nil { + return err + } + return connect(fd, ptr, n) +} + +func Getpeername(fd int) (sa Sockaddr, err error) { + var rsa RawSockaddrAny + var len _Socklen = SizeofSockaddrAny + if err = getpeername(fd, &rsa, &len); err != nil { + return + } + return anyToSockaddr(fd, &rsa) +} + +func GetsockoptByte(fd, level, opt int) (value byte, err error) { + var n byte + vallen := _Socklen(1) + err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen) + return n, err +} + +func GetsockoptInt(fd, level, opt int) (value int, err error) { + var n int32 + vallen := _Socklen(4) + err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen) + return int(n), err +} + +func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) { + vallen := _Socklen(4) + err = getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen) + return value, err +} + +func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) { + var value IPMreq + vallen := _Socklen(SizeofIPMreq) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} + +func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) { + var value IPv6Mreq + vallen := _Socklen(SizeofIPv6Mreq) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} + +func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) { + var value IPv6MTUInfo + vallen := _Socklen(SizeofIPv6MTUInfo) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} + +func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) { + var value ICMPv6Filter + vallen := _Socklen(SizeofICMPv6Filter) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} + +func GetsockoptLinger(fd, level, opt int) (*Linger, error) { + var linger Linger + vallen := _Socklen(SizeofLinger) + err := getsockopt(fd, level, opt, unsafe.Pointer(&linger), &vallen) + return &linger, err +} + +func GetsockoptTimeval(fd, level, opt int) (*Timeval, error) { + var tv Timeval + vallen := _Socklen(unsafe.Sizeof(tv)) + err := getsockopt(fd, level, opt, unsafe.Pointer(&tv), &vallen) + return &tv, err +} + +func GetsockoptUint64(fd, level, opt int) (value uint64, err error) { + var n uint64 + vallen := _Socklen(8) + err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen) + return n, err +} + +func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) { + var rsa RawSockaddrAny + var len _Socklen = SizeofSockaddrAny + if n, err = recvfrom(fd, p, flags, &rsa, &len); err != nil { + return + } + if rsa.Addr.Family != AF_UNSPEC { + from, err = anyToSockaddr(fd, &rsa) + } + return +} + +func Sendto(fd int, p []byte, flags int, to Sockaddr) (err error) { + ptr, n, err := to.sockaddr() + if err != nil { + return err + } + return sendto(fd, p, flags, ptr, n) +} + +func SetsockoptByte(fd, level, opt int, value byte) (err error) { + return setsockopt(fd, level, opt, unsafe.Pointer(&value), 1) +} + +func SetsockoptInt(fd, level, opt int, value int) (err error) { + var n = int32(value) + return setsockopt(fd, level, opt, unsafe.Pointer(&n), 4) +} + +func SetsockoptInet4Addr(fd, level, opt int, value [4]byte) (err error) { + return setsockopt(fd, level, opt, unsafe.Pointer(&value[0]), 4) +} + +func SetsockoptIPMreq(fd, level, opt int, mreq *IPMreq) (err error) { + return setsockopt(fd, level, opt, unsafe.Pointer(mreq), SizeofIPMreq) +} + +func SetsockoptIPv6Mreq(fd, level, opt int, mreq *IPv6Mreq) (err error) { + return setsockopt(fd, level, opt, unsafe.Pointer(mreq), SizeofIPv6Mreq) +} + +func SetsockoptICMPv6Filter(fd, level, opt int, filter *ICMPv6Filter) error { + return setsockopt(fd, level, opt, unsafe.Pointer(filter), SizeofICMPv6Filter) +} + +func SetsockoptLinger(fd, level, opt int, l *Linger) (err error) { + return setsockopt(fd, level, opt, unsafe.Pointer(l), SizeofLinger) +} + +func SetsockoptString(fd, level, opt int, s string) (err error) { + var p unsafe.Pointer + if len(s) > 0 { + p = unsafe.Pointer(&[]byte(s)[0]) + } + return setsockopt(fd, level, opt, p, uintptr(len(s))) +} + +func SetsockoptTimeval(fd, level, opt int, tv *Timeval) (err error) { + return setsockopt(fd, level, opt, unsafe.Pointer(tv), unsafe.Sizeof(*tv)) +} + +func SetsockoptUint64(fd, level, opt int, value uint64) (err error) { + return setsockopt(fd, level, opt, unsafe.Pointer(&value), 8) +} + +func Socket(domain, typ, proto int) (fd int, err error) { + if domain == AF_INET6 && SocketDisableIPv6 { + return -1, EAFNOSUPPORT + } + fd, err = socket(domain, typ, proto) + return +} + +func Socketpair(domain, typ, proto int) (fd [2]int, err error) { + var fdx [2]int32 + err = socketpair(domain, typ, proto, &fdx) + if err == nil { + fd[0] = int(fdx[0]) + fd[1] = int(fdx[1]) + } + return +} + +var ioSync int64 + +func CloseOnExec(fd int) { fcntl(fd, F_SETFD, FD_CLOEXEC) } + +func SetNonblock(fd int, nonblocking bool) (err error) { + flag, err := fcntl(fd, F_GETFL, 0) + if err != nil { + return err + } + if nonblocking { + flag |= O_NONBLOCK + } else { + flag &= ^O_NONBLOCK + } + _, err = fcntl(fd, F_SETFL, flag) + return err +} + +// Exec calls execve(2), which replaces the calling executable in the process +// tree. argv0 should be the full path to an executable ("/bin/ls") and the +// executable name should also be the first argument in argv (["ls", "-l"]). +// envv are the environment variables that should be passed to the new +// process (["USER=go", "PWD=/tmp"]). +func Exec(argv0 string, argv []string, envv []string) error { + return syscall.Exec(argv0, argv, envv) +} diff --git a/vendor/golang.org/x/sys/unix/timestruct.go b/vendor/golang.org/x/sys/unix/timestruct.go index 4a672f56942..3d893040553 100644 --- a/vendor/golang.org/x/sys/unix/timestruct.go +++ b/vendor/golang.org/x/sys/unix/timestruct.go @@ -2,18 +2,17 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos package unix import "time" -// TimespecToNsec converts a Timespec value into a number of -// nanoseconds since the Unix epoch. -func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } +// TimespecToNSec returns the time stored in ts as nanoseconds. +func TimespecToNsec(ts Timespec) int64 { return ts.Nano() } -// NsecToTimespec takes a number of nanoseconds since the Unix epoch -// and returns the corresponding Timespec value. +// NsecToTimespec converts a number of nanoseconds into a Timespec. func NsecToTimespec(nsec int64) Timespec { sec := nsec / 1e9 nsec = nsec % 1e9 @@ -42,12 +41,10 @@ func TimeToTimespec(t time.Time) (Timespec, error) { return ts, nil } -// TimevalToNsec converts a Timeval value into a number of nanoseconds -// since the Unix epoch. -func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } +// TimevalToNsec returns the time stored in tv as nanoseconds. +func TimevalToNsec(tv Timeval) int64 { return tv.Nano() } -// NsecToTimeval takes a number of nanoseconds since the Unix epoch -// and returns the corresponding Timeval value. +// NsecToTimeval converts a number of nanoseconds into a Timeval. func NsecToTimeval(nsec int64) Timeval { nsec += 999 // round up to microsecond usec := nsec % 1e9 / 1e3 @@ -59,24 +56,22 @@ func NsecToTimeval(nsec int64) Timeval { return setTimeval(sec, usec) } -// Unix returns ts as the number of seconds and nanoseconds elapsed since the -// Unix epoch. +// Unix returns the time stored in ts as seconds plus nanoseconds. func (ts *Timespec) Unix() (sec int64, nsec int64) { return int64(ts.Sec), int64(ts.Nsec) } -// Unix returns tv as the number of seconds and nanoseconds elapsed since the -// Unix epoch. +// Unix returns the time stored in tv as seconds plus nanoseconds. func (tv *Timeval) Unix() (sec int64, nsec int64) { return int64(tv.Sec), int64(tv.Usec) * 1000 } -// Nano returns ts as the number of nanoseconds elapsed since the Unix epoch. +// Nano returns the time stored in ts as nanoseconds. func (ts *Timespec) Nano() int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } -// Nano returns tv as the number of nanoseconds elapsed since the Unix epoch. +// Nano returns the time stored in tv as nanoseconds. func (tv *Timeval) Nano() int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 } diff --git a/vendor/golang.org/x/sys/unix/xattr_bsd.go b/vendor/golang.org/x/sys/unix/xattr_bsd.go index 30c1d71f4ed..25df1e37801 100644 --- a/vendor/golang.org/x/sys/unix/xattr_bsd.go +++ b/vendor/golang.org/x/sys/unix/xattr_bsd.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build freebsd || netbsd // +build freebsd netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zerrors_aix_ppc.go b/vendor/golang.org/x/sys/unix/zerrors_aix_ppc.go index 104994bc6a9..ca9799b79ef 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/zerrors_aix_ppc.go @@ -1,6 +1,7 @@ // mkerrors.sh -maix32 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build ppc && aix // +build ppc,aix // Created by cgo -godefs - DO NOT EDIT diff --git a/vendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go index 4fc8d306493..200c8c26fe6 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go @@ -1,6 +1,7 @@ // mkerrors.sh -maix64 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build ppc64 && aix // +build ppc64,aix // Code generated by cmd/cgo -godefs; DO NOT EDIT. diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go index ec376f51bc4..7ee196f7fcc 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go @@ -1,6 +1,7 @@ // mkerrors.sh -m32 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build 386 && darwin // +build 386,darwin // Code generated by cmd/cgo -godefs; DO NOT EDIT. diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go index fea5dfaadb9..991996b6091 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -1,6 +1,7 @@ // mkerrors.sh -m64 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && darwin // +build amd64,darwin // Code generated by cmd/cgo -godefs; DO NOT EDIT. @@ -32,7 +33,7 @@ const ( AF_LAT = 0xe AF_LINK = 0x12 AF_LOCAL = 0x1 - AF_MAX = 0x28 + AF_MAX = 0x29 AF_NATM = 0x1f AF_NDRV = 0x1b AF_NETBIOS = 0x21 @@ -49,6 +50,7 @@ const ( AF_UNIX = 0x1 AF_UNSPEC = 0x0 AF_UTUN = 0x26 + AF_VSOCK = 0x28 ALTWERASE = 0x200 ATTR_BIT_MAP_COUNT = 0x5 ATTR_CMN_ACCESSMASK = 0x20000 @@ -83,7 +85,7 @@ const ( ATTR_CMN_PAROBJID = 0x80 ATTR_CMN_RETURNED_ATTRS = 0x80000000 ATTR_CMN_SCRIPT = 0x100 - ATTR_CMN_SETMASK = 0x41c7ff00 + ATTR_CMN_SETMASK = 0x51c7ff00 ATTR_CMN_USERACCESS = 0x200000 ATTR_CMN_UUID = 0x800000 ATTR_CMN_VALIDMASK = 0xffffffff @@ -357,7 +359,7 @@ const ( DLT_LINUX_SLL = 0x71 DLT_LOOP = 0x6c DLT_LTALK = 0x72 - DLT_MATCHING_MAX = 0xf5 + DLT_MATCHING_MAX = 0x10a DLT_MATCHING_MIN = 0x68 DLT_MFR = 0xb6 DLT_MOST = 0xd3 @@ -398,6 +400,7 @@ const ( DLT_SYMANTEC_FIREWALL = 0x63 DLT_TZSP = 0x80 DLT_USB = 0xba + DLT_USB_DARWIN = 0x10a DLT_USB_LINUX = 0xbd DLT_USB_LINUX_MMAPPED = 0xdc DLT_USER0 = 0x93 @@ -442,8 +445,8 @@ const ( EVFILT_PROC = -0x5 EVFILT_READ = -0x1 EVFILT_SIGNAL = -0x6 - EVFILT_SYSCOUNT = 0xf - EVFILT_THREADMARKER = 0xf + EVFILT_SYSCOUNT = 0x11 + EVFILT_THREADMARKER = 0x11 EVFILT_TIMER = -0x7 EVFILT_USER = -0xa EVFILT_VM = -0xc @@ -481,9 +484,12 @@ const ( FSOPT_NOINMEMUPDATE = 0x2 FSOPT_PACK_INVAL_ATTRS = 0x8 FSOPT_REPORT_FULLSIZE = 0x4 + FSOPT_RETURN_REALDEV = 0x200 F_ADDFILESIGS = 0x3d F_ADDFILESIGS_FOR_DYLD_SIM = 0x53 + F_ADDFILESIGS_INFO = 0x67 F_ADDFILESIGS_RETURN = 0x61 + F_ADDFILESUPPL = 0x68 F_ADDSIGS = 0x3b F_ALLOCATEALL = 0x4 F_ALLOCATECONTIG = 0x2 @@ -505,8 +511,10 @@ const ( F_GETOWN = 0x5 F_GETPATH = 0x32 F_GETPATH_MTMINFO = 0x47 + F_GETPATH_NOFIRMLINK = 0x66 F_GETPROTECTIONCLASS = 0x3f F_GETPROTECTIONLEVEL = 0x4d + F_GETSIGSINFO = 0x69 F_GLOBAL_NOCACHE = 0x37 F_LOG2PHYS = 0x31 F_LOG2PHYS_EXT = 0x41 @@ -531,6 +539,7 @@ const ( F_SETPROTECTIONCLASS = 0x40 F_SETSIZE = 0x2b F_SINGLE_WRITER = 0x4c + F_SPECULATIVE_READ = 0x65 F_THAW_FS = 0x36 F_TRANSCODEKEY = 0x4b F_TRIM_ACTIVE_FILE = 0x64 @@ -562,6 +571,7 @@ const ( IFF_UP = 0x1 IFNAMSIZ = 0x10 IFT_1822 = 0x2 + IFT_6LOWPAN = 0x40 IFT_AAL5 = 0x31 IFT_ARCNET = 0x23 IFT_ARCNETPLUS = 0x24 @@ -766,16 +776,28 @@ const ( IPV6_2292PKTINFO = 0x13 IPV6_2292PKTOPTIONS = 0x19 IPV6_2292RTHDR = 0x18 + IPV6_3542DSTOPTS = 0x32 + IPV6_3542HOPLIMIT = 0x2f + IPV6_3542HOPOPTS = 0x31 + IPV6_3542NEXTHOP = 0x30 + IPV6_3542PKTINFO = 0x2e + IPV6_3542RTHDR = 0x33 + IPV6_ADDR_MC_FLAGS_PREFIX = 0x20 + IPV6_ADDR_MC_FLAGS_TRANSIENT = 0x10 + IPV6_ADDR_MC_FLAGS_UNICAST_BASED = 0x30 + IPV6_AUTOFLOWLABEL = 0x3b IPV6_BINDV6ONLY = 0x1b IPV6_BOUND_IF = 0x7d IPV6_CHECKSUM = 0x1a IPV6_DEFAULT_MULTICAST_HOPS = 0x1 IPV6_DEFAULT_MULTICAST_LOOP = 0x1 IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 IPV6_FAITH = 0x1d IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWLABEL_MASK = 0xffff0f00 - IPV6_FLOW_ECN_MASK = 0x300 + IPV6_FLOW_ECN_MASK = 0x3000 IPV6_FRAGTTL = 0x3c IPV6_FW_ADD = 0x1e IPV6_FW_DEL = 0x1f @@ -783,6 +805,8 @@ const ( IPV6_FW_GET = 0x22 IPV6_FW_ZERO = 0x21 IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 IPV6_IPSEC_POLICY = 0x1c IPV6_JOIN_GROUP = 0xc IPV6_LEAVE_GROUP = 0xd @@ -794,20 +818,34 @@ const ( IPV6_MAX_SOCK_SRC_FILTER = 0x80 IPV6_MIN_MEMBERSHIPS = 0x1f IPV6_MMTU = 0x500 + IPV6_MSFILTER = 0x4a IPV6_MULTICAST_HOPS = 0xa IPV6_MULTICAST_IF = 0x9 IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_PATHMTU = 0x2c + IPV6_PKTINFO = 0x2e IPV6_PORTRANGE = 0xe IPV6_PORTRANGE_DEFAULT = 0x0 IPV6_PORTRANGE_HIGH = 0x1 IPV6_PORTRANGE_LOW = 0x2 + IPV6_PREFER_TEMPADDR = 0x3f + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x3d + IPV6_RECVRTHDR = 0x26 IPV6_RECVTCLASS = 0x23 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x39 IPV6_RTHDR_LOOSE = 0x0 IPV6_RTHDR_STRICT = 0x1 IPV6_RTHDR_TYPE_0 = 0x0 IPV6_SOCKOPT_RESERVED1 = 0x3 IPV6_TCLASS = 0x24 IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a IPV6_V6ONLY = 0x1b IPV6_VERSION = 0x60 IPV6_VERSION_MASK = 0xf0 @@ -818,6 +856,7 @@ const ( IP_DEFAULT_MULTICAST_LOOP = 0x1 IP_DEFAULT_MULTICAST_TTL = 0x1 IP_DF = 0x4000 + IP_DONTFRAG = 0x1c IP_DROP_MEMBERSHIP = 0xd IP_DROP_SOURCE_MEMBERSHIP = 0x47 IP_DUMMYNET_CONFIGURE = 0x3c @@ -889,6 +928,12 @@ const ( KERN_OSRELEASE = 0x2 KERN_OSTYPE = 0x1 KERN_VERSION = 0x4 + LOCAL_PEERCRED = 0x1 + LOCAL_PEEREPID = 0x3 + LOCAL_PEEREUUID = 0x5 + LOCAL_PEERPID = 0x2 + LOCAL_PEERTOKEN = 0x6 + LOCAL_PEERUUID = 0x4 LOCK_EX = 0x2 LOCK_NB = 0x4 LOCK_SH = 0x1 @@ -904,6 +949,7 @@ const ( MADV_SEQUENTIAL = 0x2 MADV_WILLNEED = 0x3 MADV_ZERO_WIRED_PAGES = 0x6 + MAP_32BIT = 0x8000 MAP_ANON = 0x1000 MAP_ANONYMOUS = 0x1000 MAP_COPY = 0x2 @@ -920,6 +966,17 @@ const ( MAP_RESILIENT_CODESIGN = 0x2000 MAP_RESILIENT_MEDIA = 0x4000 MAP_SHARED = 0x1 + MAP_TRANSLATED_ALLOW_EXECUTE = 0x20000 + MAP_UNIX03 = 0x40000 + MCAST_BLOCK_SOURCE = 0x54 + MCAST_EXCLUDE = 0x2 + MCAST_INCLUDE = 0x1 + MCAST_JOIN_GROUP = 0x50 + MCAST_JOIN_SOURCE_GROUP = 0x52 + MCAST_LEAVE_GROUP = 0x51 + MCAST_LEAVE_SOURCE_GROUP = 0x53 + MCAST_UNBLOCK_SOURCE = 0x55 + MCAST_UNDEFINED = 0x0 MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 MNT_ASYNC = 0x40 @@ -931,6 +988,7 @@ const ( MNT_DOVOLFS = 0x8000 MNT_DWAIT = 0x4 MNT_EXPORTED = 0x100 + MNT_EXT_ROOT_DATA_VOL = 0x1 MNT_FORCE = 0x80000 MNT_IGNORE_OWNERSHIP = 0x200000 MNT_JOURNALED = 0x800000 @@ -947,12 +1005,15 @@ const ( MNT_QUOTA = 0x2000 MNT_RDONLY = 0x1 MNT_RELOAD = 0x40000 + MNT_REMOVABLE = 0x200 MNT_ROOTFS = 0x4000 + MNT_SNAPSHOT = 0x40000000 + MNT_STRICTATIME = 0x80000000 MNT_SYNCHRONOUS = 0x2 MNT_UNION = 0x20 MNT_UNKNOWNPERMISSIONS = 0x200000 MNT_UPDATE = 0x10000 - MNT_VISFLAGMASK = 0x17f0f5ff + MNT_VISFLAGMASK = 0xd7f0f7ff MNT_WAIT = 0x1 MSG_CTRUNC = 0x20 MSG_DONTROUTE = 0x4 @@ -963,6 +1024,7 @@ const ( MSG_HAVEMORE = 0x2000 MSG_HOLD = 0x800 MSG_NEEDSA = 0x10000 + MSG_NOSIGNAL = 0x80000 MSG_OOB = 0x1 MSG_PEEK = 0x2 MSG_RCVMORE = 0x4000 @@ -979,9 +1041,10 @@ const ( NET_RT_DUMP = 0x1 NET_RT_DUMP2 = 0x7 NET_RT_FLAGS = 0x2 + NET_RT_FLAGS_PRIV = 0xa NET_RT_IFLIST = 0x3 NET_RT_IFLIST2 = 0x6 - NET_RT_MAXID = 0xa + NET_RT_MAXID = 0xb NET_RT_STAT = 0x4 NET_RT_TRASH = 0x5 NFDBITS = 0x20 @@ -1019,6 +1082,7 @@ const ( NOTE_LEEWAY = 0x10 NOTE_LINK = 0x10 NOTE_LOWAT = 0x1 + NOTE_MACHTIME = 0x100 NOTE_MACH_CONTINUOUS_TIME = 0x80 NOTE_NONE = 0x80 NOTE_NSECONDS = 0x4 @@ -1065,6 +1129,7 @@ const ( O_NDELAY = 0x4 O_NOCTTY = 0x20000 O_NOFOLLOW = 0x100 + O_NOFOLLOW_ANY = 0x20000000 O_NONBLOCK = 0x4 O_POPUP = 0x80000000 O_RDONLY = 0x0 @@ -1136,6 +1201,7 @@ const ( RTF_BROADCAST = 0x400000 RTF_CLONING = 0x100 RTF_CONDEMNED = 0x2000000 + RTF_DEAD = 0x20000000 RTF_DELCLONE = 0x80 RTF_DONE = 0x40 RTF_DYNAMIC = 0x10 @@ -1143,6 +1209,7 @@ const ( RTF_HOST = 0x4 RTF_IFREF = 0x4000000 RTF_IFSCOPE = 0x1000000 + RTF_LLDATA = 0x400 RTF_LLINFO = 0x400 RTF_LOCAL = 0x200000 RTF_MODIFIED = 0x20 @@ -1210,6 +1277,7 @@ const ( SIOCGDRVSPEC = 0xc028697b SIOCGETVLAN = 0xc020697f SIOCGHIWAT = 0x40047301 + SIOCGIF6LOWPAN = 0xc02069c5 SIOCGIFADDR = 0xc0206921 SIOCGIFALTMTU = 0xc0206948 SIOCGIFASYNCMAP = 0xc020697c @@ -1220,6 +1288,7 @@ const ( SIOCGIFDEVMTU = 0xc0206944 SIOCGIFDSTADDR = 0xc0206922 SIOCGIFFLAGS = 0xc0206911 + SIOCGIFFUNCTIONALTYPE = 0xc02069ad SIOCGIFGENERIC = 0xc020693a SIOCGIFKPI = 0xc0206987 SIOCGIFMAC = 0xc0206982 @@ -1233,6 +1302,7 @@ const ( SIOCGIFSTATUS = 0xc331693d SIOCGIFVLAN = 0xc020697f SIOCGIFWAKEFLAGS = 0xc0206988 + SIOCGIFXMEDIA = 0xc02c6948 SIOCGLOWAT = 0x40047303 SIOCGPGRP = 0x40047309 SIOCIFCREATE = 0xc0206978 @@ -1243,6 +1313,7 @@ const ( SIOCSDRVSPEC = 0x8028697b SIOCSETVLAN = 0x8020697e SIOCSHIWAT = 0x80047300 + SIOCSIF6LOWPAN = 0x802069c4 SIOCSIFADDR = 0x8020690c SIOCSIFALTMTU = 0x80206945 SIOCSIFASYNCMAP = 0x8020697d @@ -1270,6 +1341,7 @@ const ( SOCK_RDM = 0x4 SOCK_SEQPACKET = 0x5 SOCK_STREAM = 0x1 + SOL_LOCAL = 0x0 SOL_SOCKET = 0xffff SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x2 diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go index 03feefbf8c9..e748cb11057 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go @@ -1,6 +1,7 @@ // mkerrors.sh // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm && darwin // +build arm,darwin // Code generated by cmd/cgo -godefs; DO NOT EDIT. diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go index b40fb1f6967..e644eaf5e75 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -1,6 +1,7 @@ // mkerrors.sh -m64 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm64 && darwin // +build arm64,darwin // Code generated by cmd/cgo -godefs; DO NOT EDIT. @@ -32,7 +33,7 @@ const ( AF_LAT = 0xe AF_LINK = 0x12 AF_LOCAL = 0x1 - AF_MAX = 0x28 + AF_MAX = 0x29 AF_NATM = 0x1f AF_NDRV = 0x1b AF_NETBIOS = 0x21 @@ -49,6 +50,7 @@ const ( AF_UNIX = 0x1 AF_UNSPEC = 0x0 AF_UTUN = 0x26 + AF_VSOCK = 0x28 ALTWERASE = 0x200 ATTR_BIT_MAP_COUNT = 0x5 ATTR_CMN_ACCESSMASK = 0x20000 @@ -83,7 +85,7 @@ const ( ATTR_CMN_PAROBJID = 0x80 ATTR_CMN_RETURNED_ATTRS = 0x80000000 ATTR_CMN_SCRIPT = 0x100 - ATTR_CMN_SETMASK = 0x41c7ff00 + ATTR_CMN_SETMASK = 0x51c7ff00 ATTR_CMN_USERACCESS = 0x200000 ATTR_CMN_UUID = 0x800000 ATTR_CMN_VALIDMASK = 0xffffffff @@ -357,7 +359,7 @@ const ( DLT_LINUX_SLL = 0x71 DLT_LOOP = 0x6c DLT_LTALK = 0x72 - DLT_MATCHING_MAX = 0xf5 + DLT_MATCHING_MAX = 0x10a DLT_MATCHING_MIN = 0x68 DLT_MFR = 0xb6 DLT_MOST = 0xd3 @@ -398,6 +400,7 @@ const ( DLT_SYMANTEC_FIREWALL = 0x63 DLT_TZSP = 0x80 DLT_USB = 0xba + DLT_USB_DARWIN = 0x10a DLT_USB_LINUX = 0xbd DLT_USB_LINUX_MMAPPED = 0xdc DLT_USER0 = 0x93 @@ -442,8 +445,8 @@ const ( EVFILT_PROC = -0x5 EVFILT_READ = -0x1 EVFILT_SIGNAL = -0x6 - EVFILT_SYSCOUNT = 0xf - EVFILT_THREADMARKER = 0xf + EVFILT_SYSCOUNT = 0x11 + EVFILT_THREADMARKER = 0x11 EVFILT_TIMER = -0x7 EVFILT_USER = -0xa EVFILT_VM = -0xc @@ -481,9 +484,12 @@ const ( FSOPT_NOINMEMUPDATE = 0x2 FSOPT_PACK_INVAL_ATTRS = 0x8 FSOPT_REPORT_FULLSIZE = 0x4 + FSOPT_RETURN_REALDEV = 0x200 F_ADDFILESIGS = 0x3d F_ADDFILESIGS_FOR_DYLD_SIM = 0x53 + F_ADDFILESIGS_INFO = 0x67 F_ADDFILESIGS_RETURN = 0x61 + F_ADDFILESUPPL = 0x68 F_ADDSIGS = 0x3b F_ALLOCATEALL = 0x4 F_ALLOCATECONTIG = 0x2 @@ -505,8 +511,10 @@ const ( F_GETOWN = 0x5 F_GETPATH = 0x32 F_GETPATH_MTMINFO = 0x47 + F_GETPATH_NOFIRMLINK = 0x66 F_GETPROTECTIONCLASS = 0x3f F_GETPROTECTIONLEVEL = 0x4d + F_GETSIGSINFO = 0x69 F_GLOBAL_NOCACHE = 0x37 F_LOG2PHYS = 0x31 F_LOG2PHYS_EXT = 0x41 @@ -531,6 +539,7 @@ const ( F_SETPROTECTIONCLASS = 0x40 F_SETSIZE = 0x2b F_SINGLE_WRITER = 0x4c + F_SPECULATIVE_READ = 0x65 F_THAW_FS = 0x36 F_TRANSCODEKEY = 0x4b F_TRIM_ACTIVE_FILE = 0x64 @@ -562,6 +571,7 @@ const ( IFF_UP = 0x1 IFNAMSIZ = 0x10 IFT_1822 = 0x2 + IFT_6LOWPAN = 0x40 IFT_AAL5 = 0x31 IFT_ARCNET = 0x23 IFT_ARCNETPLUS = 0x24 @@ -766,16 +776,28 @@ const ( IPV6_2292PKTINFO = 0x13 IPV6_2292PKTOPTIONS = 0x19 IPV6_2292RTHDR = 0x18 + IPV6_3542DSTOPTS = 0x32 + IPV6_3542HOPLIMIT = 0x2f + IPV6_3542HOPOPTS = 0x31 + IPV6_3542NEXTHOP = 0x30 + IPV6_3542PKTINFO = 0x2e + IPV6_3542RTHDR = 0x33 + IPV6_ADDR_MC_FLAGS_PREFIX = 0x20 + IPV6_ADDR_MC_FLAGS_TRANSIENT = 0x10 + IPV6_ADDR_MC_FLAGS_UNICAST_BASED = 0x30 + IPV6_AUTOFLOWLABEL = 0x3b IPV6_BINDV6ONLY = 0x1b IPV6_BOUND_IF = 0x7d IPV6_CHECKSUM = 0x1a IPV6_DEFAULT_MULTICAST_HOPS = 0x1 IPV6_DEFAULT_MULTICAST_LOOP = 0x1 IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 IPV6_FAITH = 0x1d IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWLABEL_MASK = 0xffff0f00 - IPV6_FLOW_ECN_MASK = 0x300 + IPV6_FLOW_ECN_MASK = 0x3000 IPV6_FRAGTTL = 0x3c IPV6_FW_ADD = 0x1e IPV6_FW_DEL = 0x1f @@ -783,6 +805,8 @@ const ( IPV6_FW_GET = 0x22 IPV6_FW_ZERO = 0x21 IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 IPV6_IPSEC_POLICY = 0x1c IPV6_JOIN_GROUP = 0xc IPV6_LEAVE_GROUP = 0xd @@ -794,20 +818,34 @@ const ( IPV6_MAX_SOCK_SRC_FILTER = 0x80 IPV6_MIN_MEMBERSHIPS = 0x1f IPV6_MMTU = 0x500 + IPV6_MSFILTER = 0x4a IPV6_MULTICAST_HOPS = 0xa IPV6_MULTICAST_IF = 0x9 IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_PATHMTU = 0x2c + IPV6_PKTINFO = 0x2e IPV6_PORTRANGE = 0xe IPV6_PORTRANGE_DEFAULT = 0x0 IPV6_PORTRANGE_HIGH = 0x1 IPV6_PORTRANGE_LOW = 0x2 + IPV6_PREFER_TEMPADDR = 0x3f + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x3d + IPV6_RECVRTHDR = 0x26 IPV6_RECVTCLASS = 0x23 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x39 IPV6_RTHDR_LOOSE = 0x0 IPV6_RTHDR_STRICT = 0x1 IPV6_RTHDR_TYPE_0 = 0x0 IPV6_SOCKOPT_RESERVED1 = 0x3 IPV6_TCLASS = 0x24 IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a IPV6_V6ONLY = 0x1b IPV6_VERSION = 0x60 IPV6_VERSION_MASK = 0xf0 @@ -818,6 +856,7 @@ const ( IP_DEFAULT_MULTICAST_LOOP = 0x1 IP_DEFAULT_MULTICAST_TTL = 0x1 IP_DF = 0x4000 + IP_DONTFRAG = 0x1c IP_DROP_MEMBERSHIP = 0xd IP_DROP_SOURCE_MEMBERSHIP = 0x47 IP_DUMMYNET_CONFIGURE = 0x3c @@ -889,6 +928,12 @@ const ( KERN_OSRELEASE = 0x2 KERN_OSTYPE = 0x1 KERN_VERSION = 0x4 + LOCAL_PEERCRED = 0x1 + LOCAL_PEEREPID = 0x3 + LOCAL_PEEREUUID = 0x5 + LOCAL_PEERPID = 0x2 + LOCAL_PEERTOKEN = 0x6 + LOCAL_PEERUUID = 0x4 LOCK_EX = 0x2 LOCK_NB = 0x4 LOCK_SH = 0x1 @@ -904,6 +949,7 @@ const ( MADV_SEQUENTIAL = 0x2 MADV_WILLNEED = 0x3 MADV_ZERO_WIRED_PAGES = 0x6 + MAP_32BIT = 0x8000 MAP_ANON = 0x1000 MAP_ANONYMOUS = 0x1000 MAP_COPY = 0x2 @@ -920,6 +966,17 @@ const ( MAP_RESILIENT_CODESIGN = 0x2000 MAP_RESILIENT_MEDIA = 0x4000 MAP_SHARED = 0x1 + MAP_TRANSLATED_ALLOW_EXECUTE = 0x20000 + MAP_UNIX03 = 0x40000 + MCAST_BLOCK_SOURCE = 0x54 + MCAST_EXCLUDE = 0x2 + MCAST_INCLUDE = 0x1 + MCAST_JOIN_GROUP = 0x50 + MCAST_JOIN_SOURCE_GROUP = 0x52 + MCAST_LEAVE_GROUP = 0x51 + MCAST_LEAVE_SOURCE_GROUP = 0x53 + MCAST_UNBLOCK_SOURCE = 0x55 + MCAST_UNDEFINED = 0x0 MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 MNT_ASYNC = 0x40 @@ -931,6 +988,7 @@ const ( MNT_DOVOLFS = 0x8000 MNT_DWAIT = 0x4 MNT_EXPORTED = 0x100 + MNT_EXT_ROOT_DATA_VOL = 0x1 MNT_FORCE = 0x80000 MNT_IGNORE_OWNERSHIP = 0x200000 MNT_JOURNALED = 0x800000 @@ -947,12 +1005,15 @@ const ( MNT_QUOTA = 0x2000 MNT_RDONLY = 0x1 MNT_RELOAD = 0x40000 + MNT_REMOVABLE = 0x200 MNT_ROOTFS = 0x4000 + MNT_SNAPSHOT = 0x40000000 + MNT_STRICTATIME = 0x80000000 MNT_SYNCHRONOUS = 0x2 MNT_UNION = 0x20 MNT_UNKNOWNPERMISSIONS = 0x200000 MNT_UPDATE = 0x10000 - MNT_VISFLAGMASK = 0x17f0f5ff + MNT_VISFLAGMASK = 0xd7f0f7ff MNT_WAIT = 0x1 MSG_CTRUNC = 0x20 MSG_DONTROUTE = 0x4 @@ -963,6 +1024,7 @@ const ( MSG_HAVEMORE = 0x2000 MSG_HOLD = 0x800 MSG_NEEDSA = 0x10000 + MSG_NOSIGNAL = 0x80000 MSG_OOB = 0x1 MSG_PEEK = 0x2 MSG_RCVMORE = 0x4000 @@ -979,9 +1041,10 @@ const ( NET_RT_DUMP = 0x1 NET_RT_DUMP2 = 0x7 NET_RT_FLAGS = 0x2 + NET_RT_FLAGS_PRIV = 0xa NET_RT_IFLIST = 0x3 NET_RT_IFLIST2 = 0x6 - NET_RT_MAXID = 0xa + NET_RT_MAXID = 0xb NET_RT_STAT = 0x4 NET_RT_TRASH = 0x5 NFDBITS = 0x20 @@ -1019,6 +1082,7 @@ const ( NOTE_LEEWAY = 0x10 NOTE_LINK = 0x10 NOTE_LOWAT = 0x1 + NOTE_MACHTIME = 0x100 NOTE_MACH_CONTINUOUS_TIME = 0x80 NOTE_NONE = 0x80 NOTE_NSECONDS = 0x4 @@ -1065,6 +1129,7 @@ const ( O_NDELAY = 0x4 O_NOCTTY = 0x20000 O_NOFOLLOW = 0x100 + O_NOFOLLOW_ANY = 0x20000000 O_NONBLOCK = 0x4 O_POPUP = 0x80000000 O_RDONLY = 0x0 @@ -1136,6 +1201,7 @@ const ( RTF_BROADCAST = 0x400000 RTF_CLONING = 0x100 RTF_CONDEMNED = 0x2000000 + RTF_DEAD = 0x20000000 RTF_DELCLONE = 0x80 RTF_DONE = 0x40 RTF_DYNAMIC = 0x10 @@ -1143,6 +1209,7 @@ const ( RTF_HOST = 0x4 RTF_IFREF = 0x4000000 RTF_IFSCOPE = 0x1000000 + RTF_LLDATA = 0x400 RTF_LLINFO = 0x400 RTF_LOCAL = 0x200000 RTF_MODIFIED = 0x20 @@ -1210,6 +1277,7 @@ const ( SIOCGDRVSPEC = 0xc028697b SIOCGETVLAN = 0xc020697f SIOCGHIWAT = 0x40047301 + SIOCGIF6LOWPAN = 0xc02069c5 SIOCGIFADDR = 0xc0206921 SIOCGIFALTMTU = 0xc0206948 SIOCGIFASYNCMAP = 0xc020697c @@ -1220,6 +1288,7 @@ const ( SIOCGIFDEVMTU = 0xc0206944 SIOCGIFDSTADDR = 0xc0206922 SIOCGIFFLAGS = 0xc0206911 + SIOCGIFFUNCTIONALTYPE = 0xc02069ad SIOCGIFGENERIC = 0xc020693a SIOCGIFKPI = 0xc0206987 SIOCGIFMAC = 0xc0206982 @@ -1233,6 +1302,7 @@ const ( SIOCGIFSTATUS = 0xc331693d SIOCGIFVLAN = 0xc020697f SIOCGIFWAKEFLAGS = 0xc0206988 + SIOCGIFXMEDIA = 0xc02c6948 SIOCGLOWAT = 0x40047303 SIOCGPGRP = 0x40047309 SIOCIFCREATE = 0xc0206978 @@ -1243,6 +1313,7 @@ const ( SIOCSDRVSPEC = 0x8028697b SIOCSETVLAN = 0x8020697e SIOCSHIWAT = 0x80047300 + SIOCSIF6LOWPAN = 0x802069c4 SIOCSIFADDR = 0x8020690c SIOCSIFALTMTU = 0x80206945 SIOCSIFASYNCMAP = 0x8020697d @@ -1270,6 +1341,7 @@ const ( SOCK_RDM = 0x4 SOCK_SEQPACKET = 0x5 SOCK_STREAM = 0x1 + SOL_LOCAL = 0x0 SOL_SOCKET = 0xffff SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x2 diff --git a/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go index f5e91b7abaa..17bba0e44f9 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go @@ -1,6 +1,7 @@ // mkerrors.sh -m64 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && dragonfly // +build amd64,dragonfly // Code generated by cmd/cgo -godefs; DO NOT EDIT. diff --git a/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go b/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go index 3689c808481..9c7c5e16546 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go @@ -1,6 +1,7 @@ // mkerrors.sh -m32 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build 386 && freebsd // +build 386,freebsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. @@ -997,6 +998,11 @@ const ( KERN_OSRELEASE = 0x2 KERN_OSTYPE = 0x1 KERN_VERSION = 0x4 + LOCAL_CONNWAIT = 0x4 + LOCAL_CREDS = 0x2 + LOCAL_CREDS_PERSISTENT = 0x3 + LOCAL_PEERCRED = 0x1 + LOCAL_VENDOR = 0x80000000 LOCK_EX = 0x2 LOCK_NB = 0x4 LOCK_SH = 0x1 @@ -1375,6 +1381,7 @@ const ( SOCK_RDM = 0x4 SOCK_SEQPACKET = 0x5 SOCK_STREAM = 0x1 + SOL_LOCAL = 0x0 SOL_SOCKET = 0xffff SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x2 diff --git a/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go index b8f7c3c930a..b265abb25f8 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go @@ -1,6 +1,7 @@ // mkerrors.sh -m64 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && freebsd // +build amd64,freebsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. @@ -997,6 +998,11 @@ const ( KERN_OSRELEASE = 0x2 KERN_OSTYPE = 0x1 KERN_VERSION = 0x4 + LOCAL_CONNWAIT = 0x4 + LOCAL_CREDS = 0x2 + LOCAL_CREDS_PERSISTENT = 0x3 + LOCAL_PEERCRED = 0x1 + LOCAL_VENDOR = 0x80000000 LOCK_EX = 0x2 LOCK_NB = 0x4 LOCK_SH = 0x1 @@ -1376,6 +1382,7 @@ const ( SOCK_RDM = 0x4 SOCK_SEQPACKET = 0x5 SOCK_STREAM = 0x1 + SOL_LOCAL = 0x0 SOL_SOCKET = 0xffff SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x2 diff --git a/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go b/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go index be14bb1a4cd..0326a6b3af9 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go @@ -1,6 +1,7 @@ // mkerrors.sh // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm && freebsd // +build arm,freebsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. @@ -980,6 +981,11 @@ const ( KERN_OSRELEASE = 0x2 KERN_OSTYPE = 0x1 KERN_VERSION = 0x4 + LOCAL_CONNWAIT = 0x4 + LOCAL_CREDS = 0x2 + LOCAL_CREDS_PERSISTENT = 0x3 + LOCAL_PEERCRED = 0x1 + LOCAL_VENDOR = 0x80000000 LOCK_EX = 0x2 LOCK_NB = 0x4 LOCK_SH = 0x1 @@ -1341,6 +1347,7 @@ const ( SOCK_RDM = 0x4 SOCK_SEQPACKET = 0x5 SOCK_STREAM = 0x1 + SOL_LOCAL = 0x0 SOL_SOCKET = 0xffff SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x2 diff --git a/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm64.go index 7ce9c0081a8..218d39906da 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm64.go @@ -1,6 +1,7 @@ // mkerrors.sh -m64 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm64 && freebsd // +build arm64,freebsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. @@ -997,6 +998,11 @@ const ( KERN_OSRELEASE = 0x2 KERN_OSTYPE = 0x1 KERN_VERSION = 0x4 + LOCAL_CONNWAIT = 0x4 + LOCAL_CREDS = 0x2 + LOCAL_CREDS_PERSISTENT = 0x3 + LOCAL_PEERCRED = 0x1 + LOCAL_VENDOR = 0x80000000 LOCK_EX = 0x2 LOCK_NB = 0x4 LOCK_SH = 0x1 @@ -1376,6 +1382,7 @@ const ( SOCK_RDM = 0x4 SOCK_SEQPACKET = 0x5 SOCK_STREAM = 0x1 + SOL_LOCAL = 0x0 SOL_SOCKET = 0xffff SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x2 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index b46110354df..35de419c6db 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -1,5 +1,6 @@ // Code generated by mkmerge.go; DO NOT EDIT. +//go:build linux // +build linux package unix @@ -65,6 +66,7 @@ const ( ALG_OP_ENCRYPT = 0x1 ALG_SET_AEAD_ASSOCLEN = 0x4 ALG_SET_AEAD_AUTHSIZE = 0x5 + ALG_SET_DRBG_ENTROPY = 0x6 ALG_SET_IV = 0x2 ALG_SET_KEY = 0x1 ALG_SET_OP = 0x3 @@ -179,8 +181,10 @@ const ( BPF_F_ANY_ALIGNMENT = 0x2 BPF_F_QUERY_EFFECTIVE = 0x1 BPF_F_REPLACE = 0x4 + BPF_F_SLEEPABLE = 0x10 BPF_F_STRICT_ALIGNMENT = 0x1 BPF_F_TEST_RND_HI32 = 0x4 + BPF_F_TEST_RUN_ON_CPU = 0x1 BPF_F_TEST_STATE_FREQ = 0x8 BPF_H = 0x8 BPF_IMM = 0x0 @@ -219,6 +223,7 @@ const ( BPF_NET_OFF = -0x100000 BPF_OBJ_NAME_LEN = 0x10 BPF_OR = 0x40 + BPF_PSEUDO_BTF_ID = 0x3 BPF_PSEUDO_CALL = 0x1 BPF_PSEUDO_MAP_FD = 0x1 BPF_PSEUDO_MAP_VALUE = 0x2 @@ -240,6 +245,10 @@ const ( BS0 = 0x0 BTRFS_SUPER_MAGIC = 0x9123683e BTRFS_TEST_MAGIC = 0x73727279 + BUS_BLUETOOTH = 0x5 + BUS_HIL = 0x4 + BUS_USB = 0x3 + BUS_VIRTUAL = 0x6 CAN_BCM = 0x2 CAN_EFF_FLAG = 0x80000000 CAN_EFF_ID_BITS = 0x1d @@ -309,6 +318,7 @@ const ( CAN_J1939 = 0x7 CAN_MAX_DLC = 0x8 CAN_MAX_DLEN = 0x8 + CAN_MAX_RAW_DLC = 0xf CAN_MCNET = 0x5 CAN_MTU = 0x10 CAN_NPROTO = 0x8 @@ -429,10 +439,13 @@ const ( DEBUGFS_MAGIC = 0x64626720 DEVLINK_CMD_ESWITCH_MODE_GET = 0x1d DEVLINK_CMD_ESWITCH_MODE_SET = 0x1e + DEVLINK_FLASH_OVERWRITE_IDENTIFIERS = 0x2 + DEVLINK_FLASH_OVERWRITE_SETTINGS = 0x1 DEVLINK_GENL_MCGRP_CONFIG_NAME = "config" DEVLINK_GENL_NAME = "devlink" DEVLINK_GENL_VERSION = 0x1 DEVLINK_SB_THRESHOLD_TO_ALPHA_MAX = 0x14 + DEVLINK_SUPPORTED_FLASH_OVERWRITE_SECTIONS = 0x3 DEVMEM_MAGIC = 0x454d444d DEVPTS_SUPER_MAGIC = 0x1cd1 DMA_BUF_MAGIC = 0x444d4142 @@ -477,9 +490,9 @@ const ( DM_UUID_FLAG = 0x4000 DM_UUID_LEN = 0x81 DM_VERSION = 0xc138fd00 - DM_VERSION_EXTRA = "-ioctl (2020-02-27)" + DM_VERSION_EXTRA = "-ioctl (2020-10-01)" DM_VERSION_MAJOR = 0x4 - DM_VERSION_MINOR = 0x2a + DM_VERSION_MINOR = 0x2b DM_VERSION_PATCHLEVEL = 0x0 DT_BLK = 0x6 DT_CHR = 0x2 @@ -520,6 +533,119 @@ const ( EPOLL_CTL_DEL = 0x2 EPOLL_CTL_MOD = 0x3 EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2 + ESP_V4_FLOW = 0xa + ESP_V6_FLOW = 0xc + ETHER_FLOW = 0x12 + ETHTOOL_BUSINFO_LEN = 0x20 + ETHTOOL_EROMVERS_LEN = 0x20 + ETHTOOL_FEC_AUTO = 0x2 + ETHTOOL_FEC_BASER = 0x10 + ETHTOOL_FEC_LLRS = 0x20 + ETHTOOL_FEC_NONE = 0x1 + ETHTOOL_FEC_OFF = 0x4 + ETHTOOL_FEC_RS = 0x8 + ETHTOOL_FLAG_ALL = 0x7 + ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 + ETHTOOL_FLAG_OMIT_REPLY = 0x2 + ETHTOOL_FLAG_STATS = 0x4 + ETHTOOL_FLASHDEV = 0x33 + ETHTOOL_FLASH_MAX_FILENAME = 0x80 + ETHTOOL_FWVERS_LEN = 0x20 + ETHTOOL_F_COMPAT = 0x4 + ETHTOOL_F_UNSUPPORTED = 0x1 + ETHTOOL_F_WISH = 0x2 + ETHTOOL_GCHANNELS = 0x3c + ETHTOOL_GCOALESCE = 0xe + ETHTOOL_GDRVINFO = 0x3 + ETHTOOL_GEEE = 0x44 + ETHTOOL_GEEPROM = 0xb + ETHTOOL_GENL_NAME = "ethtool" + ETHTOOL_GENL_VERSION = 0x1 + ETHTOOL_GET_DUMP_DATA = 0x40 + ETHTOOL_GET_DUMP_FLAG = 0x3f + ETHTOOL_GET_TS_INFO = 0x41 + ETHTOOL_GFEATURES = 0x3a + ETHTOOL_GFECPARAM = 0x50 + ETHTOOL_GFLAGS = 0x25 + ETHTOOL_GGRO = 0x2b + ETHTOOL_GGSO = 0x23 + ETHTOOL_GLINK = 0xa + ETHTOOL_GLINKSETTINGS = 0x4c + ETHTOOL_GMODULEEEPROM = 0x43 + ETHTOOL_GMODULEINFO = 0x42 + ETHTOOL_GMSGLVL = 0x7 + ETHTOOL_GPAUSEPARAM = 0x12 + ETHTOOL_GPERMADDR = 0x20 + ETHTOOL_GPFLAGS = 0x27 + ETHTOOL_GPHYSTATS = 0x4a + ETHTOOL_GREGS = 0x4 + ETHTOOL_GRINGPARAM = 0x10 + ETHTOOL_GRSSH = 0x46 + ETHTOOL_GRXCLSRLALL = 0x30 + ETHTOOL_GRXCLSRLCNT = 0x2e + ETHTOOL_GRXCLSRULE = 0x2f + ETHTOOL_GRXCSUM = 0x14 + ETHTOOL_GRXFH = 0x29 + ETHTOOL_GRXFHINDIR = 0x38 + ETHTOOL_GRXNTUPLE = 0x36 + ETHTOOL_GRXRINGS = 0x2d + ETHTOOL_GSET = 0x1 + ETHTOOL_GSG = 0x18 + ETHTOOL_GSSET_INFO = 0x37 + ETHTOOL_GSTATS = 0x1d + ETHTOOL_GSTRINGS = 0x1b + ETHTOOL_GTSO = 0x1e + ETHTOOL_GTUNABLE = 0x48 + ETHTOOL_GTXCSUM = 0x16 + ETHTOOL_GUFO = 0x21 + ETHTOOL_GWOL = 0x5 + ETHTOOL_MCGRP_MONITOR_NAME = "monitor" + ETHTOOL_NWAY_RST = 0x9 + ETHTOOL_PERQUEUE = 0x4b + ETHTOOL_PHYS_ID = 0x1c + ETHTOOL_PHY_EDPD_DFLT_TX_MSECS = 0xffff + ETHTOOL_PHY_EDPD_DISABLE = 0x0 + ETHTOOL_PHY_EDPD_NO_TX = 0xfffe + ETHTOOL_PHY_FAST_LINK_DOWN_OFF = 0xff + ETHTOOL_PHY_FAST_LINK_DOWN_ON = 0x0 + ETHTOOL_PHY_GTUNABLE = 0x4e + ETHTOOL_PHY_STUNABLE = 0x4f + ETHTOOL_RESET = 0x34 + ETHTOOL_RXNTUPLE_ACTION_CLEAR = -0x2 + ETHTOOL_RXNTUPLE_ACTION_DROP = -0x1 + ETHTOOL_RX_FLOW_SPEC_RING = 0xffffffff + ETHTOOL_RX_FLOW_SPEC_RING_VF = 0xff00000000 + ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF = 0x20 + ETHTOOL_SCHANNELS = 0x3d + ETHTOOL_SCOALESCE = 0xf + ETHTOOL_SEEE = 0x45 + ETHTOOL_SEEPROM = 0xc + ETHTOOL_SET_DUMP = 0x3e + ETHTOOL_SFEATURES = 0x3b + ETHTOOL_SFECPARAM = 0x51 + ETHTOOL_SFLAGS = 0x26 + ETHTOOL_SGRO = 0x2c + ETHTOOL_SGSO = 0x24 + ETHTOOL_SLINKSETTINGS = 0x4d + ETHTOOL_SMSGLVL = 0x8 + ETHTOOL_SPAUSEPARAM = 0x13 + ETHTOOL_SPFLAGS = 0x28 + ETHTOOL_SRINGPARAM = 0x11 + ETHTOOL_SRSSH = 0x47 + ETHTOOL_SRXCLSRLDEL = 0x31 + ETHTOOL_SRXCLSRLINS = 0x32 + ETHTOOL_SRXCSUM = 0x15 + ETHTOOL_SRXFH = 0x2a + ETHTOOL_SRXFHINDIR = 0x39 + ETHTOOL_SRXNTUPLE = 0x35 + ETHTOOL_SSET = 0x2 + ETHTOOL_SSG = 0x19 + ETHTOOL_STSO = 0x1f + ETHTOOL_STUNABLE = 0x49 + ETHTOOL_STXCSUM = 0x17 + ETHTOOL_SUFO = 0x22 + ETHTOOL_SWOL = 0x6 + ETHTOOL_TEST = 0x1a ETH_P_1588 = 0x88f7 ETH_P_8021AD = 0x88a8 ETH_P_8021AH = 0x88e7 @@ -544,6 +670,7 @@ const ( ETH_P_CAIF = 0xf7 ETH_P_CAN = 0xc ETH_P_CANFD = 0xd + ETH_P_CFM = 0x8902 ETH_P_CONTROL = 0x16 ETH_P_CUST = 0x6006 ETH_P_DDCMP = 0x6 @@ -714,7 +841,6 @@ const ( FSCRYPT_POLICY_FLAGS_PAD_4 = 0x0 FSCRYPT_POLICY_FLAGS_PAD_8 = 0x1 FSCRYPT_POLICY_FLAGS_PAD_MASK = 0x3 - FSCRYPT_POLICY_FLAGS_VALID = 0x1f FSCRYPT_POLICY_FLAG_DIRECT_KEY = 0x4 FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32 = 0x10 FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64 = 0x8 @@ -745,7 +871,7 @@ const ( FS_POLICY_FLAGS_PAD_4 = 0x0 FS_POLICY_FLAGS_PAD_8 = 0x1 FS_POLICY_FLAGS_PAD_MASK = 0x3 - FS_POLICY_FLAGS_VALID = 0x1f + FS_POLICY_FLAGS_VALID = 0x7 FS_VERITY_FL = 0x100000 FS_VERITY_HASH_ALG_SHA256 = 0x1 FS_VERITY_HASH_ALG_SHA512 = 0x2 @@ -842,11 +968,17 @@ const ( HDIO_SET_XFER = 0x306 HDIO_TRISTATE_HWIF = 0x31b HDIO_UNREGISTER_HWIF = 0x32a + HID_MAX_DESCRIPTOR_SIZE = 0x1000 HOSTFS_SUPER_MAGIC = 0xc0ffee HPFS_SUPER_MAGIC = 0xf995e849 HUGETLBFS_MAGIC = 0x958458f6 IBSHIFT = 0x10 ICMPV6_FILTER = 0x1 + ICMPV6_FILTER_BLOCK = 0x1 + ICMPV6_FILTER_BLOCKOTHERS = 0x3 + ICMPV6_FILTER_PASS = 0x2 + ICMPV6_FILTER_PASSONLY = 0x4 + ICMP_FILTER = 0x1 ICRNL = 0x100 IFA_F_DADFAILED = 0x8 IFA_F_DEPRECATED = 0x20 @@ -989,6 +1121,7 @@ const ( IPV6_DONTFRAG = 0x3e IPV6_DROP_MEMBERSHIP = 0x15 IPV6_DSTOPTS = 0x3b + IPV6_FLOW = 0x11 IPV6_FREEBIND = 0x4e IPV6_HDRINCL = 0x24 IPV6_HOPLIMIT = 0x34 @@ -1017,6 +1150,7 @@ const ( IPV6_PMTUDISC_WANT = 0x1 IPV6_RECVDSTOPTS = 0x3a IPV6_RECVERR = 0x19 + IPV6_RECVERR_RFC4884 = 0x1f IPV6_RECVFRAGSIZE = 0x4d IPV6_RECVHOPLIMIT = 0x33 IPV6_RECVHOPOPTS = 0x35 @@ -1038,6 +1172,7 @@ const ( IPV6_TRANSPARENT = 0x4b IPV6_UNICAST_HOPS = 0x10 IPV6_UNICAST_IF = 0x4c + IPV6_USER_FLOW = 0xe IPV6_V6ONLY = 0x1a IPV6_XFRM_POLICY = 0x23 IP_ADD_MEMBERSHIP = 0x23 @@ -1080,6 +1215,7 @@ const ( IP_PMTUDISC_PROBE = 0x3 IP_PMTUDISC_WANT = 0x1 IP_RECVERR = 0xb + IP_RECVERR_RFC4884 = 0x1a IP_RECVFRAGSIZE = 0x19 IP_RECVOPTS = 0x6 IP_RECVORIGDSTADDR = 0x14 @@ -1094,6 +1230,7 @@ const ( IP_TTL = 0x2 IP_UNBLOCK_SOURCE = 0x25 IP_UNICAST_IF = 0x32 + IP_USER_FLOW = 0xd IP_XFRM_POLICY = 0x11 ISOFS_SUPER_MAGIC = 0x9660 ISTRIP = 0x20 @@ -1331,6 +1468,7 @@ const ( MS_NOREMOTELOCK = 0x8000000 MS_NOSEC = 0x10000000 MS_NOSUID = 0x2 + MS_NOSYMFOLLOW = 0x100 MS_NOUSER = -0x80000000 MS_POSIXACL = 0x10000 MS_PRIVATE = 0x40000 @@ -1572,7 +1710,7 @@ const ( PERF_MEM_REMOTE_REMOTE = 0x1 PERF_MEM_REMOTE_SHIFT = 0x25 PERF_MEM_SNOOPX_FWD = 0x1 - PERF_MEM_SNOOPX_SHIFT = 0x25 + PERF_MEM_SNOOPX_SHIFT = 0x26 PERF_MEM_SNOOP_HIT = 0x4 PERF_MEM_SNOOP_HITM = 0x10 PERF_MEM_SNOOP_MISS = 0x8 @@ -1672,6 +1810,13 @@ const ( PR_MCE_KILL_SET = 0x1 PR_MPX_DISABLE_MANAGEMENT = 0x2c PR_MPX_ENABLE_MANAGEMENT = 0x2b + PR_MTE_TAG_MASK = 0x7fff8 + PR_MTE_TAG_SHIFT = 0x3 + PR_MTE_TCF_ASYNC = 0x4 + PR_MTE_TCF_MASK = 0x6 + PR_MTE_TCF_NONE = 0x0 + PR_MTE_TCF_SHIFT = 0x1 + PR_MTE_TCF_SYNC = 0x2 PR_PAC_APDAKEY = 0x4 PR_PAC_APDBKEY = 0x8 PR_PAC_APGAKEY = 0x10 @@ -1709,6 +1854,7 @@ const ( PR_SET_SECCOMP = 0x16 PR_SET_SECUREBITS = 0x1c PR_SET_SPECULATION_CTRL = 0x35 + PR_SET_SYSCALL_USER_DISPATCH = 0x3b PR_SET_TAGGED_ADDR_CTRL = 0x37 PR_SET_THP_DISABLE = 0x29 PR_SET_TIMERSLACK = 0x1d @@ -1728,6 +1874,8 @@ const ( PR_SVE_SET_VL_ONEXEC = 0x40000 PR_SVE_VL_INHERIT = 0x20000 PR_SVE_VL_LEN_MASK = 0xffff + PR_SYS_DISPATCH_OFF = 0x0 + PR_SYS_DISPATCH_ON = 0x1 PR_TAGGED_ADDR_ENABLE = 0x1 PR_TASK_PERF_EVENTS_DISABLE = 0x1f PR_TASK_PERF_EVENTS_ENABLE = 0x20 @@ -1973,12 +2121,13 @@ const ( RTM_SETLINK = 0x13 RTM_SETNEIGHTBL = 0x43 RTNH_ALIGNTO = 0x4 - RTNH_COMPARE_MASK = 0x19 + RTNH_COMPARE_MASK = 0x59 RTNH_F_DEAD = 0x1 RTNH_F_LINKDOWN = 0x10 RTNH_F_OFFLOAD = 0x8 RTNH_F_ONLINK = 0x4 RTNH_F_PERVASIVE = 0x2 + RTNH_F_TRAP = 0x40 RTNH_F_UNRESOLVED = 0x20 RTN_MAX = 0xb RTPROT_BABEL = 0x2a @@ -2206,7 +2355,7 @@ const ( STATX_ATTR_APPEND = 0x20 STATX_ATTR_AUTOMOUNT = 0x1000 STATX_ATTR_COMPRESSED = 0x4 - STATX_ATTR_DAX = 0x2000 + STATX_ATTR_DAX = 0x200000 STATX_ATTR_ENCRYPTED = 0x800 STATX_ATTR_IMMUTABLE = 0x10 STATX_ATTR_MOUNT_ROOT = 0x2000 @@ -2325,6 +2474,8 @@ const ( TCP_TX_DELAY = 0x25 TCP_ULP = 0x1f TCP_USER_TIMEOUT = 0x12 + TCP_V4_FLOW = 0x1 + TCP_V6_FLOW = 0x5 TCP_WINDOW_CLAMP = 0xa TCP_ZEROCOPY_RECEIVE = 0x23 TFD_TIMER_ABSTIME = 0x1 @@ -2390,6 +2541,7 @@ const ( TIPC_NODE_STATE = 0x0 TIPC_OK = 0x0 TIPC_PUBLISHED = 0x1 + TIPC_REKEYING_NOW = 0xffffffff TIPC_RESERVED_TYPES = 0x40 TIPC_RETDATA = 0x2 TIPC_SERVICE_ADDR = 0x2 @@ -2446,10 +2598,12 @@ const ( VMADDR_CID_HOST = 0x2 VMADDR_CID_HYPERVISOR = 0x0 VMADDR_CID_LOCAL = 0x1 + VMADDR_FLAG_TO_HOST = 0x1 VMADDR_PORT_ANY = 0xffffffff VM_SOCKETS_INVALID_VERSION = 0xffffffff VQUIT = 0x1 VT0 = 0x0 + WAKE_MAGIC = 0x20 WALL = 0x40000000 WCLONE = 0x80000000 WCONTINUED = 0x8 @@ -2592,6 +2746,9 @@ const ( Z3FOLD_MAGIC = 0x33 ZONEFS_MAGIC = 0x5a4f4653 ZSMALLOC_MAGIC = 0x58295829 + _HIDIOCGRAWNAME_LEN = 0x80 + _HIDIOCGRAWPHYS_LEN = 0x40 + _HIDIOCGRAWUNIQ_LEN = 0x40 ) // Errors diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index dd282c08b7f..e91a1a95792 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -1,10 +1,11 @@ // mkerrors.sh -Wall -Werror -static -I/tmp/include -m32 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build 386 && linux // +build 386,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include -m32 _const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include -m32 /build/_const.go package unix @@ -93,6 +94,9 @@ const ( F_SETOWN = 0x8 F_UNLCK = 0x2 F_WRLCK = 0x1 + HIDIOCGRAWINFO = 0x80084803 + HIDIOCGRDESC = 0x90044802 + HIDIOCGRDESCSIZE = 0x80044801 HUPCL = 0x400 ICANON = 0x2 IEXTEN = 0x8000 @@ -165,6 +169,7 @@ const ( PERF_EVENT_IOC_SET_OUTPUT = 0x2405 PPPIOCATTACH = 0x4004743d PPPIOCATTCHAN = 0x40047438 + PPPIOCBRIDGECHAN = 0x40047435 PPPIOCCONNECT = 0x4004743a PPPIOCDETACH = 0x4004743c PPPIOCDISCONN = 0x7439 @@ -192,6 +197,7 @@ const ( PPPIOCSPASS = 0x40087447 PPPIOCSRASYNCMAP = 0x40047454 PPPIOCSXASYNCMAP = 0x4020744f + PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCXFERUNIT = 0x744e PR_SET_PTRACER_ANY = 0xffffffff PTRACE_GETFPREGS = 0xe @@ -268,6 +274,7 @@ const ( SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe SO_BUSY_POLL = 0x2e + SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 SO_COOKIE = 0x39 SO_DETACH_REUSEPORT_BPF = 0x44 @@ -290,6 +297,7 @@ const ( SO_PEERCRED = 0x11 SO_PEERGROUPS = 0x3b SO_PEERSEC = 0x1f + SO_PREFER_BUSY_POLL = 0x45 SO_PROTOCOL = 0x26 SO_RCVBUF = 0x8 SO_RCVBUFFORCE = 0x21 @@ -481,6 +489,9 @@ const ( X86_FXSR_MAGIC = 0x0 XCASE = 0x4 XTABS = 0x1800 + _HIDIOCGRAWNAME = 0x80804804 + _HIDIOCGRAWPHYS = 0x80404805 + _HIDIOCGRAWUNIQ = 0x80404808 ) // Errors diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index 82fc93c7bbc..a9cbac64439 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -1,10 +1,11 @@ // mkerrors.sh -Wall -Werror -static -I/tmp/include -m64 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && linux // +build amd64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include -m64 _const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include -m64 /build/_const.go package unix @@ -93,6 +94,9 @@ const ( F_SETOWN = 0x8 F_UNLCK = 0x2 F_WRLCK = 0x1 + HIDIOCGRAWINFO = 0x80084803 + HIDIOCGRDESC = 0x90044802 + HIDIOCGRDESCSIZE = 0x80044801 HUPCL = 0x400 ICANON = 0x2 IEXTEN = 0x8000 @@ -165,6 +169,7 @@ const ( PERF_EVENT_IOC_SET_OUTPUT = 0x2405 PPPIOCATTACH = 0x4004743d PPPIOCATTCHAN = 0x40047438 + PPPIOCBRIDGECHAN = 0x40047435 PPPIOCCONNECT = 0x4004743a PPPIOCDETACH = 0x4004743c PPPIOCDISCONN = 0x7439 @@ -192,6 +197,7 @@ const ( PPPIOCSPASS = 0x40107447 PPPIOCSRASYNCMAP = 0x40047454 PPPIOCSXASYNCMAP = 0x4020744f + PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCXFERUNIT = 0x744e PR_SET_PTRACER_ANY = 0xffffffffffffffff PTRACE_ARCH_PRCTL = 0x1e @@ -269,6 +275,7 @@ const ( SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe SO_BUSY_POLL = 0x2e + SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 SO_COOKIE = 0x39 SO_DETACH_REUSEPORT_BPF = 0x44 @@ -291,6 +298,7 @@ const ( SO_PEERCRED = 0x11 SO_PEERGROUPS = 0x3b SO_PEERSEC = 0x1f + SO_PREFER_BUSY_POLL = 0x45 SO_PROTOCOL = 0x26 SO_RCVBUF = 0x8 SO_RCVBUFFORCE = 0x21 @@ -481,6 +489,9 @@ const ( WORDSIZE = 0x40 XCASE = 0x4 XTABS = 0x1800 + _HIDIOCGRAWNAME = 0x80804804 + _HIDIOCGRAWPHYS = 0x80404805 + _HIDIOCGRAWUNIQ = 0x80404808 ) // Errors diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index fe7094f2763..d74f3c15a1d 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -1,10 +1,11 @@ // mkerrors.sh -Wall -Werror -static -I/tmp/include // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm && linux // +build arm,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go package unix @@ -92,6 +93,9 @@ const ( F_SETOWN = 0x8 F_UNLCK = 0x2 F_WRLCK = 0x1 + HIDIOCGRAWINFO = 0x80084803 + HIDIOCGRDESC = 0x90044802 + HIDIOCGRDESCSIZE = 0x80044801 HUPCL = 0x400 ICANON = 0x2 IEXTEN = 0x8000 @@ -163,6 +167,7 @@ const ( PERF_EVENT_IOC_SET_OUTPUT = 0x2405 PPPIOCATTACH = 0x4004743d PPPIOCATTCHAN = 0x40047438 + PPPIOCBRIDGECHAN = 0x40047435 PPPIOCCONNECT = 0x4004743a PPPIOCDETACH = 0x4004743c PPPIOCDISCONN = 0x7439 @@ -190,6 +195,7 @@ const ( PPPIOCSPASS = 0x40087447 PPPIOCSRASYNCMAP = 0x40047454 PPPIOCSXASYNCMAP = 0x4020744f + PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCXFERUNIT = 0x744e PR_SET_PTRACER_ANY = 0xffffffff PTRACE_GETCRUNCHREGS = 0x19 @@ -275,6 +281,7 @@ const ( SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe SO_BUSY_POLL = 0x2e + SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 SO_COOKIE = 0x39 SO_DETACH_REUSEPORT_BPF = 0x44 @@ -297,6 +304,7 @@ const ( SO_PEERCRED = 0x11 SO_PEERGROUPS = 0x3b SO_PEERSEC = 0x1f + SO_PREFER_BUSY_POLL = 0x45 SO_PROTOCOL = 0x26 SO_RCVBUF = 0x8 SO_RCVBUFFORCE = 0x21 @@ -487,6 +495,9 @@ const ( WORDSIZE = 0x20 XCASE = 0x4 XTABS = 0x1800 + _HIDIOCGRAWNAME = 0x80804804 + _HIDIOCGRAWPHYS = 0x80404805 + _HIDIOCGRAWUNIQ = 0x80404808 ) // Errors diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 3b6cc58803b..e1538995b49 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -1,10 +1,11 @@ // mkerrors.sh -Wall -Werror -static -I/tmp/include -fsigned-char // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm64 && linux // +build arm64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char _const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char /build/_const.go package unix @@ -95,6 +96,9 @@ const ( F_SETOWN = 0x8 F_UNLCK = 0x2 F_WRLCK = 0x1 + HIDIOCGRAWINFO = 0x80084803 + HIDIOCGRDESC = 0x90044802 + HIDIOCGRDESCSIZE = 0x80044801 HUPCL = 0x400 ICANON = 0x2 IEXTEN = 0x8000 @@ -166,6 +170,7 @@ const ( PERF_EVENT_IOC_SET_OUTPUT = 0x2405 PPPIOCATTACH = 0x4004743d PPPIOCATTCHAN = 0x40047438 + PPPIOCBRIDGECHAN = 0x40047435 PPPIOCCONNECT = 0x4004743a PPPIOCDETACH = 0x4004743c PPPIOCDISCONN = 0x7439 @@ -193,9 +198,13 @@ const ( PPPIOCSPASS = 0x40107447 PPPIOCSRASYNCMAP = 0x40047454 PPPIOCSXASYNCMAP = 0x4020744f + PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCXFERUNIT = 0x744e PROT_BTI = 0x10 + PROT_MTE = 0x20 PR_SET_PTRACER_ANY = 0xffffffffffffffff + PTRACE_PEEKMTETAGS = 0x21 + PTRACE_POKEMTETAGS = 0x22 PTRACE_SYSEMU = 0x1f PTRACE_SYSEMU_SINGLESTEP = 0x20 RLIMIT_AS = 0x9 @@ -262,6 +271,7 @@ const ( SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe SO_BUSY_POLL = 0x2e + SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 SO_COOKIE = 0x39 SO_DETACH_REUSEPORT_BPF = 0x44 @@ -284,6 +294,7 @@ const ( SO_PEERCRED = 0x11 SO_PEERGROUPS = 0x3b SO_PEERSEC = 0x1f + SO_PREFER_BUSY_POLL = 0x45 SO_PROTOCOL = 0x26 SO_RCVBUF = 0x8 SO_RCVBUFFORCE = 0x21 @@ -475,6 +486,9 @@ const ( WORDSIZE = 0x40 XCASE = 0x4 XTABS = 0x1800 + _HIDIOCGRAWNAME = 0x80804804 + _HIDIOCGRAWPHYS = 0x80404805 + _HIDIOCGRAWUNIQ = 0x80404808 ) // Errors diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index ce3d9ae1561..5e8e71ff863 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -1,10 +1,11 @@ // mkerrors.sh -Wall -Werror -static -I/tmp/include // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build mips && linux // +build mips,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go package unix @@ -92,6 +93,9 @@ const ( F_SETOWN = 0x18 F_UNLCK = 0x2 F_WRLCK = 0x1 + HIDIOCGRAWINFO = 0x40084803 + HIDIOCGRDESC = 0x50044802 + HIDIOCGRDESCSIZE = 0x40044801 HUPCL = 0x400 ICANON = 0x2 IEXTEN = 0x100 @@ -163,6 +167,7 @@ const ( PERF_EVENT_IOC_SET_OUTPUT = 0x20002405 PPPIOCATTACH = 0x8004743d PPPIOCATTCHAN = 0x80047438 + PPPIOCBRIDGECHAN = 0x80047435 PPPIOCCONNECT = 0x8004743a PPPIOCDETACH = 0x8004743c PPPIOCDISCONN = 0x20007439 @@ -190,6 +195,7 @@ const ( PPPIOCSPASS = 0x80087447 PPPIOCSRASYNCMAP = 0x80047454 PPPIOCSXASYNCMAP = 0x8020744f + PPPIOCUNBRIDGECHAN = 0x20007434 PPPIOCXFERUNIT = 0x2000744e PR_SET_PTRACER_ANY = 0xffffffff PTRACE_GETFPREGS = 0xe @@ -268,6 +274,7 @@ const ( SO_BROADCAST = 0x20 SO_BSDCOMPAT = 0xe SO_BUSY_POLL = 0x2e + SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 SO_COOKIE = 0x39 SO_DETACH_REUSEPORT_BPF = 0x44 @@ -290,6 +297,7 @@ const ( SO_PEERCRED = 0x12 SO_PEERGROUPS = 0x3b SO_PEERSEC = 0x1e + SO_PREFER_BUSY_POLL = 0x45 SO_PROTOCOL = 0x1028 SO_RCVBUF = 0x1002 SO_RCVBUFFORCE = 0x21 @@ -483,6 +491,9 @@ const ( WORDSIZE = 0x20 XCASE = 0x4 XTABS = 0x1800 + _HIDIOCGRAWNAME = 0x40804804 + _HIDIOCGRAWPHYS = 0x40404805 + _HIDIOCGRAWUNIQ = 0x40404808 ) // Errors diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index 7a85215ce52..e670ee14814 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -1,10 +1,11 @@ // mkerrors.sh -Wall -Werror -static -I/tmp/include // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build mips64 && linux // +build mips64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go package unix @@ -92,6 +93,9 @@ const ( F_SETOWN = 0x18 F_UNLCK = 0x2 F_WRLCK = 0x1 + HIDIOCGRAWINFO = 0x40084803 + HIDIOCGRDESC = 0x50044802 + HIDIOCGRDESCSIZE = 0x40044801 HUPCL = 0x400 ICANON = 0x2 IEXTEN = 0x100 @@ -163,6 +167,7 @@ const ( PERF_EVENT_IOC_SET_OUTPUT = 0x20002405 PPPIOCATTACH = 0x8004743d PPPIOCATTCHAN = 0x80047438 + PPPIOCBRIDGECHAN = 0x80047435 PPPIOCCONNECT = 0x8004743a PPPIOCDETACH = 0x8004743c PPPIOCDISCONN = 0x20007439 @@ -190,6 +195,7 @@ const ( PPPIOCSPASS = 0x80107447 PPPIOCSRASYNCMAP = 0x80047454 PPPIOCSXASYNCMAP = 0x8020744f + PPPIOCUNBRIDGECHAN = 0x20007434 PPPIOCXFERUNIT = 0x2000744e PR_SET_PTRACER_ANY = 0xffffffffffffffff PTRACE_GETFPREGS = 0xe @@ -268,6 +274,7 @@ const ( SO_BROADCAST = 0x20 SO_BSDCOMPAT = 0xe SO_BUSY_POLL = 0x2e + SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 SO_COOKIE = 0x39 SO_DETACH_REUSEPORT_BPF = 0x44 @@ -290,6 +297,7 @@ const ( SO_PEERCRED = 0x12 SO_PEERGROUPS = 0x3b SO_PEERSEC = 0x1e + SO_PREFER_BUSY_POLL = 0x45 SO_PROTOCOL = 0x1028 SO_RCVBUF = 0x1002 SO_RCVBUFFORCE = 0x21 @@ -483,6 +491,9 @@ const ( WORDSIZE = 0x40 XCASE = 0x4 XTABS = 0x1800 + _HIDIOCGRAWNAME = 0x40804804 + _HIDIOCGRAWPHYS = 0x40404805 + _HIDIOCGRAWUNIQ = 0x40404808 ) // Errors diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index 07d4cc1bd5f..dd11eacb81e 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -1,10 +1,11 @@ // mkerrors.sh -Wall -Werror -static -I/tmp/include // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build mips64le && linux // +build mips64le,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go package unix @@ -92,6 +93,9 @@ const ( F_SETOWN = 0x18 F_UNLCK = 0x2 F_WRLCK = 0x1 + HIDIOCGRAWINFO = 0x40084803 + HIDIOCGRDESC = 0x50044802 + HIDIOCGRDESCSIZE = 0x40044801 HUPCL = 0x400 ICANON = 0x2 IEXTEN = 0x100 @@ -163,6 +167,7 @@ const ( PERF_EVENT_IOC_SET_OUTPUT = 0x20002405 PPPIOCATTACH = 0x8004743d PPPIOCATTCHAN = 0x80047438 + PPPIOCBRIDGECHAN = 0x80047435 PPPIOCCONNECT = 0x8004743a PPPIOCDETACH = 0x8004743c PPPIOCDISCONN = 0x20007439 @@ -190,6 +195,7 @@ const ( PPPIOCSPASS = 0x80107447 PPPIOCSRASYNCMAP = 0x80047454 PPPIOCSXASYNCMAP = 0x8020744f + PPPIOCUNBRIDGECHAN = 0x20007434 PPPIOCXFERUNIT = 0x2000744e PR_SET_PTRACER_ANY = 0xffffffffffffffff PTRACE_GETFPREGS = 0xe @@ -268,6 +274,7 @@ const ( SO_BROADCAST = 0x20 SO_BSDCOMPAT = 0xe SO_BUSY_POLL = 0x2e + SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 SO_COOKIE = 0x39 SO_DETACH_REUSEPORT_BPF = 0x44 @@ -290,6 +297,7 @@ const ( SO_PEERCRED = 0x12 SO_PEERGROUPS = 0x3b SO_PEERSEC = 0x1e + SO_PREFER_BUSY_POLL = 0x45 SO_PROTOCOL = 0x1028 SO_RCVBUF = 0x1002 SO_RCVBUFFORCE = 0x21 @@ -483,6 +491,9 @@ const ( WORDSIZE = 0x40 XCASE = 0x4 XTABS = 0x1800 + _HIDIOCGRAWNAME = 0x40804804 + _HIDIOCGRAWPHYS = 0x40404805 + _HIDIOCGRAWUNIQ = 0x40404808 ) // Errors diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index d4842ba1c2a..a0a5b22ae93 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -1,10 +1,11 @@ // mkerrors.sh -Wall -Werror -static -I/tmp/include // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build mipsle && linux // +build mipsle,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go package unix @@ -92,6 +93,9 @@ const ( F_SETOWN = 0x18 F_UNLCK = 0x2 F_WRLCK = 0x1 + HIDIOCGRAWINFO = 0x40084803 + HIDIOCGRDESC = 0x50044802 + HIDIOCGRDESCSIZE = 0x40044801 HUPCL = 0x400 ICANON = 0x2 IEXTEN = 0x100 @@ -163,6 +167,7 @@ const ( PERF_EVENT_IOC_SET_OUTPUT = 0x20002405 PPPIOCATTACH = 0x8004743d PPPIOCATTCHAN = 0x80047438 + PPPIOCBRIDGECHAN = 0x80047435 PPPIOCCONNECT = 0x8004743a PPPIOCDETACH = 0x8004743c PPPIOCDISCONN = 0x20007439 @@ -190,6 +195,7 @@ const ( PPPIOCSPASS = 0x80087447 PPPIOCSRASYNCMAP = 0x80047454 PPPIOCSXASYNCMAP = 0x8020744f + PPPIOCUNBRIDGECHAN = 0x20007434 PPPIOCXFERUNIT = 0x2000744e PR_SET_PTRACER_ANY = 0xffffffff PTRACE_GETFPREGS = 0xe @@ -268,6 +274,7 @@ const ( SO_BROADCAST = 0x20 SO_BSDCOMPAT = 0xe SO_BUSY_POLL = 0x2e + SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 SO_COOKIE = 0x39 SO_DETACH_REUSEPORT_BPF = 0x44 @@ -290,6 +297,7 @@ const ( SO_PEERCRED = 0x12 SO_PEERGROUPS = 0x3b SO_PEERSEC = 0x1e + SO_PREFER_BUSY_POLL = 0x45 SO_PROTOCOL = 0x1028 SO_RCVBUF = 0x1002 SO_RCVBUFFORCE = 0x21 @@ -483,6 +491,9 @@ const ( WORDSIZE = 0x20 XCASE = 0x4 XTABS = 0x1800 + _HIDIOCGRAWNAME = 0x40804804 + _HIDIOCGRAWPHYS = 0x40404805 + _HIDIOCGRAWUNIQ = 0x40404808 ) // Errors diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index 941e20dacec..e60102f6a92 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -1,10 +1,11 @@ // mkerrors.sh -Wall -Werror -static -I/tmp/include // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build ppc64 && linux // +build ppc64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go package unix @@ -92,6 +93,9 @@ const ( F_SETOWN = 0x8 F_UNLCK = 0x2 F_WRLCK = 0x1 + HIDIOCGRAWINFO = 0x40084803 + HIDIOCGRDESC = 0x50044802 + HIDIOCGRDESCSIZE = 0x40044801 HUPCL = 0x4000 ICANON = 0x100 IEXTEN = 0x400 @@ -165,6 +169,7 @@ const ( PERF_EVENT_IOC_SET_OUTPUT = 0x20002405 PPPIOCATTACH = 0x8004743d PPPIOCATTCHAN = 0x80047438 + PPPIOCBRIDGECHAN = 0x80047435 PPPIOCCONNECT = 0x8004743a PPPIOCDETACH = 0x8004743c PPPIOCDISCONN = 0x20007439 @@ -192,6 +197,7 @@ const ( PPPIOCSPASS = 0x80107447 PPPIOCSRASYNCMAP = 0x80047454 PPPIOCSXASYNCMAP = 0x8020744f + PPPIOCUNBRIDGECHAN = 0x20007434 PPPIOCXFERUNIT = 0x2000744e PROT_SAO = 0x10 PR_SET_PTRACER_ANY = 0xffffffffffffffff @@ -327,6 +333,7 @@ const ( SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe SO_BUSY_POLL = 0x2e + SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 SO_COOKIE = 0x39 SO_DETACH_REUSEPORT_BPF = 0x44 @@ -349,6 +356,7 @@ const ( SO_PEERCRED = 0x15 SO_PEERGROUPS = 0x3b SO_PEERSEC = 0x1f + SO_PREFER_BUSY_POLL = 0x45 SO_PROTOCOL = 0x26 SO_RCVBUF = 0x8 SO_RCVBUFFORCE = 0x21 @@ -543,6 +551,9 @@ const ( WORDSIZE = 0x40 XCASE = 0x4000 XTABS = 0xc00 + _HIDIOCGRAWNAME = 0x40804804 + _HIDIOCGRAWPHYS = 0x40404805 + _HIDIOCGRAWUNIQ = 0x40404808 ) // Errors diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index 63d3bc56627..838ff4ea6d0 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -1,10 +1,11 @@ // mkerrors.sh -Wall -Werror -static -I/tmp/include // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build ppc64le && linux // +build ppc64le,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go package unix @@ -92,6 +93,9 @@ const ( F_SETOWN = 0x8 F_UNLCK = 0x2 F_WRLCK = 0x1 + HIDIOCGRAWINFO = 0x40084803 + HIDIOCGRDESC = 0x50044802 + HIDIOCGRDESCSIZE = 0x40044801 HUPCL = 0x4000 ICANON = 0x100 IEXTEN = 0x400 @@ -165,6 +169,7 @@ const ( PERF_EVENT_IOC_SET_OUTPUT = 0x20002405 PPPIOCATTACH = 0x8004743d PPPIOCATTCHAN = 0x80047438 + PPPIOCBRIDGECHAN = 0x80047435 PPPIOCCONNECT = 0x8004743a PPPIOCDETACH = 0x8004743c PPPIOCDISCONN = 0x20007439 @@ -192,6 +197,7 @@ const ( PPPIOCSPASS = 0x80107447 PPPIOCSRASYNCMAP = 0x80047454 PPPIOCSXASYNCMAP = 0x8020744f + PPPIOCUNBRIDGECHAN = 0x20007434 PPPIOCXFERUNIT = 0x2000744e PROT_SAO = 0x10 PR_SET_PTRACER_ANY = 0xffffffffffffffff @@ -327,6 +333,7 @@ const ( SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe SO_BUSY_POLL = 0x2e + SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 SO_COOKIE = 0x39 SO_DETACH_REUSEPORT_BPF = 0x44 @@ -349,6 +356,7 @@ const ( SO_PEERCRED = 0x15 SO_PEERGROUPS = 0x3b SO_PEERSEC = 0x1f + SO_PREFER_BUSY_POLL = 0x45 SO_PROTOCOL = 0x26 SO_RCVBUF = 0x8 SO_RCVBUFFORCE = 0x21 @@ -543,6 +551,9 @@ const ( WORDSIZE = 0x40 XCASE = 0x4000 XTABS = 0xc00 + _HIDIOCGRAWNAME = 0x40804804 + _HIDIOCGRAWPHYS = 0x40404805 + _HIDIOCGRAWUNIQ = 0x40404808 ) // Errors diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 490bee1ab1b..7cc98f09c3e 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -1,10 +1,11 @@ // mkerrors.sh -Wall -Werror -static -I/tmp/include // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build riscv64 && linux // +build riscv64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go package unix @@ -92,6 +93,9 @@ const ( F_SETOWN = 0x8 F_UNLCK = 0x2 F_WRLCK = 0x1 + HIDIOCGRAWINFO = 0x80084803 + HIDIOCGRDESC = 0x90044802 + HIDIOCGRDESCSIZE = 0x80044801 HUPCL = 0x400 ICANON = 0x2 IEXTEN = 0x8000 @@ -163,6 +167,7 @@ const ( PERF_EVENT_IOC_SET_OUTPUT = 0x2405 PPPIOCATTACH = 0x4004743d PPPIOCATTCHAN = 0x40047438 + PPPIOCBRIDGECHAN = 0x40047435 PPPIOCCONNECT = 0x4004743a PPPIOCDETACH = 0x4004743c PPPIOCDISCONN = 0x7439 @@ -190,6 +195,7 @@ const ( PPPIOCSPASS = 0x40107447 PPPIOCSRASYNCMAP = 0x40047454 PPPIOCSXASYNCMAP = 0x4020744f + PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCXFERUNIT = 0x744e PR_SET_PTRACER_ANY = 0xffffffffffffffff RLIMIT_AS = 0x9 @@ -256,6 +262,7 @@ const ( SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe SO_BUSY_POLL = 0x2e + SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 SO_COOKIE = 0x39 SO_DETACH_REUSEPORT_BPF = 0x44 @@ -278,6 +285,7 @@ const ( SO_PEERCRED = 0x11 SO_PEERGROUPS = 0x3b SO_PEERSEC = 0x1f + SO_PREFER_BUSY_POLL = 0x45 SO_PROTOCOL = 0x26 SO_RCVBUF = 0x8 SO_RCVBUFFORCE = 0x21 @@ -468,6 +476,9 @@ const ( WORDSIZE = 0x40 XCASE = 0x4 XTABS = 0x1800 + _HIDIOCGRAWNAME = 0x80804804 + _HIDIOCGRAWPHYS = 0x80404805 + _HIDIOCGRAWUNIQ = 0x80404808 ) // Errors diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index 467b8218e80..a508392d258 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -1,10 +1,11 @@ // mkerrors.sh -Wall -Werror -static -I/tmp/include -fsigned-char // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build s390x && linux // +build s390x,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char _const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char /build/_const.go package unix @@ -92,6 +93,9 @@ const ( F_SETOWN = 0x8 F_UNLCK = 0x2 F_WRLCK = 0x1 + HIDIOCGRAWINFO = 0x80084803 + HIDIOCGRDESC = 0x90044802 + HIDIOCGRDESCSIZE = 0x80044801 HUPCL = 0x400 ICANON = 0x2 IEXTEN = 0x8000 @@ -163,6 +167,7 @@ const ( PERF_EVENT_IOC_SET_OUTPUT = 0x2405 PPPIOCATTACH = 0x4004743d PPPIOCATTCHAN = 0x40047438 + PPPIOCBRIDGECHAN = 0x40047435 PPPIOCCONNECT = 0x4004743a PPPIOCDETACH = 0x4004743c PPPIOCDISCONN = 0x7439 @@ -190,6 +195,7 @@ const ( PPPIOCSPASS = 0x40107447 PPPIOCSRASYNCMAP = 0x40047454 PPPIOCSXASYNCMAP = 0x4020744f + PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCXFERUNIT = 0x744e PR_SET_PTRACER_ANY = 0xffffffffffffffff PTRACE_DISABLE_TE = 0x5010 @@ -329,6 +335,7 @@ const ( SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe SO_BUSY_POLL = 0x2e + SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 SO_COOKIE = 0x39 SO_DETACH_REUSEPORT_BPF = 0x44 @@ -351,6 +358,7 @@ const ( SO_PEERCRED = 0x11 SO_PEERGROUPS = 0x3b SO_PEERSEC = 0x1f + SO_PREFER_BUSY_POLL = 0x45 SO_PROTOCOL = 0x26 SO_RCVBUF = 0x8 SO_RCVBUFFORCE = 0x21 @@ -541,6 +549,9 @@ const ( WORDSIZE = 0x40 XCASE = 0x4 XTABS = 0x1800 + _HIDIOCGRAWNAME = 0x80804804 + _HIDIOCGRAWPHYS = 0x80404805 + _HIDIOCGRAWUNIQ = 0x80404808 ) // Errors diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index 79fbafbcf6c..d5e2dc94faa 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -1,10 +1,11 @@ // mkerrors.sh -Wall -Werror -static -I/tmp/include // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build sparc64 && linux // +build sparc64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go package unix @@ -96,6 +97,9 @@ const ( F_SETOWN = 0x6 F_UNLCK = 0x3 F_WRLCK = 0x2 + HIDIOCGRAWINFO = 0x40084803 + HIDIOCGRDESC = 0x50044802 + HIDIOCGRDESCSIZE = 0x40044801 HUPCL = 0x400 ICANON = 0x2 IEXTEN = 0x8000 @@ -168,6 +172,7 @@ const ( PERF_EVENT_IOC_SET_OUTPUT = 0x20002405 PPPIOCATTACH = 0x8004743d PPPIOCATTCHAN = 0x80047438 + PPPIOCBRIDGECHAN = 0x80047435 PPPIOCCONNECT = 0x8004743a PPPIOCDETACH = 0x8004743c PPPIOCDISCONN = 0x20007439 @@ -195,6 +200,7 @@ const ( PPPIOCSPASS = 0x80107447 PPPIOCSRASYNCMAP = 0x80047454 PPPIOCSXASYNCMAP = 0x8020744f + PPPIOCUNBRIDGECHAN = 0x20007434 PPPIOCXFERUNIT = 0x2000744e PR_SET_PTRACER_ANY = 0xffffffffffffffff PTRACE_GETFPAREGS = 0x14 @@ -322,6 +328,7 @@ const ( SO_BROADCAST = 0x20 SO_BSDCOMPAT = 0x400 SO_BUSY_POLL = 0x30 + SO_BUSY_POLL_BUDGET = 0x49 SO_CNX_ADVICE = 0x37 SO_COOKIE = 0x3b SO_DETACH_REUSEPORT_BPF = 0x47 @@ -344,6 +351,7 @@ const ( SO_PEERCRED = 0x40 SO_PEERGROUPS = 0x3d SO_PEERSEC = 0x1e + SO_PREFER_BUSY_POLL = 0x48 SO_PROTOCOL = 0x1028 SO_RCVBUF = 0x1002 SO_RCVBUFFORCE = 0x100b @@ -531,6 +539,9 @@ const ( WORDSIZE = 0x40 XCASE = 0x4 XTABS = 0x1800 + _HIDIOCGRAWNAME = 0x40804804 + _HIDIOCGRAWPHYS = 0x40404805 + _HIDIOCGRAWUNIQ = 0x40404808 __TIOCFLUSH = 0x80047410 ) diff --git a/vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go b/vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go index 20f3a5799fd..72f7420d20a 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go @@ -1,6 +1,7 @@ // mkerrors.sh -m32 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build 386 && netbsd // +build 386,netbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. diff --git a/vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go index 90b8fcd29c5..8d4eb0c0804 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go @@ -1,6 +1,7 @@ // mkerrors.sh -m64 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && netbsd // +build amd64,netbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. diff --git a/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go b/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go index c5c03993b67..9eef9749f6a 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go @@ -1,6 +1,7 @@ // mkerrors.sh -marm // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm && netbsd // +build arm,netbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. diff --git a/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm64.go index 14dd3c1d1ee..3b62ba192c3 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm64.go @@ -1,6 +1,7 @@ // mkerrors.sh -m64 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm64 && netbsd // +build arm64,netbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go index c865a10df44..593cc0feffa 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go @@ -1,6 +1,7 @@ // mkerrors.sh -m32 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build 386 && openbsd // +build 386,openbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go index 9db6b2fb6e2..25cb6094813 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go @@ -1,6 +1,7 @@ // mkerrors.sh -m64 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && openbsd // +build amd64,openbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go index 7072526a640..a4e4c22314e 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go @@ -1,6 +1,7 @@ // mkerrors.sh // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm && openbsd // +build arm,openbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm64.go index ac5efbe5ac7..90de7dfc33a 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm64.go @@ -1,6 +1,7 @@ // mkerrors.sh -m64 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm64 && openbsd // +build arm64,openbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_mips64.go index a74639a46fb..f1154ff56f6 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_mips64.go @@ -1,6 +1,7 @@ // mkerrors.sh -m64 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build mips64 && openbsd // +build mips64,openbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. diff --git a/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go index 5312c36cc82..65fb2c5cd83 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go @@ -1,6 +1,7 @@ // mkerrors.sh -m64 // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && solaris // +build amd64,solaris // Code generated by cmd/cgo -godefs; DO NOT EDIT. diff --git a/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go new file mode 100644 index 00000000000..4117ce08a50 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go @@ -0,0 +1,831 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build zos && s390x +// +build zos,s390x + +// Hand edited based on zerrors_linux_s390x.go +// TODO: auto-generate. + +package unix + +const ( + BRKINT = 0x0001 + CLOCK_MONOTONIC = 0x1 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_THREAD_CPUTIME_ID = 0x3 + CS8 = 0x0030 + CSIZE = 0x0030 + ECHO = 0x00000008 + ECHONL = 0x00000001 + FD_CLOEXEC = 0x01 + FD_CLOFORK = 0x02 + FNDELAY = 0x04 + F_CLOSFD = 9 + F_CONTROL_CVT = 13 + F_DUPFD = 0 + F_DUPFD2 = 8 + F_GETFD = 1 + F_GETFL = 259 + F_GETLK = 5 + F_GETOWN = 10 + F_OK = 0x0 + F_RDLCK = 1 + F_SETFD = 2 + F_SETFL = 4 + F_SETLK = 6 + F_SETLKW = 7 + F_SETOWN = 11 + F_SETTAG = 12 + F_UNLCK = 3 + F_WRLCK = 2 + FSTYPE_ZFS = 0xe9 //"Z" + FSTYPE_HFS = 0xc8 //"H" + FSTYPE_NFS = 0xd5 //"N" + FSTYPE_TFS = 0xe3 //"T" + FSTYPE_AUTOMOUNT = 0xc1 //"A" + IP6F_MORE_FRAG = 0x0001 + IP6F_OFF_MASK = 0xfff8 + IP6F_RESERVED_MASK = 0x0006 + IP6OPT_JUMBO = 0xc2 + IP6OPT_JUMBO_LEN = 6 + IP6OPT_MUTABLE = 0x20 + IP6OPT_NSAP_ADDR = 0xc3 + IP6OPT_PAD1 = 0x00 + IP6OPT_PADN = 0x01 + IP6OPT_ROUTER_ALERT = 0x05 + IP6OPT_TUNNEL_LIMIT = 0x04 + IP6OPT_TYPE_DISCARD = 0x40 + IP6OPT_TYPE_FORCEICMP = 0x80 + IP6OPT_TYPE_ICMP = 0xc0 + IP6OPT_TYPE_SKIP = 0x00 + IP6_ALERT_AN = 0x0002 + IP6_ALERT_MLD = 0x0000 + IP6_ALERT_RSVP = 0x0001 + IPPORT_RESERVED = 1024 + IPPORT_USERRESERVED = 5000 + IPPROTO_AH = 51 + IPPROTO_DSTOPTS = 60 + IPPROTO_EGP = 8 + IPPROTO_ESP = 50 + IPPROTO_FRAGMENT = 44 + IPPROTO_GGP = 2 + IPPROTO_HOPOPTS = 0 + IPPROTO_ICMP = 1 + IPPROTO_ICMPV6 = 58 + IPPROTO_IDP = 22 + IPPROTO_IP = 0 + IPPROTO_IPV6 = 41 + IPPROTO_MAX = 256 + IPPROTO_NONE = 59 + IPPROTO_PUP = 12 + IPPROTO_RAW = 255 + IPPROTO_ROUTING = 43 + IPPROTO_TCP = 6 + IPPROTO_UDP = 17 + IPV6_ADDR_PREFERENCES = 32 + IPV6_CHECKSUM = 19 + IPV6_DONTFRAG = 29 + IPV6_DSTOPTS = 23 + IPV6_HOPLIMIT = 11 + IPV6_HOPOPTS = 22 + IPV6_JOIN_GROUP = 5 + IPV6_LEAVE_GROUP = 6 + IPV6_MULTICAST_HOPS = 9 + IPV6_MULTICAST_IF = 7 + IPV6_MULTICAST_LOOP = 4 + IPV6_NEXTHOP = 20 + IPV6_PATHMTU = 12 + IPV6_PKTINFO = 13 + IPV6_PREFER_SRC_CGA = 0x10 + IPV6_PREFER_SRC_COA = 0x02 + IPV6_PREFER_SRC_HOME = 0x01 + IPV6_PREFER_SRC_NONCGA = 0x20 + IPV6_PREFER_SRC_PUBLIC = 0x08 + IPV6_PREFER_SRC_TMP = 0x04 + IPV6_RECVDSTOPTS = 28 + IPV6_RECVHOPLIMIT = 14 + IPV6_RECVHOPOPTS = 26 + IPV6_RECVPATHMTU = 16 + IPV6_RECVPKTINFO = 15 + IPV6_RECVRTHDR = 25 + IPV6_RECVTCLASS = 31 + IPV6_RTHDR = 21 + IPV6_RTHDRDSTOPTS = 24 + IPV6_RTHDR_TYPE_0 = 0 + IPV6_TCLASS = 30 + IPV6_UNICAST_HOPS = 3 + IPV6_USE_MIN_MTU = 18 + IPV6_V6ONLY = 10 + IP_ADD_MEMBERSHIP = 5 + IP_ADD_SOURCE_MEMBERSHIP = 12 + IP_BLOCK_SOURCE = 10 + IP_DEFAULT_MULTICAST_LOOP = 1 + IP_DEFAULT_MULTICAST_TTL = 1 + IP_DROP_MEMBERSHIP = 6 + IP_DROP_SOURCE_MEMBERSHIP = 13 + IP_MAX_MEMBERSHIPS = 20 + IP_MULTICAST_IF = 7 + IP_MULTICAST_LOOP = 4 + IP_MULTICAST_TTL = 3 + IP_OPTIONS = 1 + IP_PKTINFO = 101 + IP_RECVPKTINFO = 102 + IP_TOS = 2 + IP_TTL = 3 + IP_UNBLOCK_SOURCE = 11 + ICANON = 0x0010 + ICRNL = 0x0002 + IEXTEN = 0x0020 + IGNBRK = 0x0004 + IGNCR = 0x0008 + INLCR = 0x0020 + ISIG = 0x0040 + ISTRIP = 0x0080 + IXON = 0x0200 + IXOFF = 0x0100 + LOCK_SH = 0x1 // Not exist on zOS + LOCK_EX = 0x2 // Not exist on zOS + LOCK_NB = 0x4 // Not exist on zOS + LOCK_UN = 0x8 // Not exist on zOS + POLLIN = 0x0003 + POLLOUT = 0x0004 + POLLPRI = 0x0010 + POLLERR = 0x0020 + POLLHUP = 0x0040 + POLLNVAL = 0x0080 + PROT_READ = 0x1 // mmap - page can be read + PROT_WRITE = 0x2 // page can be written + PROT_NONE = 0x4 // can't be accessed + PROT_EXEC = 0x8 // can be executed + MAP_PRIVATE = 0x1 // changes are private + MAP_SHARED = 0x2 // changes are shared + MAP_FIXED = 0x4 // place exactly + MS_SYNC = 0x1 // msync - synchronous writes + MS_ASYNC = 0x2 // asynchronous writes + MS_INVALIDATE = 0x4 // invalidate mappings + MTM_RDONLY = 0x80000000 + MTM_RDWR = 0x40000000 + MTM_UMOUNT = 0x10000000 + MTM_IMMED = 0x08000000 + MTM_FORCE = 0x04000000 + MTM_DRAIN = 0x02000000 + MTM_RESET = 0x01000000 + MTM_SAMEMODE = 0x00100000 + MTM_UNQSEFORCE = 0x00040000 + MTM_NOSUID = 0x00000400 + MTM_SYNCHONLY = 0x00000200 + MTM_REMOUNT = 0x00000100 + MTM_NOSECURITY = 0x00000080 + O_ACCMODE = 0x03 + O_APPEND = 0x08 + O_ASYNCSIG = 0x0200 + O_CREAT = 0x80 + O_EXCL = 0x40 + O_GETFL = 0x0F + O_LARGEFILE = 0x0400 + O_NONBLOCK = 0x04 + O_RDONLY = 0x02 + O_RDWR = 0x03 + O_SYNC = 0x0100 + O_TRUNC = 0x10 + O_WRONLY = 0x01 + O_NOCTTY = 0x20 + OPOST = 0x0001 + ONLCR = 0x0004 + PARENB = 0x0200 + PARMRK = 0x0400 + QUERYCVT = 3 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 // RUSAGE_THREAD unsupported on z/OS + SEEK_CUR = 1 + SEEK_END = 2 + SEEK_SET = 0 + SETAUTOCVTALL = 5 + SETAUTOCVTON = 2 + SETCVTALL = 4 + SETCVTOFF = 0 + SETCVTON = 1 + AF_APPLETALK = 16 + AF_CCITT = 10 + AF_CHAOS = 5 + AF_DATAKIT = 9 + AF_DLI = 13 + AF_ECMA = 8 + AF_HYLINK = 15 + AF_IMPLINK = 3 + AF_INET = 2 + AF_INET6 = 19 + AF_INTF = 20 + AF_IUCV = 17 + AF_LAT = 14 + AF_LINK = 18 + AF_MAX = 30 + AF_NBS = 7 + AF_NDD = 23 + AF_NETWARE = 22 + AF_NS = 6 + AF_PUP = 4 + AF_RIF = 21 + AF_ROUTE = 20 + AF_SNA = 11 + AF_UNIX = 1 + AF_UNSPEC = 0 + IBMTCP_IMAGE = 1 + MSG_ACK_EXPECTED = 0x10 + MSG_ACK_GEN = 0x40 + MSG_ACK_TIMEOUT = 0x20 + MSG_CONNTERM = 0x80 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_EOF = 0x8000 + MSG_EOR = 0x8 + MSG_MAXIOVLEN = 16 + MSG_NONBLOCK = 0x4000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + PRIO_PROCESS = 1 + PRIO_PGRP = 2 + PRIO_USER = 3 + RLIMIT_CPU = 0 + RLIMIT_FSIZE = 1 + RLIMIT_DATA = 2 + RLIMIT_STACK = 3 + RLIMIT_CORE = 4 + RLIMIT_AS = 5 + RLIMIT_NOFILE = 6 + RLIMIT_MEMLIMIT = 7 + RLIM_INFINITY = 2147483647 + SCM_RIGHTS = 0x01 + SF_CLOSE = 0x00000002 + SF_REUSE = 0x00000001 + SHUT_RD = 0 + SHUT_RDWR = 2 + SHUT_WR = 1 + SOCK_CONN_DGRAM = 6 + SOCK_DGRAM = 2 + SOCK_RAW = 3 + SOCK_RDM = 4 + SOCK_SEQPACKET = 5 + SOCK_STREAM = 1 + SOL_SOCKET = 0xffff + SOMAXCONN = 10 + SO_ACCEPTCONN = 0x0002 + SO_ACCEPTECONNABORTED = 0x0006 + SO_ACKNOW = 0x7700 + SO_BROADCAST = 0x0020 + SO_BULKMODE = 0x8000 + SO_CKSUMRECV = 0x0800 + SO_CLOSE = 0x01 + SO_CLUSTERCONNTYPE = 0x00004001 + SO_CLUSTERCONNTYPE_INTERNAL = 8 + SO_CLUSTERCONNTYPE_NOCONN = 0 + SO_CLUSTERCONNTYPE_NONE = 1 + SO_CLUSTERCONNTYPE_SAME_CLUSTER = 2 + SO_CLUSTERCONNTYPE_SAME_IMAGE = 4 + SO_DEBUG = 0x0001 + SO_DONTROUTE = 0x0010 + SO_ERROR = 0x1007 + SO_IGNOREINCOMINGPUSH = 0x1 + SO_IGNORESOURCEVIPA = 0x0002 + SO_KEEPALIVE = 0x0008 + SO_LINGER = 0x0080 + SO_NONBLOCKLOCAL = 0x8001 + SO_NOREUSEADDR = 0x1000 + SO_OOBINLINE = 0x0100 + SO_OPTACK = 0x8004 + SO_OPTMSS = 0x8003 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x0004 + SO_REUSEPORT = 0x0200 + SO_SECINFO = 0x00004002 + SO_SET = 0x0200 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_TYPE = 0x1008 + SO_UNSET = 0x0400 + SO_USELOOPBACK = 0x0040 + SO_USE_IFBUFS = 0x0400 + S_ISUID = 0x0800 + S_ISGID = 0x0400 + S_ISVTX = 0x0200 + S_IRUSR = 0x0100 + S_IWUSR = 0x0080 + S_IXUSR = 0x0040 + S_IRWXU = 0x01C0 + S_IRGRP = 0x0020 + S_IWGRP = 0x0010 + S_IXGRP = 0x0008 + S_IRWXG = 0x0038 + S_IROTH = 0x0004 + S_IWOTH = 0x0002 + S_IXOTH = 0x0001 + S_IRWXO = 0x0007 + S_IREAD = S_IRUSR + S_IWRITE = S_IWUSR + S_IEXEC = S_IXUSR + S_IFDIR = 0x01000000 + S_IFCHR = 0x02000000 + S_IFREG = 0x03000000 + S_IFFIFO = 0x04000000 + S_IFIFO = 0x04000000 + S_IFLNK = 0x05000000 + S_IFBLK = 0x06000000 + S_IFSOCK = 0x07000000 + S_IFVMEXTL = 0xFE000000 + S_IFVMEXTL_EXEC = 0x00010000 + S_IFVMEXTL_DATA = 0x00020000 + S_IFVMEXTL_MEL = 0x00030000 + S_IFEXTL = 0x00000001 + S_IFPROGCTL = 0x00000002 + S_IFAPFCTL = 0x00000004 + S_IFNOSHARE = 0x00000008 + S_IFSHARELIB = 0x00000010 + S_IFMT = 0xFF000000 + S_IFMST = 0x00FF0000 + TCP_KEEPALIVE = 0x8 + TCP_NODELAY = 0x1 + TIOCGWINSZ = 0x4008a368 + TIOCSWINSZ = 0x8008a367 + TIOCSBRK = 0x2000a77b + TIOCCBRK = 0x2000a77a + TIOCSTI = 0x8001a772 + TIOCGPGRP = 0x4004a777 // _IOR(167, 119, int) + TCSANOW = 0 + TCSETS = 0 // equivalent to TCSANOW for tcsetattr + TCSADRAIN = 1 + TCSETSW = 1 // equivalent to TCSADRAIN for tcsetattr + TCSAFLUSH = 2 + TCSETSF = 2 // equivalent to TCSAFLUSH for tcsetattr + TCGETS = 3 // not defined in ioctl.h -- zos golang only + TCIFLUSH = 0 + TCOFLUSH = 1 + TCIOFLUSH = 2 + TCOOFF = 0 + TCOON = 1 + TCIOFF = 2 + TCION = 3 + TIOCSPGRP = 0x8004a776 + TIOCNOTTY = 0x2000a771 + TIOCEXCL = 0x2000a70d + TIOCNXCL = 0x2000a70e + TIOCGETD = 0x4004a700 + TIOCSETD = 0x8004a701 + TIOCPKT = 0x8004a770 + TIOCSTOP = 0x2000a76f + TIOCSTART = 0x2000a76e + TIOCUCNTL = 0x8004a766 + TIOCREMOTE = 0x8004a769 + TIOCMGET = 0x4004a76a + TIOCMSET = 0x8004a76d + TIOCMBIC = 0x8004a76b + TIOCMBIS = 0x8004a76c + VINTR = 0 + VQUIT = 1 + VERASE = 2 + VKILL = 3 + VEOF = 4 + VEOL = 5 + VMIN = 6 + VSTART = 7 + VSTOP = 8 + VSUSP = 9 + VTIME = 10 + WCONTINUED = 0x4 + WNOHANG = 0x1 + WUNTRACED = 0x2 + _BPX_SWAP = 1 + _BPX_NONSWAP = 2 + MCL_CURRENT = 1 // for Linux compatibility -- no zos semantics + MCL_FUTURE = 2 // for Linux compatibility -- no zos semantics + MCL_ONFAULT = 3 // for Linux compatibility -- no zos semantics + MADV_NORMAL = 0 // for Linux compatibility -- no zos semantics + MADV_RANDOM = 1 // for Linux compatibility -- no zos semantics + MADV_SEQUENTIAL = 2 // for Linux compatibility -- no zos semantics + MADV_WILLNEED = 3 // for Linux compatibility -- no zos semantics + MADV_REMOVE = 4 // for Linux compatibility -- no zos semantics + MADV_DONTFORK = 5 // for Linux compatibility -- no zos semantics + MADV_DOFORK = 6 // for Linux compatibility -- no zos semantics + MADV_HWPOISON = 7 // for Linux compatibility -- no zos semantics + MADV_MERGEABLE = 8 // for Linux compatibility -- no zos semantics + MADV_UNMERGEABLE = 9 // for Linux compatibility -- no zos semantics + MADV_SOFT_OFFLINE = 10 // for Linux compatibility -- no zos semantics + MADV_HUGEPAGE = 11 // for Linux compatibility -- no zos semantics + MADV_NOHUGEPAGE = 12 // for Linux compatibility -- no zos semantics + MADV_DONTDUMP = 13 // for Linux compatibility -- no zos semantics + MADV_DODUMP = 14 // for Linux compatibility -- no zos semantics + MADV_FREE = 15 // for Linux compatibility -- no zos semantics + MADV_WIPEONFORK = 16 // for Linux compatibility -- no zos semantics + MADV_KEEPONFORK = 17 // for Linux compatibility -- no zos semantics + AT_SYMLINK_NOFOLLOW = 1 // for Unix compatibility -- no zos semantics + AT_FDCWD = 2 // for Unix compatibility -- no zos semantics +) + +const ( + EDOM = Errno(1) + ERANGE = Errno(2) + EACCES = Errno(111) + EAGAIN = Errno(112) + EBADF = Errno(113) + EBUSY = Errno(114) + ECHILD = Errno(115) + EDEADLK = Errno(116) + EEXIST = Errno(117) + EFAULT = Errno(118) + EFBIG = Errno(119) + EINTR = Errno(120) + EINVAL = Errno(121) + EIO = Errno(122) + EISDIR = Errno(123) + EMFILE = Errno(124) + EMLINK = Errno(125) + ENAMETOOLONG = Errno(126) + ENFILE = Errno(127) + ENODEV = Errno(128) + ENOENT = Errno(129) + ENOEXEC = Errno(130) + ENOLCK = Errno(131) + ENOMEM = Errno(132) + ENOSPC = Errno(133) + ENOSYS = Errno(134) + ENOTDIR = Errno(135) + ENOTEMPTY = Errno(136) + ENOTTY = Errno(137) + ENXIO = Errno(138) + EPERM = Errno(139) + EPIPE = Errno(140) + EROFS = Errno(141) + ESPIPE = Errno(142) + ESRCH = Errno(143) + EXDEV = Errno(144) + E2BIG = Errno(145) + ELOOP = Errno(146) + EILSEQ = Errno(147) + ENODATA = Errno(148) + EOVERFLOW = Errno(149) + EMVSNOTUP = Errno(150) + ECMSSTORAGE = Errno(151) + EMVSDYNALC = Errno(151) + EMVSCVAF = Errno(152) + EMVSCATLG = Errno(153) + ECMSINITIAL = Errno(156) + EMVSINITIAL = Errno(156) + ECMSERR = Errno(157) + EMVSERR = Errno(157) + EMVSPARM = Errno(158) + ECMSPFSFILE = Errno(159) + EMVSPFSFILE = Errno(159) + EMVSBADCHAR = Errno(160) + ECMSPFSPERM = Errno(162) + EMVSPFSPERM = Errno(162) + EMVSSAFEXTRERR = Errno(163) + EMVSSAF2ERR = Errno(164) + EMVSTODNOTSET = Errno(165) + EMVSPATHOPTS = Errno(166) + EMVSNORTL = Errno(167) + EMVSEXPIRE = Errno(168) + EMVSPASSWORD = Errno(169) + EMVSWLMERROR = Errno(170) + EMVSCPLERROR = Errno(171) + EMVSARMERROR = Errno(172) + ELENOFORK = Errno(200) + ELEMSGERR = Errno(201) + EFPMASKINV = Errno(202) + EFPMODEINV = Errno(203) + EBUFLEN = Errno(227) + EEXTLINK = Errno(228) + ENODD = Errno(229) + ECMSESMERR = Errno(230) + ECPERR = Errno(231) + ELEMULTITHREAD = Errno(232) + ELEFENCE = Errno(244) + EBADDATA = Errno(245) + EUNKNOWN = Errno(246) + ENOTSUP = Errno(247) + EBADNAME = Errno(248) + ENOTSAFE = Errno(249) + ELEMULTITHREADFORK = Errno(257) + ECUNNOENV = Errno(258) + ECUNNOCONV = Errno(259) + ECUNNOTALIGNED = Errno(260) + ECUNERR = Errno(262) + EIBMBADCALL = Errno(1000) + EIBMBADPARM = Errno(1001) + EIBMSOCKOUTOFRANGE = Errno(1002) + EIBMSOCKINUSE = Errno(1003) + EIBMIUCVERR = Errno(1004) + EOFFLOADboxERROR = Errno(1005) + EOFFLOADboxRESTART = Errno(1006) + EOFFLOADboxDOWN = Errno(1007) + EIBMCONFLICT = Errno(1008) + EIBMCANCELLED = Errno(1009) + EIBMBADTCPNAME = Errno(1011) + ENOTBLK = Errno(1100) + ETXTBSY = Errno(1101) + EWOULDBLOCK = Errno(1102) + EINPROGRESS = Errno(1103) + EALREADY = Errno(1104) + ENOTSOCK = Errno(1105) + EDESTADDRREQ = Errno(1106) + EMSGSIZE = Errno(1107) + EPROTOTYPE = Errno(1108) + ENOPROTOOPT = Errno(1109) + EPROTONOSUPPORT = Errno(1110) + ESOCKTNOSUPPORT = Errno(1111) + EOPNOTSUPP = Errno(1112) + EPFNOSUPPORT = Errno(1113) + EAFNOSUPPORT = Errno(1114) + EADDRINUSE = Errno(1115) + EADDRNOTAVAIL = Errno(1116) + ENETDOWN = Errno(1117) + ENETUNREACH = Errno(1118) + ENETRESET = Errno(1119) + ECONNABORTED = Errno(1120) + ECONNRESET = Errno(1121) + ENOBUFS = Errno(1122) + EISCONN = Errno(1123) + ENOTCONN = Errno(1124) + ESHUTDOWN = Errno(1125) + ETOOMANYREFS = Errno(1126) + ETIMEDOUT = Errno(1127) + ECONNREFUSED = Errno(1128) + EHOSTDOWN = Errno(1129) + EHOSTUNREACH = Errno(1130) + EPROCLIM = Errno(1131) + EUSERS = Errno(1132) + EDQUOT = Errno(1133) + ESTALE = Errno(1134) + EREMOTE = Errno(1135) + ENOSTR = Errno(1136) + ETIME = Errno(1137) + ENOSR = Errno(1138) + ENOMSG = Errno(1139) + EBADMSG = Errno(1140) + EIDRM = Errno(1141) + ENONET = Errno(1142) + ERREMOTE = Errno(1143) + ENOLINK = Errno(1144) + EADV = Errno(1145) + ESRMNT = Errno(1146) + ECOMM = Errno(1147) + EPROTO = Errno(1148) + EMULTIHOP = Errno(1149) + EDOTDOT = Errno(1150) + EREMCHG = Errno(1151) + ECANCELED = Errno(1152) + EINTRNODATA = Errno(1159) + ENOREUSE = Errno(1160) + ENOMOVE = Errno(1161) +) + +// Signals +const ( + SIGHUP = Signal(1) + SIGINT = Signal(2) + SIGABRT = Signal(3) + SIGILL = Signal(4) + SIGPOLL = Signal(5) + SIGURG = Signal(6) + SIGSTOP = Signal(7) + SIGFPE = Signal(8) + SIGKILL = Signal(9) + SIGBUS = Signal(10) + SIGSEGV = Signal(11) + SIGSYS = Signal(12) + SIGPIPE = Signal(13) + SIGALRM = Signal(14) + SIGTERM = Signal(15) + SIGUSR1 = Signal(16) + SIGUSR2 = Signal(17) + SIGABND = Signal(18) + SIGCONT = Signal(19) + SIGCHLD = Signal(20) + SIGTTIN = Signal(21) + SIGTTOU = Signal(22) + SIGIO = Signal(23) + SIGQUIT = Signal(24) + SIGTSTP = Signal(25) + SIGTRAP = Signal(26) + SIGIOERR = Signal(27) + SIGWINCH = Signal(28) + SIGXCPU = Signal(29) + SIGXFSZ = Signal(30) + SIGVTALRM = Signal(31) + SIGPROF = Signal(32) + SIGDANGER = Signal(33) + SIGTHSTOP = Signal(34) + SIGTHCONT = Signal(35) + SIGTRACE = Signal(37) + SIGDCE = Signal(38) + SIGDUMP = Signal(39) +) + +// Error table +var errorList = [...]struct { + num Errno + name string + desc string +}{ + {1, "EDC5001I", "A domain error occurred."}, + {2, "EDC5002I", "A range error occurred."}, + {111, "EDC5111I", "Permission denied."}, + {112, "EDC5112I", "Resource temporarily unavailable."}, + {113, "EDC5113I", "Bad file descriptor."}, + {114, "EDC5114I", "Resource busy."}, + {115, "EDC5115I", "No child processes."}, + {116, "EDC5116I", "Resource deadlock avoided."}, + {117, "EDC5117I", "File exists."}, + {118, "EDC5118I", "Incorrect address."}, + {119, "EDC5119I", "File too large."}, + {120, "EDC5120I", "Interrupted function call."}, + {121, "EDC5121I", "Invalid argument."}, + {122, "EDC5122I", "Input/output error."}, + {123, "EDC5123I", "Is a directory."}, + {124, "EDC5124I", "Too many open files."}, + {125, "EDC5125I", "Too many links."}, + {126, "EDC5126I", "Filename too long."}, + {127, "EDC5127I", "Too many open files in system."}, + {128, "EDC5128I", "No such device."}, + {129, "EDC5129I", "No such file or directory."}, + {130, "EDC5130I", "Exec format error."}, + {131, "EDC5131I", "No locks available."}, + {132, "EDC5132I", "Not enough memory."}, + {133, "EDC5133I", "No space left on device."}, + {134, "EDC5134I", "Function not implemented."}, + {135, "EDC5135I", "Not a directory."}, + {136, "EDC5136I", "Directory not empty."}, + {137, "EDC5137I", "Inappropriate I/O control operation."}, + {138, "EDC5138I", "No such device or address."}, + {139, "EDC5139I", "Operation not permitted."}, + {140, "EDC5140I", "Broken pipe."}, + {141, "EDC5141I", "Read-only file system."}, + {142, "EDC5142I", "Invalid seek."}, + {143, "EDC5143I", "No such process."}, + {144, "EDC5144I", "Improper link."}, + {145, "EDC5145I", "The parameter list is too long, or the message to receive was too large for the buffer."}, + {146, "EDC5146I", "Too many levels of symbolic links."}, + {147, "EDC5147I", "Illegal byte sequence."}, + {148, "", ""}, + {149, "EDC5149I", "Value Overflow Error."}, + {150, "EDC5150I", "UNIX System Services is not active."}, + {151, "EDC5151I", "Dynamic allocation error."}, + {152, "EDC5152I", "Common VTOC access facility (CVAF) error."}, + {153, "EDC5153I", "Catalog obtain error."}, + {156, "EDC5156I", "Process initialization error."}, + {157, "EDC5157I", "An internal error has occurred."}, + {158, "EDC5158I", "Bad parameters were passed to the service."}, + {159, "EDC5159I", "The Physical File System encountered a permanent file error."}, + {160, "EDC5160I", "Bad character in environment variable name."}, + {162, "EDC5162I", "The Physical File System encountered a system error."}, + {163, "EDC5163I", "SAF/RACF extract error."}, + {164, "EDC5164I", "SAF/RACF error."}, + {165, "EDC5165I", "System TOD clock not set."}, + {166, "EDC5166I", "Access mode argument on function call conflicts with PATHOPTS parameter on JCL DD statement."}, + {167, "EDC5167I", "Access to the UNIX System Services version of the C RTL is denied."}, + {168, "EDC5168I", "Password has expired."}, + {169, "EDC5169I", "Password is invalid."}, + {170, "EDC5170I", "An error was encountered with WLM."}, + {171, "EDC5171I", "An error was encountered with CPL."}, + {172, "EDC5172I", "An error was encountered with Application Response Measurement (ARM) component."}, + {200, "EDC5200I", "The application contains a Language Environment member language that cannot tolerate a fork()."}, + {201, "EDC5201I", "The Language Environment message file was not found in the hierarchical file system."}, + {202, "EDC5202E", "DLL facilities are not supported under SPC environment."}, + {203, "EDC5203E", "DLL facilities are not supported under POSIX environment."}, + {227, "EDC5227I", "Buffer is not long enough to contain a path definition"}, + {228, "EDC5228I", "The file referred to is an external link"}, + {229, "EDC5229I", "No path definition for ddname in effect"}, + {230, "EDC5230I", "ESM error."}, + {231, "EDC5231I", "CP or the external security manager had an error"}, + {232, "EDC5232I", "The function failed because it was invoked from a multithread environment."}, + {244, "EDC5244I", "The program, module or DLL is not supported in this environment."}, + {245, "EDC5245I", "Data is not valid."}, + {246, "EDC5246I", "Unknown system state."}, + {247, "EDC5247I", "Operation not supported."}, + {248, "EDC5248I", "The object name specified is not correct."}, + {249, "EDC5249I", "The function is not allowed."}, + {257, "EDC5257I", "Function cannot be called in the child process of a fork() from a multithreaded process until exec() is called."}, + {258, "EDC5258I", "A CUN_RS_NO_UNI_ENV error was issued by Unicode Services."}, + {259, "EDC5259I", "A CUN_RS_NO_CONVERSION error was issued by Unicode Services."}, + {260, "EDC5260I", "A CUN_RS_TABLE_NOT_ALIGNED error was issued by Unicode Services."}, + {262, "EDC5262I", "An iconv() function encountered an unexpected error while using Unicode Services."}, + {1000, "EDC8000I", "A bad socket-call constant was found in the IUCV header."}, + {1001, "EDC8001I", "An error was found in the IUCV header."}, + {1002, "EDC8002I", "A socket descriptor is out of range."}, + {1003, "EDC8003I", "A socket descriptor is in use."}, + {1004, "EDC8004I", "Request failed because of an IUCV error."}, + {1005, "EDC8005I", "Offload box error."}, + {1006, "EDC8006I", "Offload box restarted."}, + {1007, "EDC8007I", "Offload box down."}, + {1008, "EDC8008I", "Already a conflicting call outstanding on socket."}, + {1009, "EDC8009I", "Request cancelled using a SOCKcallCANCEL request."}, + {1011, "EDC8011I", "A name of a PFS was specified that either is not configured or is not a Sockets PFS."}, + {1100, "EDC8100I", "Block device required."}, + {1101, "EDC8101I", "Text file busy."}, + {1102, "EDC8102I", "Operation would block."}, + {1103, "EDC8103I", "Operation now in progress."}, + {1104, "EDC8104I", "Connection already in progress."}, + {1105, "EDC8105I", "Socket operation on non-socket."}, + {1106, "EDC8106I", "Destination address required."}, + {1107, "EDC8107I", "Message too long."}, + {1108, "EDC8108I", "Protocol wrong type for socket."}, + {1109, "EDC8109I", "Protocol not available."}, + {1110, "EDC8110I", "Protocol not supported."}, + {1111, "EDC8111I", "Socket type not supported."}, + {1112, "EDC8112I", "Operation not supported on socket."}, + {1113, "EDC8113I", "Protocol family not supported."}, + {1114, "EDC8114I", "Address family not supported."}, + {1115, "EDC8115I", "Address already in use."}, + {1116, "EDC8116I", "Address not available."}, + {1117, "EDC8117I", "Network is down."}, + {1118, "EDC8118I", "Network is unreachable."}, + {1119, "EDC8119I", "Network dropped connection on reset."}, + {1120, "EDC8120I", "Connection ended abnormally."}, + {1121, "EDC8121I", "Connection reset."}, + {1122, "EDC8122I", "No buffer space available."}, + {1123, "EDC8123I", "Socket already connected."}, + {1124, "EDC8124I", "Socket not connected."}, + {1125, "EDC8125I", "Can't send after socket shutdown."}, + {1126, "EDC8126I", "Too many references; can't splice."}, + {1127, "EDC8127I", "Connection timed out."}, + {1128, "EDC8128I", "Connection refused."}, + {1129, "EDC8129I", "Host is not available."}, + {1130, "EDC8130I", "Host cannot be reached."}, + {1131, "EDC8131I", "Too many processes."}, + {1132, "EDC8132I", "Too many users."}, + {1133, "EDC8133I", "Disk quota exceeded."}, + {1134, "EDC8134I", "Stale file handle."}, + {1135, "", ""}, + {1136, "EDC8136I", "File is not a STREAM."}, + {1137, "EDC8137I", "STREAMS ioctl() timeout."}, + {1138, "EDC8138I", "No STREAMS resources."}, + {1139, "EDC8139I", "The message identified by set_id and msg_id is not in the message catalog."}, + {1140, "EDC8140I", "Bad message."}, + {1141, "EDC8141I", "Identifier removed."}, + {1142, "", ""}, + {1143, "", ""}, + {1144, "EDC8144I", "The link has been severed."}, + {1145, "", ""}, + {1146, "", ""}, + {1147, "", ""}, + {1148, "EDC8148I", "Protocol error."}, + {1149, "EDC8149I", "Multihop not allowed."}, + {1150, "", ""}, + {1151, "", ""}, + {1152, "EDC8152I", "The asynchronous I/O request has been canceled."}, + {1159, "EDC8159I", "Function call was interrupted before any data was received."}, + {1160, "EDC8160I", "Socket reuse is not supported."}, + {1161, "EDC8161I", "The file system cannot currently be moved."}, +} + +// Signal table +var signalList = [...]struct { + num Signal + name string + desc string +}{ + {1, "SIGHUP", "hangup"}, + {2, "SIGINT", "interrupt"}, + {3, "SIGABT", "aborted"}, + {4, "SIGILL", "illegal instruction"}, + {5, "SIGPOLL", "pollable event"}, + {6, "SIGURG", "urgent I/O condition"}, + {7, "SIGSTOP", "stop process"}, + {8, "SIGFPE", "floating point exception"}, + {9, "SIGKILL", "killed"}, + {10, "SIGBUS", "bus error"}, + {11, "SIGSEGV", "segmentation fault"}, + {12, "SIGSYS", "bad argument to routine"}, + {13, "SIGPIPE", "broken pipe"}, + {14, "SIGALRM", "alarm clock"}, + {15, "SIGTERM", "terminated"}, + {16, "SIGUSR1", "user defined signal 1"}, + {17, "SIGUSR2", "user defined signal 2"}, + {18, "SIGABND", "abend"}, + {19, "SIGCONT", "continued"}, + {20, "SIGCHLD", "child exited"}, + {21, "SIGTTIN", "stopped (tty input)"}, + {22, "SIGTTOU", "stopped (tty output)"}, + {23, "SIGIO", "I/O possible"}, + {24, "SIGQUIT", "quit"}, + {25, "SIGTSTP", "stopped"}, + {26, "SIGTRAP", "trace/breakpoint trap"}, + {27, "SIGIOER", "I/O error"}, + {28, "SIGWINCH", "window changed"}, + {29, "SIGXCPU", "CPU time limit exceeded"}, + {30, "SIGXFSZ", "file size limit exceeded"}, + {31, "SIGVTALRM", "virtual timer expired"}, + {32, "SIGPROF", "profiling timer expired"}, + {33, "SIGDANGER", "danger"}, + {34, "SIGTHSTOP", "stop thread"}, + {35, "SIGTHCONT", "continue thread"}, + {37, "SIGTRACE", "trace"}, + {38, "", "DCE"}, + {39, "SIGDUMP", "dump"}, +} diff --git a/vendor/golang.org/x/sys/unix/zptrace_armnn_linux.go b/vendor/golang.org/x/sys/unix/zptrace_armnn_linux.go index 89c5920e0cb..bd001a6e1cc 100644 --- a/vendor/golang.org/x/sys/unix/zptrace_armnn_linux.go +++ b/vendor/golang.org/x/sys/unix/zptrace_armnn_linux.go @@ -1,5 +1,6 @@ // Code generated by linux/mkall.go generatePtracePair("arm", "arm64"). DO NOT EDIT. +//go:build linux && (arm || arm64) // +build linux // +build arm arm64 diff --git a/vendor/golang.org/x/sys/unix/zptrace_mipsnn_linux.go b/vendor/golang.org/x/sys/unix/zptrace_mipsnn_linux.go index 24b841eec50..c34d0639be3 100644 --- a/vendor/golang.org/x/sys/unix/zptrace_mipsnn_linux.go +++ b/vendor/golang.org/x/sys/unix/zptrace_mipsnn_linux.go @@ -1,5 +1,6 @@ // Code generated by linux/mkall.go generatePtracePair("mips", "mips64"). DO NOT EDIT. +//go:build linux && (mips || mips64) // +build linux // +build mips mips64 diff --git a/vendor/golang.org/x/sys/unix/zptrace_mipsnnle_linux.go b/vendor/golang.org/x/sys/unix/zptrace_mipsnnle_linux.go index 47b04895651..3ccf0c0c4a8 100644 --- a/vendor/golang.org/x/sys/unix/zptrace_mipsnnle_linux.go +++ b/vendor/golang.org/x/sys/unix/zptrace_mipsnnle_linux.go @@ -1,5 +1,6 @@ // Code generated by linux/mkall.go generatePtracePair("mipsle", "mips64le"). DO NOT EDIT. +//go:build linux && (mipsle || mips64le) // +build linux // +build mipsle mips64le diff --git a/vendor/golang.org/x/sys/unix/zptrace_x86_linux.go b/vendor/golang.org/x/sys/unix/zptrace_x86_linux.go index ea5d9cb536c..7d65857004c 100644 --- a/vendor/golang.org/x/sys/unix/zptrace_x86_linux.go +++ b/vendor/golang.org/x/sys/unix/zptrace_x86_linux.go @@ -1,5 +1,6 @@ // Code generated by linux/mkall.go generatePtracePair("386", "amd64"). DO NOT EDIT. +//go:build linux && (386 || amd64) // +build linux // +build 386 amd64 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go index ed657ff1bc0..91a23cc7287 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go @@ -1,6 +1,7 @@ // go run mksyscall_aix_ppc.go -aix -tags aix,ppc syscall_aix.go syscall_aix_ppc.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build aix && ppc // +build aix,ppc package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go index 664b293b431..33c2609b8b4 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go @@ -1,6 +1,7 @@ // go run mksyscall_aix_ppc64.go -aix -tags aix,ppc64 syscall_aix.go syscall_aix_ppc64.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build aix && ppc64 // +build aix,ppc64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go index 0550da06d14..8b737fa971e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go @@ -1,8 +1,8 @@ // go run mksyscall_aix_ppc64.go -aix -tags aix,ppc64 syscall_aix.go syscall_aix_ppc64.go // Code generated by the command above; see README.md. DO NOT EDIT. -// +build aix,ppc64 -// +build gc +//go:build aix && ppc64 && gc +// +build aix,ppc64,gc package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go index cde4dbc5f54..3c260917ed5 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go @@ -1,8 +1,8 @@ // go run mksyscall_aix_ppc64.go -aix -tags aix,ppc64 syscall_aix.go syscall_aix_ppc64.go // Code generated by the command above; see README.md. DO NOT EDIT. -// +build aix,ppc64 -// +build gccgo +//go:build aix && ppc64 && gccgo +// +build aix,ppc64,gccgo package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.1_13.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.1_13.go index e263fbdb8bf..48a62e39062 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.1_13.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.1_13.go @@ -1,6 +1,7 @@ // go run mksyscall.go -l32 -tags darwin,386,go1.13 syscall_darwin.1_13.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build darwin && 386 && go1.13 // +build darwin,386,go1.13 package unix @@ -24,7 +25,6 @@ func closedir(dir uintptr) (err error) { func libc_closedir_trampoline() -//go:linkname libc_closedir libc_closedir //go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -37,5 +37,4 @@ func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { func libc_readdir_r_trampoline() -//go:linkname libc_readdir_r libc_readdir_r //go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go index 6eb45798323..a266636af67 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go @@ -1,6 +1,7 @@ // go run mksyscall.go -l32 -tags darwin,386,go1.12 syscall_bsd.go syscall_darwin.go syscall_darwin_386.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build darwin && 386 && go1.12 // +build darwin,386,go1.12 package unix @@ -25,7 +26,6 @@ func getgroups(ngid int, gid *_Gid_t) (n int, err error) { func libc_getgroups_trampoline() -//go:linkname libc_getgroups libc_getgroups //go:cgo_import_dynamic libc_getgroups getgroups "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -40,7 +40,6 @@ func setgroups(ngid int, gid *_Gid_t) (err error) { func libc_setgroups_trampoline() -//go:linkname libc_setgroups libc_setgroups //go:cgo_import_dynamic libc_setgroups setgroups "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -56,7 +55,6 @@ func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err func libc_wait4_trampoline() -//go:linkname libc_wait4 libc_wait4 //go:cgo_import_dynamic libc_wait4 wait4 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -72,7 +70,6 @@ func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { func libc_accept_trampoline() -//go:linkname libc_accept libc_accept //go:cgo_import_dynamic libc_accept accept "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -87,7 +84,6 @@ func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { func libc_bind_trampoline() -//go:linkname libc_bind libc_bind //go:cgo_import_dynamic libc_bind bind "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -102,7 +98,6 @@ func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { func libc_connect_trampoline() -//go:linkname libc_connect libc_connect //go:cgo_import_dynamic libc_connect connect "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -118,7 +113,6 @@ func socket(domain int, typ int, proto int) (fd int, err error) { func libc_socket_trampoline() -//go:linkname libc_socket libc_socket //go:cgo_import_dynamic libc_socket socket "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -133,7 +127,6 @@ func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen func libc_getsockopt_trampoline() -//go:linkname libc_getsockopt libc_getsockopt //go:cgo_import_dynamic libc_getsockopt getsockopt "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -148,7 +141,6 @@ func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) func libc_setsockopt_trampoline() -//go:linkname libc_setsockopt libc_setsockopt //go:cgo_import_dynamic libc_setsockopt setsockopt "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -163,7 +155,6 @@ func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { func libc_getpeername_trampoline() -//go:linkname libc_getpeername libc_getpeername //go:cgo_import_dynamic libc_getpeername getpeername "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -178,7 +169,6 @@ func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { func libc_getsockname_trampoline() -//go:linkname libc_getsockname libc_getsockname //go:cgo_import_dynamic libc_getsockname getsockname "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -193,7 +183,6 @@ func Shutdown(s int, how int) (err error) { func libc_shutdown_trampoline() -//go:linkname libc_shutdown libc_shutdown //go:cgo_import_dynamic libc_shutdown shutdown "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -208,7 +197,6 @@ func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { func libc_socketpair_trampoline() -//go:linkname libc_socketpair libc_socketpair //go:cgo_import_dynamic libc_socketpair socketpair "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -230,7 +218,6 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl func libc_recvfrom_trampoline() -//go:linkname libc_recvfrom libc_recvfrom //go:cgo_import_dynamic libc_recvfrom recvfrom "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -251,7 +238,6 @@ func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) ( func libc_sendto_trampoline() -//go:linkname libc_sendto libc_sendto //go:cgo_import_dynamic libc_sendto sendto "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -267,7 +253,6 @@ func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { func libc_recvmsg_trampoline() -//go:linkname libc_recvmsg libc_recvmsg //go:cgo_import_dynamic libc_recvmsg recvmsg "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -283,7 +268,6 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { func libc_sendmsg_trampoline() -//go:linkname libc_sendmsg libc_sendmsg //go:cgo_import_dynamic libc_sendmsg sendmsg "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -299,7 +283,6 @@ func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, ne func libc_kevent_trampoline() -//go:linkname libc_kevent libc_kevent //go:cgo_import_dynamic libc_kevent kevent "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -319,7 +302,6 @@ func utimes(path string, timeval *[2]Timeval) (err error) { func libc_utimes_trampoline() -//go:linkname libc_utimes libc_utimes //go:cgo_import_dynamic libc_utimes utimes "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -334,7 +316,6 @@ func futimes(fd int, timeval *[2]Timeval) (err error) { func libc_futimes_trampoline() -//go:linkname libc_futimes libc_futimes //go:cgo_import_dynamic libc_futimes futimes "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -350,7 +331,6 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { func libc_poll_trampoline() -//go:linkname libc_poll libc_poll //go:cgo_import_dynamic libc_poll poll "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -371,7 +351,6 @@ func Madvise(b []byte, behav int) (err error) { func libc_madvise_trampoline() -//go:linkname libc_madvise libc_madvise //go:cgo_import_dynamic libc_madvise madvise "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -392,7 +371,6 @@ func Mlock(b []byte) (err error) { func libc_mlock_trampoline() -//go:linkname libc_mlock libc_mlock //go:cgo_import_dynamic libc_mlock mlock "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -407,7 +385,6 @@ func Mlockall(flags int) (err error) { func libc_mlockall_trampoline() -//go:linkname libc_mlockall libc_mlockall //go:cgo_import_dynamic libc_mlockall mlockall "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -428,7 +405,6 @@ func Mprotect(b []byte, prot int) (err error) { func libc_mprotect_trampoline() -//go:linkname libc_mprotect libc_mprotect //go:cgo_import_dynamic libc_mprotect mprotect "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -449,7 +425,6 @@ func Msync(b []byte, flags int) (err error) { func libc_msync_trampoline() -//go:linkname libc_msync libc_msync //go:cgo_import_dynamic libc_msync msync "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -470,7 +445,6 @@ func Munlock(b []byte) (err error) { func libc_munlock_trampoline() -//go:linkname libc_munlock libc_munlock //go:cgo_import_dynamic libc_munlock munlock "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -485,15 +459,12 @@ func Munlockall() (err error) { func libc_munlockall_trampoline() -//go:linkname libc_munlockall libc_munlockall //go:cgo_import_dynamic libc_munlockall munlockall "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe() (r int, w int, err error) { - r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0) - r = int(r0) - w = int(r1) +func pipe(p *[2]int32) (err error) { + _, _, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), uintptr(unsafe.Pointer(p)), 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -502,7 +473,6 @@ func pipe() (r int, w int, err error) { func libc_pipe_trampoline() -//go:linkname libc_pipe libc_pipe //go:cgo_import_dynamic libc_pipe pipe "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -528,7 +498,6 @@ func getxattr(path string, attr string, dest *byte, size int, position uint32, o func libc_getxattr_trampoline() -//go:linkname libc_getxattr libc_getxattr //go:cgo_import_dynamic libc_getxattr getxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -549,7 +518,6 @@ func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, optio func libc_fgetxattr_trampoline() -//go:linkname libc_fgetxattr libc_fgetxattr //go:cgo_import_dynamic libc_fgetxattr fgetxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -574,7 +542,6 @@ func setxattr(path string, attr string, data *byte, size int, position uint32, o func libc_setxattr_trampoline() -//go:linkname libc_setxattr libc_setxattr //go:cgo_import_dynamic libc_setxattr setxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -594,7 +561,6 @@ func fsetxattr(fd int, attr string, data *byte, size int, position uint32, optio func libc_fsetxattr_trampoline() -//go:linkname libc_fsetxattr libc_fsetxattr //go:cgo_import_dynamic libc_fsetxattr fsetxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -619,7 +585,6 @@ func removexattr(path string, attr string, options int) (err error) { func libc_removexattr_trampoline() -//go:linkname libc_removexattr libc_removexattr //go:cgo_import_dynamic libc_removexattr removexattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -639,7 +604,6 @@ func fremovexattr(fd int, attr string, options int) (err error) { func libc_fremovexattr_trampoline() -//go:linkname libc_fremovexattr libc_fremovexattr //go:cgo_import_dynamic libc_fremovexattr fremovexattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -660,7 +624,6 @@ func listxattr(path string, dest *byte, size int, options int) (sz int, err erro func libc_listxattr_trampoline() -//go:linkname libc_listxattr libc_listxattr //go:cgo_import_dynamic libc_listxattr listxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -676,7 +639,6 @@ func flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) { func libc_flistxattr_trampoline() -//go:linkname libc_flistxattr libc_flistxattr //go:cgo_import_dynamic libc_flistxattr flistxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -691,7 +653,6 @@ func setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintp func libc_setattrlist_trampoline() -//go:linkname libc_setattrlist libc_setattrlist //go:cgo_import_dynamic libc_setattrlist setattrlist "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -707,7 +668,6 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { func libc_fcntl_trampoline() -//go:linkname libc_fcntl libc_fcntl //go:cgo_import_dynamic libc_fcntl fcntl "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -722,7 +682,6 @@ func kill(pid int, signum int, posix int) (err error) { func libc_kill_trampoline() -//go:linkname libc_kill libc_kill //go:cgo_import_dynamic libc_kill kill "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -737,7 +696,6 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { func libc_ioctl_trampoline() -//go:linkname libc_ioctl libc_ioctl //go:cgo_import_dynamic libc_ioctl ioctl "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -758,7 +716,6 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) func libc_sysctl_trampoline() -//go:linkname libc_sysctl libc_sysctl //go:cgo_import_dynamic libc_sysctl sysctl "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -773,7 +730,6 @@ func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer func libc_sendfile_trampoline() -//go:linkname libc_sendfile libc_sendfile //go:cgo_import_dynamic libc_sendfile sendfile "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -793,7 +749,6 @@ func Access(path string, mode uint32) (err error) { func libc_access_trampoline() -//go:linkname libc_access libc_access //go:cgo_import_dynamic libc_access access "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -808,7 +763,6 @@ func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { func libc_adjtime_trampoline() -//go:linkname libc_adjtime libc_adjtime //go:cgo_import_dynamic libc_adjtime adjtime "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -828,7 +782,6 @@ func Chdir(path string) (err error) { func libc_chdir_trampoline() -//go:linkname libc_chdir libc_chdir //go:cgo_import_dynamic libc_chdir chdir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -848,7 +801,6 @@ func Chflags(path string, flags int) (err error) { func libc_chflags_trampoline() -//go:linkname libc_chflags libc_chflags //go:cgo_import_dynamic libc_chflags chflags "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -868,7 +820,6 @@ func Chmod(path string, mode uint32) (err error) { func libc_chmod_trampoline() -//go:linkname libc_chmod libc_chmod //go:cgo_import_dynamic libc_chmod chmod "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -888,7 +839,6 @@ func Chown(path string, uid int, gid int) (err error) { func libc_chown_trampoline() -//go:linkname libc_chown libc_chown //go:cgo_import_dynamic libc_chown chown "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -908,7 +858,6 @@ func Chroot(path string) (err error) { func libc_chroot_trampoline() -//go:linkname libc_chroot libc_chroot //go:cgo_import_dynamic libc_chroot chroot "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -923,7 +872,6 @@ func ClockGettime(clockid int32, time *Timespec) (err error) { func libc_clock_gettime_trampoline() -//go:linkname libc_clock_gettime libc_clock_gettime //go:cgo_import_dynamic libc_clock_gettime clock_gettime "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -938,7 +886,6 @@ func Close(fd int) (err error) { func libc_close_trampoline() -//go:linkname libc_close libc_close //go:cgo_import_dynamic libc_close close "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -963,7 +910,6 @@ func Clonefile(src string, dst string, flags int) (err error) { func libc_clonefile_trampoline() -//go:linkname libc_clonefile libc_clonefile //go:cgo_import_dynamic libc_clonefile clonefile "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -988,7 +934,6 @@ func Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) func libc_clonefileat_trampoline() -//go:linkname libc_clonefileat libc_clonefileat //go:cgo_import_dynamic libc_clonefileat clonefileat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1004,7 +949,6 @@ func Dup(fd int) (nfd int, err error) { func libc_dup_trampoline() -//go:linkname libc_dup libc_dup //go:cgo_import_dynamic libc_dup dup "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1019,7 +963,6 @@ func Dup2(from int, to int) (err error) { func libc_dup2_trampoline() -//go:linkname libc_dup2 libc_dup2 //go:cgo_import_dynamic libc_dup2 dup2 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1044,7 +987,6 @@ func Exchangedata(path1 string, path2 string, options int) (err error) { func libc_exchangedata_trampoline() -//go:linkname libc_exchangedata libc_exchangedata //go:cgo_import_dynamic libc_exchangedata exchangedata "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1056,7 +998,6 @@ func Exit(code int) { func libc_exit_trampoline() -//go:linkname libc_exit libc_exit //go:cgo_import_dynamic libc_exit exit "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1076,7 +1017,6 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { func libc_faccessat_trampoline() -//go:linkname libc_faccessat libc_faccessat //go:cgo_import_dynamic libc_faccessat faccessat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1091,7 +1031,6 @@ func Fchdir(fd int) (err error) { func libc_fchdir_trampoline() -//go:linkname libc_fchdir libc_fchdir //go:cgo_import_dynamic libc_fchdir fchdir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1106,7 +1045,6 @@ func Fchflags(fd int, flags int) (err error) { func libc_fchflags_trampoline() -//go:linkname libc_fchflags libc_fchflags //go:cgo_import_dynamic libc_fchflags fchflags "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1121,7 +1059,6 @@ func Fchmod(fd int, mode uint32) (err error) { func libc_fchmod_trampoline() -//go:linkname libc_fchmod libc_fchmod //go:cgo_import_dynamic libc_fchmod fchmod "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1141,7 +1078,6 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { func libc_fchmodat_trampoline() -//go:linkname libc_fchmodat libc_fchmodat //go:cgo_import_dynamic libc_fchmodat fchmodat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1156,7 +1092,6 @@ func Fchown(fd int, uid int, gid int) (err error) { func libc_fchown_trampoline() -//go:linkname libc_fchown libc_fchown //go:cgo_import_dynamic libc_fchown fchown "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1176,7 +1111,6 @@ func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { func libc_fchownat_trampoline() -//go:linkname libc_fchownat libc_fchownat //go:cgo_import_dynamic libc_fchownat fchownat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1196,7 +1130,6 @@ func Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error) func libc_fclonefileat_trampoline() -//go:linkname libc_fclonefileat libc_fclonefileat //go:cgo_import_dynamic libc_fclonefileat fclonefileat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1211,7 +1144,6 @@ func Flock(fd int, how int) (err error) { func libc_flock_trampoline() -//go:linkname libc_flock libc_flock //go:cgo_import_dynamic libc_flock flock "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1227,7 +1159,6 @@ func Fpathconf(fd int, name int) (val int, err error) { func libc_fpathconf_trampoline() -//go:linkname libc_fpathconf libc_fpathconf //go:cgo_import_dynamic libc_fpathconf fpathconf "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1242,7 +1173,6 @@ func Fsync(fd int) (err error) { func libc_fsync_trampoline() -//go:linkname libc_fsync libc_fsync //go:cgo_import_dynamic libc_fsync fsync "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1257,7 +1187,6 @@ func Ftruncate(fd int, length int64) (err error) { func libc_ftruncate_trampoline() -//go:linkname libc_ftruncate libc_ftruncate //go:cgo_import_dynamic libc_ftruncate ftruncate "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1279,7 +1208,6 @@ func Getcwd(buf []byte) (n int, err error) { func libc_getcwd_trampoline() -//go:linkname libc_getcwd libc_getcwd //go:cgo_import_dynamic libc_getcwd getcwd "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1292,7 +1220,6 @@ func Getdtablesize() (size int) { func libc_getdtablesize_trampoline() -//go:linkname libc_getdtablesize libc_getdtablesize //go:cgo_import_dynamic libc_getdtablesize getdtablesize "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1305,7 +1232,6 @@ func Getegid() (egid int) { func libc_getegid_trampoline() -//go:linkname libc_getegid libc_getegid //go:cgo_import_dynamic libc_getegid getegid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1318,7 +1244,6 @@ func Geteuid() (uid int) { func libc_geteuid_trampoline() -//go:linkname libc_geteuid libc_geteuid //go:cgo_import_dynamic libc_geteuid geteuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1331,7 +1256,6 @@ func Getgid() (gid int) { func libc_getgid_trampoline() -//go:linkname libc_getgid libc_getgid //go:cgo_import_dynamic libc_getgid getgid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1347,7 +1271,6 @@ func Getpgid(pid int) (pgid int, err error) { func libc_getpgid_trampoline() -//go:linkname libc_getpgid libc_getpgid //go:cgo_import_dynamic libc_getpgid getpgid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1360,7 +1283,6 @@ func Getpgrp() (pgrp int) { func libc_getpgrp_trampoline() -//go:linkname libc_getpgrp libc_getpgrp //go:cgo_import_dynamic libc_getpgrp getpgrp "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1373,7 +1295,6 @@ func Getpid() (pid int) { func libc_getpid_trampoline() -//go:linkname libc_getpid libc_getpid //go:cgo_import_dynamic libc_getpid getpid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1386,7 +1307,6 @@ func Getppid() (ppid int) { func libc_getppid_trampoline() -//go:linkname libc_getppid libc_getppid //go:cgo_import_dynamic libc_getppid getppid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1402,7 +1322,6 @@ func Getpriority(which int, who int) (prio int, err error) { func libc_getpriority_trampoline() -//go:linkname libc_getpriority libc_getpriority //go:cgo_import_dynamic libc_getpriority getpriority "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1417,7 +1336,6 @@ func Getrlimit(which int, lim *Rlimit) (err error) { func libc_getrlimit_trampoline() -//go:linkname libc_getrlimit libc_getrlimit //go:cgo_import_dynamic libc_getrlimit getrlimit "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1432,7 +1350,6 @@ func Getrusage(who int, rusage *Rusage) (err error) { func libc_getrusage_trampoline() -//go:linkname libc_getrusage libc_getrusage //go:cgo_import_dynamic libc_getrusage getrusage "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1448,7 +1365,6 @@ func Getsid(pid int) (sid int, err error) { func libc_getsid_trampoline() -//go:linkname libc_getsid libc_getsid //go:cgo_import_dynamic libc_getsid getsid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1463,7 +1379,6 @@ func Gettimeofday(tp *Timeval) (err error) { func libc_gettimeofday_trampoline() -//go:linkname libc_gettimeofday libc_gettimeofday //go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1476,7 +1391,6 @@ func Getuid() (uid int) { func libc_getuid_trampoline() -//go:linkname libc_getuid libc_getuid //go:cgo_import_dynamic libc_getuid getuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1489,7 +1403,6 @@ func Issetugid() (tainted bool) { func libc_issetugid_trampoline() -//go:linkname libc_issetugid libc_issetugid //go:cgo_import_dynamic libc_issetugid issetugid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1505,7 +1418,6 @@ func Kqueue() (fd int, err error) { func libc_kqueue_trampoline() -//go:linkname libc_kqueue libc_kqueue //go:cgo_import_dynamic libc_kqueue kqueue "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1525,7 +1437,6 @@ func Lchown(path string, uid int, gid int) (err error) { func libc_lchown_trampoline() -//go:linkname libc_lchown libc_lchown //go:cgo_import_dynamic libc_lchown lchown "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1550,7 +1461,6 @@ func Link(path string, link string) (err error) { func libc_link_trampoline() -//go:linkname libc_link libc_link //go:cgo_import_dynamic libc_link link "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1575,7 +1485,6 @@ func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err er func libc_linkat_trampoline() -//go:linkname libc_linkat libc_linkat //go:cgo_import_dynamic libc_linkat linkat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1590,7 +1499,6 @@ func Listen(s int, backlog int) (err error) { func libc_listen_trampoline() -//go:linkname libc_listen libc_listen //go:cgo_import_dynamic libc_listen listen "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1610,7 +1518,6 @@ func Mkdir(path string, mode uint32) (err error) { func libc_mkdir_trampoline() -//go:linkname libc_mkdir libc_mkdir //go:cgo_import_dynamic libc_mkdir mkdir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1630,7 +1537,6 @@ func Mkdirat(dirfd int, path string, mode uint32) (err error) { func libc_mkdirat_trampoline() -//go:linkname libc_mkdirat libc_mkdirat //go:cgo_import_dynamic libc_mkdirat mkdirat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1650,7 +1556,6 @@ func Mkfifo(path string, mode uint32) (err error) { func libc_mkfifo_trampoline() -//go:linkname libc_mkfifo libc_mkfifo //go:cgo_import_dynamic libc_mkfifo mkfifo "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1670,7 +1575,6 @@ func Mknod(path string, mode uint32, dev int) (err error) { func libc_mknod_trampoline() -//go:linkname libc_mknod libc_mknod //go:cgo_import_dynamic libc_mknod mknod "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1691,7 +1595,6 @@ func Open(path string, mode int, perm uint32) (fd int, err error) { func libc_open_trampoline() -//go:linkname libc_open libc_open //go:cgo_import_dynamic libc_open open "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1712,7 +1615,6 @@ func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) { func libc_openat_trampoline() -//go:linkname libc_openat libc_openat //go:cgo_import_dynamic libc_openat openat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1733,7 +1635,6 @@ func Pathconf(path string, name int) (val int, err error) { func libc_pathconf_trampoline() -//go:linkname libc_pathconf libc_pathconf //go:cgo_import_dynamic libc_pathconf pathconf "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1755,7 +1656,6 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { func libc_pread_trampoline() -//go:linkname libc_pread libc_pread //go:cgo_import_dynamic libc_pread pread "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1777,7 +1677,6 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) { func libc_pwrite_trampoline() -//go:linkname libc_pwrite libc_pwrite //go:cgo_import_dynamic libc_pwrite pwrite "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1799,7 +1698,6 @@ func read(fd int, p []byte) (n int, err error) { func libc_read_trampoline() -//go:linkname libc_read libc_read //go:cgo_import_dynamic libc_read read "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1826,7 +1724,6 @@ func Readlink(path string, buf []byte) (n int, err error) { func libc_readlink_trampoline() -//go:linkname libc_readlink libc_readlink //go:cgo_import_dynamic libc_readlink readlink "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1853,7 +1750,6 @@ func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) { func libc_readlinkat_trampoline() -//go:linkname libc_readlinkat libc_readlinkat //go:cgo_import_dynamic libc_readlinkat readlinkat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1878,7 +1774,6 @@ func Rename(from string, to string) (err error) { func libc_rename_trampoline() -//go:linkname libc_rename libc_rename //go:cgo_import_dynamic libc_rename rename "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1903,7 +1798,6 @@ func Renameat(fromfd int, from string, tofd int, to string) (err error) { func libc_renameat_trampoline() -//go:linkname libc_renameat libc_renameat //go:cgo_import_dynamic libc_renameat renameat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1923,7 +1817,6 @@ func Revoke(path string) (err error) { func libc_revoke_trampoline() -//go:linkname libc_revoke libc_revoke //go:cgo_import_dynamic libc_revoke revoke "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1943,7 +1836,6 @@ func Rmdir(path string) (err error) { func libc_rmdir_trampoline() -//go:linkname libc_rmdir libc_rmdir //go:cgo_import_dynamic libc_rmdir rmdir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1959,7 +1851,6 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { func libc_lseek_trampoline() -//go:linkname libc_lseek libc_lseek //go:cgo_import_dynamic libc_lseek lseek "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1975,7 +1866,6 @@ func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err func libc_select_trampoline() -//go:linkname libc_select libc_select //go:cgo_import_dynamic libc_select select "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1990,7 +1880,6 @@ func Setegid(egid int) (err error) { func libc_setegid_trampoline() -//go:linkname libc_setegid libc_setegid //go:cgo_import_dynamic libc_setegid setegid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2005,7 +1894,6 @@ func Seteuid(euid int) (err error) { func libc_seteuid_trampoline() -//go:linkname libc_seteuid libc_seteuid //go:cgo_import_dynamic libc_seteuid seteuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2020,7 +1908,6 @@ func Setgid(gid int) (err error) { func libc_setgid_trampoline() -//go:linkname libc_setgid libc_setgid //go:cgo_import_dynamic libc_setgid setgid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2040,7 +1927,6 @@ func Setlogin(name string) (err error) { func libc_setlogin_trampoline() -//go:linkname libc_setlogin libc_setlogin //go:cgo_import_dynamic libc_setlogin setlogin "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2055,7 +1941,6 @@ func Setpgid(pid int, pgid int) (err error) { func libc_setpgid_trampoline() -//go:linkname libc_setpgid libc_setpgid //go:cgo_import_dynamic libc_setpgid setpgid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2070,7 +1955,6 @@ func Setpriority(which int, who int, prio int) (err error) { func libc_setpriority_trampoline() -//go:linkname libc_setpriority libc_setpriority //go:cgo_import_dynamic libc_setpriority setpriority "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2085,7 +1969,6 @@ func Setprivexec(flag int) (err error) { func libc_setprivexec_trampoline() -//go:linkname libc_setprivexec libc_setprivexec //go:cgo_import_dynamic libc_setprivexec setprivexec "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2100,7 +1983,6 @@ func Setregid(rgid int, egid int) (err error) { func libc_setregid_trampoline() -//go:linkname libc_setregid libc_setregid //go:cgo_import_dynamic libc_setregid setregid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2115,7 +1997,6 @@ func Setreuid(ruid int, euid int) (err error) { func libc_setreuid_trampoline() -//go:linkname libc_setreuid libc_setreuid //go:cgo_import_dynamic libc_setreuid setreuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2130,7 +2011,6 @@ func Setrlimit(which int, lim *Rlimit) (err error) { func libc_setrlimit_trampoline() -//go:linkname libc_setrlimit libc_setrlimit //go:cgo_import_dynamic libc_setrlimit setrlimit "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2146,7 +2026,6 @@ func Setsid() (pid int, err error) { func libc_setsid_trampoline() -//go:linkname libc_setsid libc_setsid //go:cgo_import_dynamic libc_setsid setsid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2161,7 +2040,6 @@ func Settimeofday(tp *Timeval) (err error) { func libc_settimeofday_trampoline() -//go:linkname libc_settimeofday libc_settimeofday //go:cgo_import_dynamic libc_settimeofday settimeofday "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2176,7 +2054,6 @@ func Setuid(uid int) (err error) { func libc_setuid_trampoline() -//go:linkname libc_setuid libc_setuid //go:cgo_import_dynamic libc_setuid setuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2201,7 +2078,6 @@ func Symlink(path string, link string) (err error) { func libc_symlink_trampoline() -//go:linkname libc_symlink libc_symlink //go:cgo_import_dynamic libc_symlink symlink "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2226,7 +2102,6 @@ func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { func libc_symlinkat_trampoline() -//go:linkname libc_symlinkat libc_symlinkat //go:cgo_import_dynamic libc_symlinkat symlinkat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2241,7 +2116,6 @@ func Sync() (err error) { func libc_sync_trampoline() -//go:linkname libc_sync libc_sync //go:cgo_import_dynamic libc_sync sync "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2261,7 +2135,6 @@ func Truncate(path string, length int64) (err error) { func libc_truncate_trampoline() -//go:linkname libc_truncate libc_truncate //go:cgo_import_dynamic libc_truncate truncate "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2274,7 +2147,6 @@ func Umask(newmask int) (oldmask int) { func libc_umask_trampoline() -//go:linkname libc_umask libc_umask //go:cgo_import_dynamic libc_umask umask "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2294,7 +2166,6 @@ func Undelete(path string) (err error) { func libc_undelete_trampoline() -//go:linkname libc_undelete libc_undelete //go:cgo_import_dynamic libc_undelete undelete "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2314,7 +2185,6 @@ func Unlink(path string) (err error) { func libc_unlink_trampoline() -//go:linkname libc_unlink libc_unlink //go:cgo_import_dynamic libc_unlink unlink "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2334,7 +2204,6 @@ func Unlinkat(dirfd int, path string, flags int) (err error) { func libc_unlinkat_trampoline() -//go:linkname libc_unlinkat libc_unlinkat //go:cgo_import_dynamic libc_unlinkat unlinkat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2354,7 +2223,6 @@ func Unmount(path string, flags int) (err error) { func libc_unmount_trampoline() -//go:linkname libc_unmount libc_unmount //go:cgo_import_dynamic libc_unmount unmount "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2376,7 +2244,6 @@ func write(fd int, p []byte) (n int, err error) { func libc_write_trampoline() -//go:linkname libc_write libc_write //go:cgo_import_dynamic libc_write write "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2392,7 +2259,6 @@ func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) ( func libc_mmap_trampoline() -//go:linkname libc_mmap libc_mmap //go:cgo_import_dynamic libc_mmap mmap "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2407,7 +2273,6 @@ func munmap(addr uintptr, length uintptr) (err error) { func libc_munmap_trampoline() -//go:linkname libc_munmap libc_munmap //go:cgo_import_dynamic libc_munmap munmap "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2444,7 +2309,6 @@ func Fstat(fd int, stat *Stat_t) (err error) { func libc_fstat64_trampoline() -//go:linkname libc_fstat64 libc_fstat64 //go:cgo_import_dynamic libc_fstat64 fstat64 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2464,7 +2328,6 @@ func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) { func libc_fstatat64_trampoline() -//go:linkname libc_fstatat64 libc_fstatat64 //go:cgo_import_dynamic libc_fstatat64 fstatat64 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2479,7 +2342,6 @@ func Fstatfs(fd int, stat *Statfs_t) (err error) { func libc_fstatfs64_trampoline() -//go:linkname libc_fstatfs64 libc_fstatfs64 //go:cgo_import_dynamic libc_fstatfs64 fstatfs64 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2495,7 +2357,6 @@ func getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) { func libc_getfsstat64_trampoline() -//go:linkname libc_getfsstat64 libc_getfsstat64 //go:cgo_import_dynamic libc_getfsstat64 getfsstat64 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2515,12 +2376,11 @@ func Lstat(path string, stat *Stat_t) (err error) { func libc_lstat64_trampoline() -//go:linkname libc_lstat64 libc_lstat64 //go:cgo_import_dynamic libc_lstat64 lstat64 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { +func ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) { _, _, e1 := syscall_syscall6(funcPC(libc_ptrace_trampoline), uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) if e1 != 0 { err = errnoErr(e1) @@ -2530,7 +2390,6 @@ func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { func libc_ptrace_trampoline() -//go:linkname libc_ptrace libc_ptrace //go:cgo_import_dynamic libc_ptrace ptrace "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2550,7 +2409,6 @@ func Stat(path string, stat *Stat_t) (err error) { func libc_stat64_trampoline() -//go:linkname libc_stat64 libc_stat64 //go:cgo_import_dynamic libc_stat64 stat64 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2570,5 +2428,4 @@ func Statfs(path string, stat *Statfs_t) (err error) { func libc_statfs64_trampoline() -//go:linkname libc_statfs64 libc_statfs64 //go:cgo_import_dynamic libc_statfs64 statfs64 "/usr/lib/libSystem.B.dylib" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.go index 314042a9d42..e36299ead09 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.go @@ -1,6 +1,7 @@ // go run mksyscall.go -tags darwin,amd64,go1.13 syscall_darwin.1_13.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build darwin && amd64 && go1.13 // +build darwin,amd64,go1.13 package unix @@ -24,7 +25,6 @@ func closedir(dir uintptr) (err error) { func libc_closedir_trampoline() -//go:linkname libc_closedir libc_closedir //go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -37,5 +37,4 @@ func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { func libc_readdir_r_trampoline() -//go:linkname libc_readdir_r libc_readdir_r //go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index 889c14059e9..f4111628823 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -1,6 +1,7 @@ // go run mksyscall.go -tags darwin,amd64,go1.12 syscall_bsd.go syscall_darwin.go syscall_darwin_amd64.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build darwin && amd64 && go1.12 // +build darwin,amd64,go1.12 package unix @@ -25,7 +26,6 @@ func getgroups(ngid int, gid *_Gid_t) (n int, err error) { func libc_getgroups_trampoline() -//go:linkname libc_getgroups libc_getgroups //go:cgo_import_dynamic libc_getgroups getgroups "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -40,7 +40,6 @@ func setgroups(ngid int, gid *_Gid_t) (err error) { func libc_setgroups_trampoline() -//go:linkname libc_setgroups libc_setgroups //go:cgo_import_dynamic libc_setgroups setgroups "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -56,7 +55,6 @@ func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err func libc_wait4_trampoline() -//go:linkname libc_wait4 libc_wait4 //go:cgo_import_dynamic libc_wait4 wait4 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -72,7 +70,6 @@ func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { func libc_accept_trampoline() -//go:linkname libc_accept libc_accept //go:cgo_import_dynamic libc_accept accept "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -87,7 +84,6 @@ func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { func libc_bind_trampoline() -//go:linkname libc_bind libc_bind //go:cgo_import_dynamic libc_bind bind "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -102,7 +98,6 @@ func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { func libc_connect_trampoline() -//go:linkname libc_connect libc_connect //go:cgo_import_dynamic libc_connect connect "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -118,7 +113,6 @@ func socket(domain int, typ int, proto int) (fd int, err error) { func libc_socket_trampoline() -//go:linkname libc_socket libc_socket //go:cgo_import_dynamic libc_socket socket "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -133,7 +127,6 @@ func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen func libc_getsockopt_trampoline() -//go:linkname libc_getsockopt libc_getsockopt //go:cgo_import_dynamic libc_getsockopt getsockopt "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -148,7 +141,6 @@ func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) func libc_setsockopt_trampoline() -//go:linkname libc_setsockopt libc_setsockopt //go:cgo_import_dynamic libc_setsockopt setsockopt "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -163,7 +155,6 @@ func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { func libc_getpeername_trampoline() -//go:linkname libc_getpeername libc_getpeername //go:cgo_import_dynamic libc_getpeername getpeername "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -178,7 +169,6 @@ func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { func libc_getsockname_trampoline() -//go:linkname libc_getsockname libc_getsockname //go:cgo_import_dynamic libc_getsockname getsockname "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -193,7 +183,6 @@ func Shutdown(s int, how int) (err error) { func libc_shutdown_trampoline() -//go:linkname libc_shutdown libc_shutdown //go:cgo_import_dynamic libc_shutdown shutdown "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -208,7 +197,6 @@ func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { func libc_socketpair_trampoline() -//go:linkname libc_socketpair libc_socketpair //go:cgo_import_dynamic libc_socketpair socketpair "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -230,7 +218,6 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl func libc_recvfrom_trampoline() -//go:linkname libc_recvfrom libc_recvfrom //go:cgo_import_dynamic libc_recvfrom recvfrom "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -251,7 +238,6 @@ func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) ( func libc_sendto_trampoline() -//go:linkname libc_sendto libc_sendto //go:cgo_import_dynamic libc_sendto sendto "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -267,7 +253,6 @@ func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { func libc_recvmsg_trampoline() -//go:linkname libc_recvmsg libc_recvmsg //go:cgo_import_dynamic libc_recvmsg recvmsg "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -283,7 +268,6 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { func libc_sendmsg_trampoline() -//go:linkname libc_sendmsg libc_sendmsg //go:cgo_import_dynamic libc_sendmsg sendmsg "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -299,7 +283,6 @@ func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, ne func libc_kevent_trampoline() -//go:linkname libc_kevent libc_kevent //go:cgo_import_dynamic libc_kevent kevent "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -319,7 +302,6 @@ func utimes(path string, timeval *[2]Timeval) (err error) { func libc_utimes_trampoline() -//go:linkname libc_utimes libc_utimes //go:cgo_import_dynamic libc_utimes utimes "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -334,7 +316,6 @@ func futimes(fd int, timeval *[2]Timeval) (err error) { func libc_futimes_trampoline() -//go:linkname libc_futimes libc_futimes //go:cgo_import_dynamic libc_futimes futimes "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -350,7 +331,6 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { func libc_poll_trampoline() -//go:linkname libc_poll libc_poll //go:cgo_import_dynamic libc_poll poll "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -371,7 +351,6 @@ func Madvise(b []byte, behav int) (err error) { func libc_madvise_trampoline() -//go:linkname libc_madvise libc_madvise //go:cgo_import_dynamic libc_madvise madvise "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -392,7 +371,6 @@ func Mlock(b []byte) (err error) { func libc_mlock_trampoline() -//go:linkname libc_mlock libc_mlock //go:cgo_import_dynamic libc_mlock mlock "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -407,7 +385,6 @@ func Mlockall(flags int) (err error) { func libc_mlockall_trampoline() -//go:linkname libc_mlockall libc_mlockall //go:cgo_import_dynamic libc_mlockall mlockall "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -428,7 +405,6 @@ func Mprotect(b []byte, prot int) (err error) { func libc_mprotect_trampoline() -//go:linkname libc_mprotect libc_mprotect //go:cgo_import_dynamic libc_mprotect mprotect "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -449,7 +425,6 @@ func Msync(b []byte, flags int) (err error) { func libc_msync_trampoline() -//go:linkname libc_msync libc_msync //go:cgo_import_dynamic libc_msync msync "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -470,7 +445,6 @@ func Munlock(b []byte) (err error) { func libc_munlock_trampoline() -//go:linkname libc_munlock libc_munlock //go:cgo_import_dynamic libc_munlock munlock "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -485,15 +459,12 @@ func Munlockall() (err error) { func libc_munlockall_trampoline() -//go:linkname libc_munlockall libc_munlockall //go:cgo_import_dynamic libc_munlockall munlockall "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe() (r int, w int, err error) { - r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0) - r = int(r0) - w = int(r1) +func pipe(p *[2]int32) (err error) { + _, _, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), uintptr(unsafe.Pointer(p)), 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -502,7 +473,6 @@ func pipe() (r int, w int, err error) { func libc_pipe_trampoline() -//go:linkname libc_pipe libc_pipe //go:cgo_import_dynamic libc_pipe pipe "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -528,7 +498,6 @@ func getxattr(path string, attr string, dest *byte, size int, position uint32, o func libc_getxattr_trampoline() -//go:linkname libc_getxattr libc_getxattr //go:cgo_import_dynamic libc_getxattr getxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -549,7 +518,6 @@ func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, optio func libc_fgetxattr_trampoline() -//go:linkname libc_fgetxattr libc_fgetxattr //go:cgo_import_dynamic libc_fgetxattr fgetxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -574,7 +542,6 @@ func setxattr(path string, attr string, data *byte, size int, position uint32, o func libc_setxattr_trampoline() -//go:linkname libc_setxattr libc_setxattr //go:cgo_import_dynamic libc_setxattr setxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -594,7 +561,6 @@ func fsetxattr(fd int, attr string, data *byte, size int, position uint32, optio func libc_fsetxattr_trampoline() -//go:linkname libc_fsetxattr libc_fsetxattr //go:cgo_import_dynamic libc_fsetxattr fsetxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -619,7 +585,6 @@ func removexattr(path string, attr string, options int) (err error) { func libc_removexattr_trampoline() -//go:linkname libc_removexattr libc_removexattr //go:cgo_import_dynamic libc_removexattr removexattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -639,7 +604,6 @@ func fremovexattr(fd int, attr string, options int) (err error) { func libc_fremovexattr_trampoline() -//go:linkname libc_fremovexattr libc_fremovexattr //go:cgo_import_dynamic libc_fremovexattr fremovexattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -660,7 +624,6 @@ func listxattr(path string, dest *byte, size int, options int) (sz int, err erro func libc_listxattr_trampoline() -//go:linkname libc_listxattr libc_listxattr //go:cgo_import_dynamic libc_listxattr listxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -676,7 +639,6 @@ func flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) { func libc_flistxattr_trampoline() -//go:linkname libc_flistxattr libc_flistxattr //go:cgo_import_dynamic libc_flistxattr flistxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -691,7 +653,6 @@ func setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintp func libc_setattrlist_trampoline() -//go:linkname libc_setattrlist libc_setattrlist //go:cgo_import_dynamic libc_setattrlist setattrlist "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -707,7 +668,6 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { func libc_fcntl_trampoline() -//go:linkname libc_fcntl libc_fcntl //go:cgo_import_dynamic libc_fcntl fcntl "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -722,7 +682,6 @@ func kill(pid int, signum int, posix int) (err error) { func libc_kill_trampoline() -//go:linkname libc_kill libc_kill //go:cgo_import_dynamic libc_kill kill "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -737,7 +696,6 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { func libc_ioctl_trampoline() -//go:linkname libc_ioctl libc_ioctl //go:cgo_import_dynamic libc_ioctl ioctl "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -758,7 +716,6 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) func libc_sysctl_trampoline() -//go:linkname libc_sysctl libc_sysctl //go:cgo_import_dynamic libc_sysctl sysctl "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -773,7 +730,6 @@ func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer func libc_sendfile_trampoline() -//go:linkname libc_sendfile libc_sendfile //go:cgo_import_dynamic libc_sendfile sendfile "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -793,7 +749,6 @@ func Access(path string, mode uint32) (err error) { func libc_access_trampoline() -//go:linkname libc_access libc_access //go:cgo_import_dynamic libc_access access "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -808,7 +763,6 @@ func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { func libc_adjtime_trampoline() -//go:linkname libc_adjtime libc_adjtime //go:cgo_import_dynamic libc_adjtime adjtime "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -828,7 +782,6 @@ func Chdir(path string) (err error) { func libc_chdir_trampoline() -//go:linkname libc_chdir libc_chdir //go:cgo_import_dynamic libc_chdir chdir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -848,7 +801,6 @@ func Chflags(path string, flags int) (err error) { func libc_chflags_trampoline() -//go:linkname libc_chflags libc_chflags //go:cgo_import_dynamic libc_chflags chflags "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -868,7 +820,6 @@ func Chmod(path string, mode uint32) (err error) { func libc_chmod_trampoline() -//go:linkname libc_chmod libc_chmod //go:cgo_import_dynamic libc_chmod chmod "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -888,7 +839,6 @@ func Chown(path string, uid int, gid int) (err error) { func libc_chown_trampoline() -//go:linkname libc_chown libc_chown //go:cgo_import_dynamic libc_chown chown "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -908,7 +858,6 @@ func Chroot(path string) (err error) { func libc_chroot_trampoline() -//go:linkname libc_chroot libc_chroot //go:cgo_import_dynamic libc_chroot chroot "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -923,7 +872,6 @@ func ClockGettime(clockid int32, time *Timespec) (err error) { func libc_clock_gettime_trampoline() -//go:linkname libc_clock_gettime libc_clock_gettime //go:cgo_import_dynamic libc_clock_gettime clock_gettime "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -938,7 +886,6 @@ func Close(fd int) (err error) { func libc_close_trampoline() -//go:linkname libc_close libc_close //go:cgo_import_dynamic libc_close close "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -963,7 +910,6 @@ func Clonefile(src string, dst string, flags int) (err error) { func libc_clonefile_trampoline() -//go:linkname libc_clonefile libc_clonefile //go:cgo_import_dynamic libc_clonefile clonefile "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -988,7 +934,6 @@ func Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) func libc_clonefileat_trampoline() -//go:linkname libc_clonefileat libc_clonefileat //go:cgo_import_dynamic libc_clonefileat clonefileat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1004,7 +949,6 @@ func Dup(fd int) (nfd int, err error) { func libc_dup_trampoline() -//go:linkname libc_dup libc_dup //go:cgo_import_dynamic libc_dup dup "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1019,7 +963,6 @@ func Dup2(from int, to int) (err error) { func libc_dup2_trampoline() -//go:linkname libc_dup2 libc_dup2 //go:cgo_import_dynamic libc_dup2 dup2 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1044,7 +987,6 @@ func Exchangedata(path1 string, path2 string, options int) (err error) { func libc_exchangedata_trampoline() -//go:linkname libc_exchangedata libc_exchangedata //go:cgo_import_dynamic libc_exchangedata exchangedata "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1056,7 +998,6 @@ func Exit(code int) { func libc_exit_trampoline() -//go:linkname libc_exit libc_exit //go:cgo_import_dynamic libc_exit exit "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1076,7 +1017,6 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { func libc_faccessat_trampoline() -//go:linkname libc_faccessat libc_faccessat //go:cgo_import_dynamic libc_faccessat faccessat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1091,7 +1031,6 @@ func Fchdir(fd int) (err error) { func libc_fchdir_trampoline() -//go:linkname libc_fchdir libc_fchdir //go:cgo_import_dynamic libc_fchdir fchdir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1106,7 +1045,6 @@ func Fchflags(fd int, flags int) (err error) { func libc_fchflags_trampoline() -//go:linkname libc_fchflags libc_fchflags //go:cgo_import_dynamic libc_fchflags fchflags "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1121,7 +1059,6 @@ func Fchmod(fd int, mode uint32) (err error) { func libc_fchmod_trampoline() -//go:linkname libc_fchmod libc_fchmod //go:cgo_import_dynamic libc_fchmod fchmod "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1141,7 +1078,6 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { func libc_fchmodat_trampoline() -//go:linkname libc_fchmodat libc_fchmodat //go:cgo_import_dynamic libc_fchmodat fchmodat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1156,7 +1092,6 @@ func Fchown(fd int, uid int, gid int) (err error) { func libc_fchown_trampoline() -//go:linkname libc_fchown libc_fchown //go:cgo_import_dynamic libc_fchown fchown "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1176,7 +1111,6 @@ func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { func libc_fchownat_trampoline() -//go:linkname libc_fchownat libc_fchownat //go:cgo_import_dynamic libc_fchownat fchownat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1196,7 +1130,6 @@ func Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error) func libc_fclonefileat_trampoline() -//go:linkname libc_fclonefileat libc_fclonefileat //go:cgo_import_dynamic libc_fclonefileat fclonefileat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1211,7 +1144,6 @@ func Flock(fd int, how int) (err error) { func libc_flock_trampoline() -//go:linkname libc_flock libc_flock //go:cgo_import_dynamic libc_flock flock "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1227,7 +1159,6 @@ func Fpathconf(fd int, name int) (val int, err error) { func libc_fpathconf_trampoline() -//go:linkname libc_fpathconf libc_fpathconf //go:cgo_import_dynamic libc_fpathconf fpathconf "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1242,7 +1173,6 @@ func Fsync(fd int) (err error) { func libc_fsync_trampoline() -//go:linkname libc_fsync libc_fsync //go:cgo_import_dynamic libc_fsync fsync "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1257,7 +1187,6 @@ func Ftruncate(fd int, length int64) (err error) { func libc_ftruncate_trampoline() -//go:linkname libc_ftruncate libc_ftruncate //go:cgo_import_dynamic libc_ftruncate ftruncate "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1279,7 +1208,6 @@ func Getcwd(buf []byte) (n int, err error) { func libc_getcwd_trampoline() -//go:linkname libc_getcwd libc_getcwd //go:cgo_import_dynamic libc_getcwd getcwd "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1292,7 +1220,6 @@ func Getdtablesize() (size int) { func libc_getdtablesize_trampoline() -//go:linkname libc_getdtablesize libc_getdtablesize //go:cgo_import_dynamic libc_getdtablesize getdtablesize "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1305,7 +1232,6 @@ func Getegid() (egid int) { func libc_getegid_trampoline() -//go:linkname libc_getegid libc_getegid //go:cgo_import_dynamic libc_getegid getegid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1318,7 +1244,6 @@ func Geteuid() (uid int) { func libc_geteuid_trampoline() -//go:linkname libc_geteuid libc_geteuid //go:cgo_import_dynamic libc_geteuid geteuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1331,7 +1256,6 @@ func Getgid() (gid int) { func libc_getgid_trampoline() -//go:linkname libc_getgid libc_getgid //go:cgo_import_dynamic libc_getgid getgid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1347,7 +1271,6 @@ func Getpgid(pid int) (pgid int, err error) { func libc_getpgid_trampoline() -//go:linkname libc_getpgid libc_getpgid //go:cgo_import_dynamic libc_getpgid getpgid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1360,7 +1283,6 @@ func Getpgrp() (pgrp int) { func libc_getpgrp_trampoline() -//go:linkname libc_getpgrp libc_getpgrp //go:cgo_import_dynamic libc_getpgrp getpgrp "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1373,7 +1295,6 @@ func Getpid() (pid int) { func libc_getpid_trampoline() -//go:linkname libc_getpid libc_getpid //go:cgo_import_dynamic libc_getpid getpid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1386,7 +1307,6 @@ func Getppid() (ppid int) { func libc_getppid_trampoline() -//go:linkname libc_getppid libc_getppid //go:cgo_import_dynamic libc_getppid getppid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1402,7 +1322,6 @@ func Getpriority(which int, who int) (prio int, err error) { func libc_getpriority_trampoline() -//go:linkname libc_getpriority libc_getpriority //go:cgo_import_dynamic libc_getpriority getpriority "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1417,7 +1336,6 @@ func Getrlimit(which int, lim *Rlimit) (err error) { func libc_getrlimit_trampoline() -//go:linkname libc_getrlimit libc_getrlimit //go:cgo_import_dynamic libc_getrlimit getrlimit "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1432,7 +1350,6 @@ func Getrusage(who int, rusage *Rusage) (err error) { func libc_getrusage_trampoline() -//go:linkname libc_getrusage libc_getrusage //go:cgo_import_dynamic libc_getrusage getrusage "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1448,7 +1365,6 @@ func Getsid(pid int) (sid int, err error) { func libc_getsid_trampoline() -//go:linkname libc_getsid libc_getsid //go:cgo_import_dynamic libc_getsid getsid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1463,7 +1379,6 @@ func Gettimeofday(tp *Timeval) (err error) { func libc_gettimeofday_trampoline() -//go:linkname libc_gettimeofday libc_gettimeofday //go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1476,7 +1391,6 @@ func Getuid() (uid int) { func libc_getuid_trampoline() -//go:linkname libc_getuid libc_getuid //go:cgo_import_dynamic libc_getuid getuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1489,7 +1403,6 @@ func Issetugid() (tainted bool) { func libc_issetugid_trampoline() -//go:linkname libc_issetugid libc_issetugid //go:cgo_import_dynamic libc_issetugid issetugid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1505,7 +1418,6 @@ func Kqueue() (fd int, err error) { func libc_kqueue_trampoline() -//go:linkname libc_kqueue libc_kqueue //go:cgo_import_dynamic libc_kqueue kqueue "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1525,7 +1437,6 @@ func Lchown(path string, uid int, gid int) (err error) { func libc_lchown_trampoline() -//go:linkname libc_lchown libc_lchown //go:cgo_import_dynamic libc_lchown lchown "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1550,7 +1461,6 @@ func Link(path string, link string) (err error) { func libc_link_trampoline() -//go:linkname libc_link libc_link //go:cgo_import_dynamic libc_link link "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1575,7 +1485,6 @@ func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err er func libc_linkat_trampoline() -//go:linkname libc_linkat libc_linkat //go:cgo_import_dynamic libc_linkat linkat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1590,7 +1499,6 @@ func Listen(s int, backlog int) (err error) { func libc_listen_trampoline() -//go:linkname libc_listen libc_listen //go:cgo_import_dynamic libc_listen listen "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1610,7 +1518,6 @@ func Mkdir(path string, mode uint32) (err error) { func libc_mkdir_trampoline() -//go:linkname libc_mkdir libc_mkdir //go:cgo_import_dynamic libc_mkdir mkdir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1630,7 +1537,6 @@ func Mkdirat(dirfd int, path string, mode uint32) (err error) { func libc_mkdirat_trampoline() -//go:linkname libc_mkdirat libc_mkdirat //go:cgo_import_dynamic libc_mkdirat mkdirat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1650,7 +1556,6 @@ func Mkfifo(path string, mode uint32) (err error) { func libc_mkfifo_trampoline() -//go:linkname libc_mkfifo libc_mkfifo //go:cgo_import_dynamic libc_mkfifo mkfifo "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1670,7 +1575,6 @@ func Mknod(path string, mode uint32, dev int) (err error) { func libc_mknod_trampoline() -//go:linkname libc_mknod libc_mknod //go:cgo_import_dynamic libc_mknod mknod "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1691,7 +1595,6 @@ func Open(path string, mode int, perm uint32) (fd int, err error) { func libc_open_trampoline() -//go:linkname libc_open libc_open //go:cgo_import_dynamic libc_open open "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1712,7 +1615,6 @@ func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) { func libc_openat_trampoline() -//go:linkname libc_openat libc_openat //go:cgo_import_dynamic libc_openat openat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1733,7 +1635,6 @@ func Pathconf(path string, name int) (val int, err error) { func libc_pathconf_trampoline() -//go:linkname libc_pathconf libc_pathconf //go:cgo_import_dynamic libc_pathconf pathconf "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1755,7 +1656,6 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { func libc_pread_trampoline() -//go:linkname libc_pread libc_pread //go:cgo_import_dynamic libc_pread pread "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1777,7 +1677,6 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) { func libc_pwrite_trampoline() -//go:linkname libc_pwrite libc_pwrite //go:cgo_import_dynamic libc_pwrite pwrite "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1799,7 +1698,6 @@ func read(fd int, p []byte) (n int, err error) { func libc_read_trampoline() -//go:linkname libc_read libc_read //go:cgo_import_dynamic libc_read read "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1826,7 +1724,6 @@ func Readlink(path string, buf []byte) (n int, err error) { func libc_readlink_trampoline() -//go:linkname libc_readlink libc_readlink //go:cgo_import_dynamic libc_readlink readlink "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1853,7 +1750,6 @@ func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) { func libc_readlinkat_trampoline() -//go:linkname libc_readlinkat libc_readlinkat //go:cgo_import_dynamic libc_readlinkat readlinkat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1878,7 +1774,6 @@ func Rename(from string, to string) (err error) { func libc_rename_trampoline() -//go:linkname libc_rename libc_rename //go:cgo_import_dynamic libc_rename rename "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1903,7 +1798,6 @@ func Renameat(fromfd int, from string, tofd int, to string) (err error) { func libc_renameat_trampoline() -//go:linkname libc_renameat libc_renameat //go:cgo_import_dynamic libc_renameat renameat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1923,7 +1817,6 @@ func Revoke(path string) (err error) { func libc_revoke_trampoline() -//go:linkname libc_revoke libc_revoke //go:cgo_import_dynamic libc_revoke revoke "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1943,7 +1836,6 @@ func Rmdir(path string) (err error) { func libc_rmdir_trampoline() -//go:linkname libc_rmdir libc_rmdir //go:cgo_import_dynamic libc_rmdir rmdir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1959,7 +1851,6 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { func libc_lseek_trampoline() -//go:linkname libc_lseek libc_lseek //go:cgo_import_dynamic libc_lseek lseek "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1975,7 +1866,6 @@ func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err func libc_select_trampoline() -//go:linkname libc_select libc_select //go:cgo_import_dynamic libc_select select "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1990,7 +1880,6 @@ func Setegid(egid int) (err error) { func libc_setegid_trampoline() -//go:linkname libc_setegid libc_setegid //go:cgo_import_dynamic libc_setegid setegid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2005,7 +1894,6 @@ func Seteuid(euid int) (err error) { func libc_seteuid_trampoline() -//go:linkname libc_seteuid libc_seteuid //go:cgo_import_dynamic libc_seteuid seteuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2020,7 +1908,6 @@ func Setgid(gid int) (err error) { func libc_setgid_trampoline() -//go:linkname libc_setgid libc_setgid //go:cgo_import_dynamic libc_setgid setgid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2040,7 +1927,6 @@ func Setlogin(name string) (err error) { func libc_setlogin_trampoline() -//go:linkname libc_setlogin libc_setlogin //go:cgo_import_dynamic libc_setlogin setlogin "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2055,7 +1941,6 @@ func Setpgid(pid int, pgid int) (err error) { func libc_setpgid_trampoline() -//go:linkname libc_setpgid libc_setpgid //go:cgo_import_dynamic libc_setpgid setpgid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2070,7 +1955,6 @@ func Setpriority(which int, who int, prio int) (err error) { func libc_setpriority_trampoline() -//go:linkname libc_setpriority libc_setpriority //go:cgo_import_dynamic libc_setpriority setpriority "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2085,7 +1969,6 @@ func Setprivexec(flag int) (err error) { func libc_setprivexec_trampoline() -//go:linkname libc_setprivexec libc_setprivexec //go:cgo_import_dynamic libc_setprivexec setprivexec "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2100,7 +1983,6 @@ func Setregid(rgid int, egid int) (err error) { func libc_setregid_trampoline() -//go:linkname libc_setregid libc_setregid //go:cgo_import_dynamic libc_setregid setregid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2115,7 +1997,6 @@ func Setreuid(ruid int, euid int) (err error) { func libc_setreuid_trampoline() -//go:linkname libc_setreuid libc_setreuid //go:cgo_import_dynamic libc_setreuid setreuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2130,7 +2011,6 @@ func Setrlimit(which int, lim *Rlimit) (err error) { func libc_setrlimit_trampoline() -//go:linkname libc_setrlimit libc_setrlimit //go:cgo_import_dynamic libc_setrlimit setrlimit "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2146,7 +2026,6 @@ func Setsid() (pid int, err error) { func libc_setsid_trampoline() -//go:linkname libc_setsid libc_setsid //go:cgo_import_dynamic libc_setsid setsid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2161,7 +2040,6 @@ func Settimeofday(tp *Timeval) (err error) { func libc_settimeofday_trampoline() -//go:linkname libc_settimeofday libc_settimeofday //go:cgo_import_dynamic libc_settimeofday settimeofday "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2176,7 +2054,6 @@ func Setuid(uid int) (err error) { func libc_setuid_trampoline() -//go:linkname libc_setuid libc_setuid //go:cgo_import_dynamic libc_setuid setuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2201,7 +2078,6 @@ func Symlink(path string, link string) (err error) { func libc_symlink_trampoline() -//go:linkname libc_symlink libc_symlink //go:cgo_import_dynamic libc_symlink symlink "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2226,7 +2102,6 @@ func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { func libc_symlinkat_trampoline() -//go:linkname libc_symlinkat libc_symlinkat //go:cgo_import_dynamic libc_symlinkat symlinkat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2241,7 +2116,6 @@ func Sync() (err error) { func libc_sync_trampoline() -//go:linkname libc_sync libc_sync //go:cgo_import_dynamic libc_sync sync "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2261,7 +2135,6 @@ func Truncate(path string, length int64) (err error) { func libc_truncate_trampoline() -//go:linkname libc_truncate libc_truncate //go:cgo_import_dynamic libc_truncate truncate "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2274,7 +2147,6 @@ func Umask(newmask int) (oldmask int) { func libc_umask_trampoline() -//go:linkname libc_umask libc_umask //go:cgo_import_dynamic libc_umask umask "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2294,7 +2166,6 @@ func Undelete(path string) (err error) { func libc_undelete_trampoline() -//go:linkname libc_undelete libc_undelete //go:cgo_import_dynamic libc_undelete undelete "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2314,7 +2185,6 @@ func Unlink(path string) (err error) { func libc_unlink_trampoline() -//go:linkname libc_unlink libc_unlink //go:cgo_import_dynamic libc_unlink unlink "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2334,7 +2204,6 @@ func Unlinkat(dirfd int, path string, flags int) (err error) { func libc_unlinkat_trampoline() -//go:linkname libc_unlinkat libc_unlinkat //go:cgo_import_dynamic libc_unlinkat unlinkat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2354,7 +2223,6 @@ func Unmount(path string, flags int) (err error) { func libc_unmount_trampoline() -//go:linkname libc_unmount libc_unmount //go:cgo_import_dynamic libc_unmount unmount "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2376,7 +2244,6 @@ func write(fd int, p []byte) (n int, err error) { func libc_write_trampoline() -//go:linkname libc_write libc_write //go:cgo_import_dynamic libc_write write "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2392,7 +2259,6 @@ func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) ( func libc_mmap_trampoline() -//go:linkname libc_mmap libc_mmap //go:cgo_import_dynamic libc_mmap mmap "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2407,7 +2273,6 @@ func munmap(addr uintptr, length uintptr) (err error) { func libc_munmap_trampoline() -//go:linkname libc_munmap libc_munmap //go:cgo_import_dynamic libc_munmap munmap "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2444,7 +2309,6 @@ func Fstat(fd int, stat *Stat_t) (err error) { func libc_fstat64_trampoline() -//go:linkname libc_fstat64 libc_fstat64 //go:cgo_import_dynamic libc_fstat64 fstat64 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2464,7 +2328,6 @@ func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) { func libc_fstatat64_trampoline() -//go:linkname libc_fstatat64 libc_fstatat64 //go:cgo_import_dynamic libc_fstatat64 fstatat64 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2479,7 +2342,6 @@ func Fstatfs(fd int, stat *Statfs_t) (err error) { func libc_fstatfs64_trampoline() -//go:linkname libc_fstatfs64 libc_fstatfs64 //go:cgo_import_dynamic libc_fstatfs64 fstatfs64 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2495,7 +2357,6 @@ func getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) { func libc_getfsstat64_trampoline() -//go:linkname libc_getfsstat64 libc_getfsstat64 //go:cgo_import_dynamic libc_getfsstat64 getfsstat64 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2515,12 +2376,11 @@ func Lstat(path string, stat *Stat_t) (err error) { func libc_lstat64_trampoline() -//go:linkname libc_lstat64 libc_lstat64 //go:cgo_import_dynamic libc_lstat64 lstat64 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { +func ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) { _, _, e1 := syscall_syscall6(funcPC(libc_ptrace_trampoline), uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) if e1 != 0 { err = errnoErr(e1) @@ -2530,7 +2390,6 @@ func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { func libc_ptrace_trampoline() -//go:linkname libc_ptrace libc_ptrace //go:cgo_import_dynamic libc_ptrace ptrace "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2550,7 +2409,6 @@ func Stat(path string, stat *Stat_t) (err error) { func libc_stat64_trampoline() -//go:linkname libc_stat64 libc_stat64 //go:cgo_import_dynamic libc_stat64 stat64 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2570,5 +2428,4 @@ func Statfs(path string, stat *Statfs_t) (err error) { func libc_statfs64_trampoline() -//go:linkname libc_statfs64 libc_statfs64 //go:cgo_import_dynamic libc_statfs64 statfs64 "/usr/lib/libSystem.B.dylib" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.1_13.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.1_13.go index f519ce9afb3..ed437f89a9e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.1_13.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.1_13.go @@ -1,6 +1,7 @@ // go run mksyscall.go -l32 -tags darwin,arm,go1.13 syscall_darwin.1_13.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build darwin && arm && go1.13 // +build darwin,arm,go1.13 package unix @@ -24,7 +25,6 @@ func closedir(dir uintptr) (err error) { func libc_closedir_trampoline() -//go:linkname libc_closedir libc_closedir //go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -37,5 +37,4 @@ func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { func libc_readdir_r_trampoline() -//go:linkname libc_readdir_r libc_readdir_r //go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go index d6b5249c2f2..7f88cb5ea22 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go @@ -1,6 +1,7 @@ // go run mksyscall.go -l32 -tags darwin,arm,go1.12 syscall_bsd.go syscall_darwin.go syscall_darwin_arm.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build darwin && arm && go1.12 // +build darwin,arm,go1.12 package unix @@ -25,7 +26,6 @@ func getgroups(ngid int, gid *_Gid_t) (n int, err error) { func libc_getgroups_trampoline() -//go:linkname libc_getgroups libc_getgroups //go:cgo_import_dynamic libc_getgroups getgroups "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -40,7 +40,6 @@ func setgroups(ngid int, gid *_Gid_t) (err error) { func libc_setgroups_trampoline() -//go:linkname libc_setgroups libc_setgroups //go:cgo_import_dynamic libc_setgroups setgroups "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -56,7 +55,6 @@ func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err func libc_wait4_trampoline() -//go:linkname libc_wait4 libc_wait4 //go:cgo_import_dynamic libc_wait4 wait4 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -72,7 +70,6 @@ func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { func libc_accept_trampoline() -//go:linkname libc_accept libc_accept //go:cgo_import_dynamic libc_accept accept "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -87,7 +84,6 @@ func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { func libc_bind_trampoline() -//go:linkname libc_bind libc_bind //go:cgo_import_dynamic libc_bind bind "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -102,7 +98,6 @@ func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { func libc_connect_trampoline() -//go:linkname libc_connect libc_connect //go:cgo_import_dynamic libc_connect connect "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -118,7 +113,6 @@ func socket(domain int, typ int, proto int) (fd int, err error) { func libc_socket_trampoline() -//go:linkname libc_socket libc_socket //go:cgo_import_dynamic libc_socket socket "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -133,7 +127,6 @@ func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen func libc_getsockopt_trampoline() -//go:linkname libc_getsockopt libc_getsockopt //go:cgo_import_dynamic libc_getsockopt getsockopt "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -148,7 +141,6 @@ func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) func libc_setsockopt_trampoline() -//go:linkname libc_setsockopt libc_setsockopt //go:cgo_import_dynamic libc_setsockopt setsockopt "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -163,7 +155,6 @@ func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { func libc_getpeername_trampoline() -//go:linkname libc_getpeername libc_getpeername //go:cgo_import_dynamic libc_getpeername getpeername "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -178,7 +169,6 @@ func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { func libc_getsockname_trampoline() -//go:linkname libc_getsockname libc_getsockname //go:cgo_import_dynamic libc_getsockname getsockname "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -193,7 +183,6 @@ func Shutdown(s int, how int) (err error) { func libc_shutdown_trampoline() -//go:linkname libc_shutdown libc_shutdown //go:cgo_import_dynamic libc_shutdown shutdown "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -208,7 +197,6 @@ func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { func libc_socketpair_trampoline() -//go:linkname libc_socketpair libc_socketpair //go:cgo_import_dynamic libc_socketpair socketpair "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -230,7 +218,6 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl func libc_recvfrom_trampoline() -//go:linkname libc_recvfrom libc_recvfrom //go:cgo_import_dynamic libc_recvfrom recvfrom "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -251,7 +238,6 @@ func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) ( func libc_sendto_trampoline() -//go:linkname libc_sendto libc_sendto //go:cgo_import_dynamic libc_sendto sendto "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -267,7 +253,6 @@ func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { func libc_recvmsg_trampoline() -//go:linkname libc_recvmsg libc_recvmsg //go:cgo_import_dynamic libc_recvmsg recvmsg "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -283,7 +268,6 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { func libc_sendmsg_trampoline() -//go:linkname libc_sendmsg libc_sendmsg //go:cgo_import_dynamic libc_sendmsg sendmsg "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -299,7 +283,6 @@ func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, ne func libc_kevent_trampoline() -//go:linkname libc_kevent libc_kevent //go:cgo_import_dynamic libc_kevent kevent "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -319,7 +302,6 @@ func utimes(path string, timeval *[2]Timeval) (err error) { func libc_utimes_trampoline() -//go:linkname libc_utimes libc_utimes //go:cgo_import_dynamic libc_utimes utimes "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -334,7 +316,6 @@ func futimes(fd int, timeval *[2]Timeval) (err error) { func libc_futimes_trampoline() -//go:linkname libc_futimes libc_futimes //go:cgo_import_dynamic libc_futimes futimes "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -350,7 +331,6 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { func libc_poll_trampoline() -//go:linkname libc_poll libc_poll //go:cgo_import_dynamic libc_poll poll "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -371,7 +351,6 @@ func Madvise(b []byte, behav int) (err error) { func libc_madvise_trampoline() -//go:linkname libc_madvise libc_madvise //go:cgo_import_dynamic libc_madvise madvise "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -392,7 +371,6 @@ func Mlock(b []byte) (err error) { func libc_mlock_trampoline() -//go:linkname libc_mlock libc_mlock //go:cgo_import_dynamic libc_mlock mlock "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -407,7 +385,6 @@ func Mlockall(flags int) (err error) { func libc_mlockall_trampoline() -//go:linkname libc_mlockall libc_mlockall //go:cgo_import_dynamic libc_mlockall mlockall "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -428,7 +405,6 @@ func Mprotect(b []byte, prot int) (err error) { func libc_mprotect_trampoline() -//go:linkname libc_mprotect libc_mprotect //go:cgo_import_dynamic libc_mprotect mprotect "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -449,7 +425,6 @@ func Msync(b []byte, flags int) (err error) { func libc_msync_trampoline() -//go:linkname libc_msync libc_msync //go:cgo_import_dynamic libc_msync msync "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -470,7 +445,6 @@ func Munlock(b []byte) (err error) { func libc_munlock_trampoline() -//go:linkname libc_munlock libc_munlock //go:cgo_import_dynamic libc_munlock munlock "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -485,15 +459,12 @@ func Munlockall() (err error) { func libc_munlockall_trampoline() -//go:linkname libc_munlockall libc_munlockall //go:cgo_import_dynamic libc_munlockall munlockall "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe() (r int, w int, err error) { - r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0) - r = int(r0) - w = int(r1) +func pipe(p *[2]int32) (err error) { + _, _, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), uintptr(unsafe.Pointer(p)), 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -502,7 +473,6 @@ func pipe() (r int, w int, err error) { func libc_pipe_trampoline() -//go:linkname libc_pipe libc_pipe //go:cgo_import_dynamic libc_pipe pipe "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -528,7 +498,6 @@ func getxattr(path string, attr string, dest *byte, size int, position uint32, o func libc_getxattr_trampoline() -//go:linkname libc_getxattr libc_getxattr //go:cgo_import_dynamic libc_getxattr getxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -549,7 +518,6 @@ func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, optio func libc_fgetxattr_trampoline() -//go:linkname libc_fgetxattr libc_fgetxattr //go:cgo_import_dynamic libc_fgetxattr fgetxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -574,7 +542,6 @@ func setxattr(path string, attr string, data *byte, size int, position uint32, o func libc_setxattr_trampoline() -//go:linkname libc_setxattr libc_setxattr //go:cgo_import_dynamic libc_setxattr setxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -594,7 +561,6 @@ func fsetxattr(fd int, attr string, data *byte, size int, position uint32, optio func libc_fsetxattr_trampoline() -//go:linkname libc_fsetxattr libc_fsetxattr //go:cgo_import_dynamic libc_fsetxattr fsetxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -619,7 +585,6 @@ func removexattr(path string, attr string, options int) (err error) { func libc_removexattr_trampoline() -//go:linkname libc_removexattr libc_removexattr //go:cgo_import_dynamic libc_removexattr removexattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -639,7 +604,6 @@ func fremovexattr(fd int, attr string, options int) (err error) { func libc_fremovexattr_trampoline() -//go:linkname libc_fremovexattr libc_fremovexattr //go:cgo_import_dynamic libc_fremovexattr fremovexattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -660,7 +624,6 @@ func listxattr(path string, dest *byte, size int, options int) (sz int, err erro func libc_listxattr_trampoline() -//go:linkname libc_listxattr libc_listxattr //go:cgo_import_dynamic libc_listxattr listxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -676,7 +639,6 @@ func flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) { func libc_flistxattr_trampoline() -//go:linkname libc_flistxattr libc_flistxattr //go:cgo_import_dynamic libc_flistxattr flistxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -691,7 +653,6 @@ func setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintp func libc_setattrlist_trampoline() -//go:linkname libc_setattrlist libc_setattrlist //go:cgo_import_dynamic libc_setattrlist setattrlist "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -707,7 +668,6 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { func libc_fcntl_trampoline() -//go:linkname libc_fcntl libc_fcntl //go:cgo_import_dynamic libc_fcntl fcntl "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -722,7 +682,6 @@ func kill(pid int, signum int, posix int) (err error) { func libc_kill_trampoline() -//go:linkname libc_kill libc_kill //go:cgo_import_dynamic libc_kill kill "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -737,7 +696,6 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { func libc_ioctl_trampoline() -//go:linkname libc_ioctl libc_ioctl //go:cgo_import_dynamic libc_ioctl ioctl "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -758,7 +716,6 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) func libc_sysctl_trampoline() -//go:linkname libc_sysctl libc_sysctl //go:cgo_import_dynamic libc_sysctl sysctl "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -773,7 +730,6 @@ func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer func libc_sendfile_trampoline() -//go:linkname libc_sendfile libc_sendfile //go:cgo_import_dynamic libc_sendfile sendfile "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -793,7 +749,6 @@ func Access(path string, mode uint32) (err error) { func libc_access_trampoline() -//go:linkname libc_access libc_access //go:cgo_import_dynamic libc_access access "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -808,7 +763,6 @@ func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { func libc_adjtime_trampoline() -//go:linkname libc_adjtime libc_adjtime //go:cgo_import_dynamic libc_adjtime adjtime "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -828,7 +782,6 @@ func Chdir(path string) (err error) { func libc_chdir_trampoline() -//go:linkname libc_chdir libc_chdir //go:cgo_import_dynamic libc_chdir chdir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -848,7 +801,6 @@ func Chflags(path string, flags int) (err error) { func libc_chflags_trampoline() -//go:linkname libc_chflags libc_chflags //go:cgo_import_dynamic libc_chflags chflags "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -868,7 +820,6 @@ func Chmod(path string, mode uint32) (err error) { func libc_chmod_trampoline() -//go:linkname libc_chmod libc_chmod //go:cgo_import_dynamic libc_chmod chmod "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -888,7 +839,6 @@ func Chown(path string, uid int, gid int) (err error) { func libc_chown_trampoline() -//go:linkname libc_chown libc_chown //go:cgo_import_dynamic libc_chown chown "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -908,7 +858,6 @@ func Chroot(path string) (err error) { func libc_chroot_trampoline() -//go:linkname libc_chroot libc_chroot //go:cgo_import_dynamic libc_chroot chroot "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -923,7 +872,6 @@ func ClockGettime(clockid int32, time *Timespec) (err error) { func libc_clock_gettime_trampoline() -//go:linkname libc_clock_gettime libc_clock_gettime //go:cgo_import_dynamic libc_clock_gettime clock_gettime "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -938,7 +886,6 @@ func Close(fd int) (err error) { func libc_close_trampoline() -//go:linkname libc_close libc_close //go:cgo_import_dynamic libc_close close "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -963,7 +910,6 @@ func Clonefile(src string, dst string, flags int) (err error) { func libc_clonefile_trampoline() -//go:linkname libc_clonefile libc_clonefile //go:cgo_import_dynamic libc_clonefile clonefile "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -988,7 +934,6 @@ func Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) func libc_clonefileat_trampoline() -//go:linkname libc_clonefileat libc_clonefileat //go:cgo_import_dynamic libc_clonefileat clonefileat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1004,7 +949,6 @@ func Dup(fd int) (nfd int, err error) { func libc_dup_trampoline() -//go:linkname libc_dup libc_dup //go:cgo_import_dynamic libc_dup dup "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1019,7 +963,6 @@ func Dup2(from int, to int) (err error) { func libc_dup2_trampoline() -//go:linkname libc_dup2 libc_dup2 //go:cgo_import_dynamic libc_dup2 dup2 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1044,7 +987,6 @@ func Exchangedata(path1 string, path2 string, options int) (err error) { func libc_exchangedata_trampoline() -//go:linkname libc_exchangedata libc_exchangedata //go:cgo_import_dynamic libc_exchangedata exchangedata "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1056,7 +998,6 @@ func Exit(code int) { func libc_exit_trampoline() -//go:linkname libc_exit libc_exit //go:cgo_import_dynamic libc_exit exit "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1076,7 +1017,6 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { func libc_faccessat_trampoline() -//go:linkname libc_faccessat libc_faccessat //go:cgo_import_dynamic libc_faccessat faccessat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1091,7 +1031,6 @@ func Fchdir(fd int) (err error) { func libc_fchdir_trampoline() -//go:linkname libc_fchdir libc_fchdir //go:cgo_import_dynamic libc_fchdir fchdir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1106,7 +1045,6 @@ func Fchflags(fd int, flags int) (err error) { func libc_fchflags_trampoline() -//go:linkname libc_fchflags libc_fchflags //go:cgo_import_dynamic libc_fchflags fchflags "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1121,7 +1059,6 @@ func Fchmod(fd int, mode uint32) (err error) { func libc_fchmod_trampoline() -//go:linkname libc_fchmod libc_fchmod //go:cgo_import_dynamic libc_fchmod fchmod "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1141,7 +1078,6 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { func libc_fchmodat_trampoline() -//go:linkname libc_fchmodat libc_fchmodat //go:cgo_import_dynamic libc_fchmodat fchmodat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1156,7 +1092,6 @@ func Fchown(fd int, uid int, gid int) (err error) { func libc_fchown_trampoline() -//go:linkname libc_fchown libc_fchown //go:cgo_import_dynamic libc_fchown fchown "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1176,7 +1111,6 @@ func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { func libc_fchownat_trampoline() -//go:linkname libc_fchownat libc_fchownat //go:cgo_import_dynamic libc_fchownat fchownat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1196,7 +1130,6 @@ func Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error) func libc_fclonefileat_trampoline() -//go:linkname libc_fclonefileat libc_fclonefileat //go:cgo_import_dynamic libc_fclonefileat fclonefileat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1211,7 +1144,6 @@ func Flock(fd int, how int) (err error) { func libc_flock_trampoline() -//go:linkname libc_flock libc_flock //go:cgo_import_dynamic libc_flock flock "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1227,7 +1159,6 @@ func Fpathconf(fd int, name int) (val int, err error) { func libc_fpathconf_trampoline() -//go:linkname libc_fpathconf libc_fpathconf //go:cgo_import_dynamic libc_fpathconf fpathconf "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1242,7 +1173,6 @@ func Fsync(fd int) (err error) { func libc_fsync_trampoline() -//go:linkname libc_fsync libc_fsync //go:cgo_import_dynamic libc_fsync fsync "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1257,7 +1187,6 @@ func Ftruncate(fd int, length int64) (err error) { func libc_ftruncate_trampoline() -//go:linkname libc_ftruncate libc_ftruncate //go:cgo_import_dynamic libc_ftruncate ftruncate "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1279,7 +1208,6 @@ func Getcwd(buf []byte) (n int, err error) { func libc_getcwd_trampoline() -//go:linkname libc_getcwd libc_getcwd //go:cgo_import_dynamic libc_getcwd getcwd "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1292,7 +1220,6 @@ func Getdtablesize() (size int) { func libc_getdtablesize_trampoline() -//go:linkname libc_getdtablesize libc_getdtablesize //go:cgo_import_dynamic libc_getdtablesize getdtablesize "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1305,7 +1232,6 @@ func Getegid() (egid int) { func libc_getegid_trampoline() -//go:linkname libc_getegid libc_getegid //go:cgo_import_dynamic libc_getegid getegid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1318,7 +1244,6 @@ func Geteuid() (uid int) { func libc_geteuid_trampoline() -//go:linkname libc_geteuid libc_geteuid //go:cgo_import_dynamic libc_geteuid geteuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1331,7 +1256,6 @@ func Getgid() (gid int) { func libc_getgid_trampoline() -//go:linkname libc_getgid libc_getgid //go:cgo_import_dynamic libc_getgid getgid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1347,7 +1271,6 @@ func Getpgid(pid int) (pgid int, err error) { func libc_getpgid_trampoline() -//go:linkname libc_getpgid libc_getpgid //go:cgo_import_dynamic libc_getpgid getpgid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1360,7 +1283,6 @@ func Getpgrp() (pgrp int) { func libc_getpgrp_trampoline() -//go:linkname libc_getpgrp libc_getpgrp //go:cgo_import_dynamic libc_getpgrp getpgrp "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1373,7 +1295,6 @@ func Getpid() (pid int) { func libc_getpid_trampoline() -//go:linkname libc_getpid libc_getpid //go:cgo_import_dynamic libc_getpid getpid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1386,7 +1307,6 @@ func Getppid() (ppid int) { func libc_getppid_trampoline() -//go:linkname libc_getppid libc_getppid //go:cgo_import_dynamic libc_getppid getppid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1402,7 +1322,6 @@ func Getpriority(which int, who int) (prio int, err error) { func libc_getpriority_trampoline() -//go:linkname libc_getpriority libc_getpriority //go:cgo_import_dynamic libc_getpriority getpriority "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1417,7 +1336,6 @@ func Getrlimit(which int, lim *Rlimit) (err error) { func libc_getrlimit_trampoline() -//go:linkname libc_getrlimit libc_getrlimit //go:cgo_import_dynamic libc_getrlimit getrlimit "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1432,7 +1350,6 @@ func Getrusage(who int, rusage *Rusage) (err error) { func libc_getrusage_trampoline() -//go:linkname libc_getrusage libc_getrusage //go:cgo_import_dynamic libc_getrusage getrusage "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1448,7 +1365,6 @@ func Getsid(pid int) (sid int, err error) { func libc_getsid_trampoline() -//go:linkname libc_getsid libc_getsid //go:cgo_import_dynamic libc_getsid getsid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1463,7 +1379,6 @@ func Gettimeofday(tp *Timeval) (err error) { func libc_gettimeofday_trampoline() -//go:linkname libc_gettimeofday libc_gettimeofday //go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1476,7 +1391,6 @@ func Getuid() (uid int) { func libc_getuid_trampoline() -//go:linkname libc_getuid libc_getuid //go:cgo_import_dynamic libc_getuid getuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1489,7 +1403,6 @@ func Issetugid() (tainted bool) { func libc_issetugid_trampoline() -//go:linkname libc_issetugid libc_issetugid //go:cgo_import_dynamic libc_issetugid issetugid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1505,7 +1418,6 @@ func Kqueue() (fd int, err error) { func libc_kqueue_trampoline() -//go:linkname libc_kqueue libc_kqueue //go:cgo_import_dynamic libc_kqueue kqueue "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1525,7 +1437,6 @@ func Lchown(path string, uid int, gid int) (err error) { func libc_lchown_trampoline() -//go:linkname libc_lchown libc_lchown //go:cgo_import_dynamic libc_lchown lchown "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1550,7 +1461,6 @@ func Link(path string, link string) (err error) { func libc_link_trampoline() -//go:linkname libc_link libc_link //go:cgo_import_dynamic libc_link link "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1575,7 +1485,6 @@ func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err er func libc_linkat_trampoline() -//go:linkname libc_linkat libc_linkat //go:cgo_import_dynamic libc_linkat linkat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1590,7 +1499,6 @@ func Listen(s int, backlog int) (err error) { func libc_listen_trampoline() -//go:linkname libc_listen libc_listen //go:cgo_import_dynamic libc_listen listen "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1610,7 +1518,6 @@ func Mkdir(path string, mode uint32) (err error) { func libc_mkdir_trampoline() -//go:linkname libc_mkdir libc_mkdir //go:cgo_import_dynamic libc_mkdir mkdir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1630,7 +1537,6 @@ func Mkdirat(dirfd int, path string, mode uint32) (err error) { func libc_mkdirat_trampoline() -//go:linkname libc_mkdirat libc_mkdirat //go:cgo_import_dynamic libc_mkdirat mkdirat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1650,7 +1556,6 @@ func Mkfifo(path string, mode uint32) (err error) { func libc_mkfifo_trampoline() -//go:linkname libc_mkfifo libc_mkfifo //go:cgo_import_dynamic libc_mkfifo mkfifo "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1670,7 +1575,6 @@ func Mknod(path string, mode uint32, dev int) (err error) { func libc_mknod_trampoline() -//go:linkname libc_mknod libc_mknod //go:cgo_import_dynamic libc_mknod mknod "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1691,7 +1595,6 @@ func Open(path string, mode int, perm uint32) (fd int, err error) { func libc_open_trampoline() -//go:linkname libc_open libc_open //go:cgo_import_dynamic libc_open open "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1712,7 +1615,6 @@ func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) { func libc_openat_trampoline() -//go:linkname libc_openat libc_openat //go:cgo_import_dynamic libc_openat openat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1733,7 +1635,6 @@ func Pathconf(path string, name int) (val int, err error) { func libc_pathconf_trampoline() -//go:linkname libc_pathconf libc_pathconf //go:cgo_import_dynamic libc_pathconf pathconf "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1755,7 +1656,6 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { func libc_pread_trampoline() -//go:linkname libc_pread libc_pread //go:cgo_import_dynamic libc_pread pread "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1777,7 +1677,6 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) { func libc_pwrite_trampoline() -//go:linkname libc_pwrite libc_pwrite //go:cgo_import_dynamic libc_pwrite pwrite "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1799,7 +1698,6 @@ func read(fd int, p []byte) (n int, err error) { func libc_read_trampoline() -//go:linkname libc_read libc_read //go:cgo_import_dynamic libc_read read "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1826,7 +1724,6 @@ func Readlink(path string, buf []byte) (n int, err error) { func libc_readlink_trampoline() -//go:linkname libc_readlink libc_readlink //go:cgo_import_dynamic libc_readlink readlink "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1853,7 +1750,6 @@ func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) { func libc_readlinkat_trampoline() -//go:linkname libc_readlinkat libc_readlinkat //go:cgo_import_dynamic libc_readlinkat readlinkat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1878,7 +1774,6 @@ func Rename(from string, to string) (err error) { func libc_rename_trampoline() -//go:linkname libc_rename libc_rename //go:cgo_import_dynamic libc_rename rename "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1903,7 +1798,6 @@ func Renameat(fromfd int, from string, tofd int, to string) (err error) { func libc_renameat_trampoline() -//go:linkname libc_renameat libc_renameat //go:cgo_import_dynamic libc_renameat renameat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1923,7 +1817,6 @@ func Revoke(path string) (err error) { func libc_revoke_trampoline() -//go:linkname libc_revoke libc_revoke //go:cgo_import_dynamic libc_revoke revoke "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1943,7 +1836,6 @@ func Rmdir(path string) (err error) { func libc_rmdir_trampoline() -//go:linkname libc_rmdir libc_rmdir //go:cgo_import_dynamic libc_rmdir rmdir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1959,7 +1851,6 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { func libc_lseek_trampoline() -//go:linkname libc_lseek libc_lseek //go:cgo_import_dynamic libc_lseek lseek "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1975,7 +1866,6 @@ func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err func libc_select_trampoline() -//go:linkname libc_select libc_select //go:cgo_import_dynamic libc_select select "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1990,7 +1880,6 @@ func Setegid(egid int) (err error) { func libc_setegid_trampoline() -//go:linkname libc_setegid libc_setegid //go:cgo_import_dynamic libc_setegid setegid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2005,7 +1894,6 @@ func Seteuid(euid int) (err error) { func libc_seteuid_trampoline() -//go:linkname libc_seteuid libc_seteuid //go:cgo_import_dynamic libc_seteuid seteuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2020,7 +1908,6 @@ func Setgid(gid int) (err error) { func libc_setgid_trampoline() -//go:linkname libc_setgid libc_setgid //go:cgo_import_dynamic libc_setgid setgid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2040,7 +1927,6 @@ func Setlogin(name string) (err error) { func libc_setlogin_trampoline() -//go:linkname libc_setlogin libc_setlogin //go:cgo_import_dynamic libc_setlogin setlogin "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2055,7 +1941,6 @@ func Setpgid(pid int, pgid int) (err error) { func libc_setpgid_trampoline() -//go:linkname libc_setpgid libc_setpgid //go:cgo_import_dynamic libc_setpgid setpgid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2070,7 +1955,6 @@ func Setpriority(which int, who int, prio int) (err error) { func libc_setpriority_trampoline() -//go:linkname libc_setpriority libc_setpriority //go:cgo_import_dynamic libc_setpriority setpriority "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2085,7 +1969,6 @@ func Setprivexec(flag int) (err error) { func libc_setprivexec_trampoline() -//go:linkname libc_setprivexec libc_setprivexec //go:cgo_import_dynamic libc_setprivexec setprivexec "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2100,7 +1983,6 @@ func Setregid(rgid int, egid int) (err error) { func libc_setregid_trampoline() -//go:linkname libc_setregid libc_setregid //go:cgo_import_dynamic libc_setregid setregid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2115,7 +1997,6 @@ func Setreuid(ruid int, euid int) (err error) { func libc_setreuid_trampoline() -//go:linkname libc_setreuid libc_setreuid //go:cgo_import_dynamic libc_setreuid setreuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2130,7 +2011,6 @@ func Setrlimit(which int, lim *Rlimit) (err error) { func libc_setrlimit_trampoline() -//go:linkname libc_setrlimit libc_setrlimit //go:cgo_import_dynamic libc_setrlimit setrlimit "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2146,7 +2026,6 @@ func Setsid() (pid int, err error) { func libc_setsid_trampoline() -//go:linkname libc_setsid libc_setsid //go:cgo_import_dynamic libc_setsid setsid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2161,7 +2040,6 @@ func Settimeofday(tp *Timeval) (err error) { func libc_settimeofday_trampoline() -//go:linkname libc_settimeofday libc_settimeofday //go:cgo_import_dynamic libc_settimeofday settimeofday "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2176,7 +2054,6 @@ func Setuid(uid int) (err error) { func libc_setuid_trampoline() -//go:linkname libc_setuid libc_setuid //go:cgo_import_dynamic libc_setuid setuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2201,7 +2078,6 @@ func Symlink(path string, link string) (err error) { func libc_symlink_trampoline() -//go:linkname libc_symlink libc_symlink //go:cgo_import_dynamic libc_symlink symlink "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2226,7 +2102,6 @@ func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { func libc_symlinkat_trampoline() -//go:linkname libc_symlinkat libc_symlinkat //go:cgo_import_dynamic libc_symlinkat symlinkat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2241,7 +2116,6 @@ func Sync() (err error) { func libc_sync_trampoline() -//go:linkname libc_sync libc_sync //go:cgo_import_dynamic libc_sync sync "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2261,7 +2135,6 @@ func Truncate(path string, length int64) (err error) { func libc_truncate_trampoline() -//go:linkname libc_truncate libc_truncate //go:cgo_import_dynamic libc_truncate truncate "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2274,7 +2147,6 @@ func Umask(newmask int) (oldmask int) { func libc_umask_trampoline() -//go:linkname libc_umask libc_umask //go:cgo_import_dynamic libc_umask umask "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2294,7 +2166,6 @@ func Undelete(path string) (err error) { func libc_undelete_trampoline() -//go:linkname libc_undelete libc_undelete //go:cgo_import_dynamic libc_undelete undelete "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2314,7 +2185,6 @@ func Unlink(path string) (err error) { func libc_unlink_trampoline() -//go:linkname libc_unlink libc_unlink //go:cgo_import_dynamic libc_unlink unlink "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2334,7 +2204,6 @@ func Unlinkat(dirfd int, path string, flags int) (err error) { func libc_unlinkat_trampoline() -//go:linkname libc_unlinkat libc_unlinkat //go:cgo_import_dynamic libc_unlinkat unlinkat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2354,7 +2223,6 @@ func Unmount(path string, flags int) (err error) { func libc_unmount_trampoline() -//go:linkname libc_unmount libc_unmount //go:cgo_import_dynamic libc_unmount unmount "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2376,7 +2244,6 @@ func write(fd int, p []byte) (n int, err error) { func libc_write_trampoline() -//go:linkname libc_write libc_write //go:cgo_import_dynamic libc_write write "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2392,7 +2259,6 @@ func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) ( func libc_mmap_trampoline() -//go:linkname libc_mmap libc_mmap //go:cgo_import_dynamic libc_mmap mmap "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2407,7 +2273,6 @@ func munmap(addr uintptr, length uintptr) (err error) { func libc_munmap_trampoline() -//go:linkname libc_munmap libc_munmap //go:cgo_import_dynamic libc_munmap munmap "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2444,7 +2309,6 @@ func Fstat(fd int, stat *Stat_t) (err error) { func libc_fstat_trampoline() -//go:linkname libc_fstat libc_fstat //go:cgo_import_dynamic libc_fstat fstat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2464,7 +2328,6 @@ func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) { func libc_fstatat_trampoline() -//go:linkname libc_fstatat libc_fstatat //go:cgo_import_dynamic libc_fstatat fstatat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2479,7 +2342,6 @@ func Fstatfs(fd int, stat *Statfs_t) (err error) { func libc_fstatfs_trampoline() -//go:linkname libc_fstatfs libc_fstatfs //go:cgo_import_dynamic libc_fstatfs fstatfs "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2495,7 +2357,6 @@ func getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) { func libc_getfsstat_trampoline() -//go:linkname libc_getfsstat libc_getfsstat //go:cgo_import_dynamic libc_getfsstat getfsstat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2515,7 +2376,6 @@ func Lstat(path string, stat *Stat_t) (err error) { func libc_lstat_trampoline() -//go:linkname libc_lstat libc_lstat //go:cgo_import_dynamic libc_lstat lstat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2535,7 +2395,6 @@ func Stat(path string, stat *Stat_t) (err error) { func libc_stat_trampoline() -//go:linkname libc_stat libc_stat //go:cgo_import_dynamic libc_stat stat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2555,5 +2414,4 @@ func Statfs(path string, stat *Statfs_t) (err error) { func libc_statfs_trampoline() -//go:linkname libc_statfs libc_statfs //go:cgo_import_dynamic libc_statfs statfs "/usr/lib/libSystem.B.dylib" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.go index d64e6c806f5..d30ec4e29a0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.go @@ -1,6 +1,7 @@ // go run mksyscall.go -tags darwin,arm64,go1.13 syscall_darwin.1_13.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build darwin && arm64 && go1.13 // +build darwin,arm64,go1.13 package unix @@ -24,7 +25,6 @@ func closedir(dir uintptr) (err error) { func libc_closedir_trampoline() -//go:linkname libc_closedir libc_closedir //go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -37,5 +37,4 @@ func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { func libc_readdir_r_trampoline() -//go:linkname libc_readdir_r libc_readdir_r //go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 23b65a5301a..a10df58d00e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -1,6 +1,7 @@ // go run mksyscall.go -tags darwin,arm64,go1.12 syscall_bsd.go syscall_darwin.go syscall_darwin_arm64.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build darwin && arm64 && go1.12 // +build darwin,arm64,go1.12 package unix @@ -25,7 +26,6 @@ func getgroups(ngid int, gid *_Gid_t) (n int, err error) { func libc_getgroups_trampoline() -//go:linkname libc_getgroups libc_getgroups //go:cgo_import_dynamic libc_getgroups getgroups "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -40,7 +40,6 @@ func setgroups(ngid int, gid *_Gid_t) (err error) { func libc_setgroups_trampoline() -//go:linkname libc_setgroups libc_setgroups //go:cgo_import_dynamic libc_setgroups setgroups "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -56,7 +55,6 @@ func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err func libc_wait4_trampoline() -//go:linkname libc_wait4 libc_wait4 //go:cgo_import_dynamic libc_wait4 wait4 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -72,7 +70,6 @@ func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { func libc_accept_trampoline() -//go:linkname libc_accept libc_accept //go:cgo_import_dynamic libc_accept accept "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -87,7 +84,6 @@ func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { func libc_bind_trampoline() -//go:linkname libc_bind libc_bind //go:cgo_import_dynamic libc_bind bind "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -102,7 +98,6 @@ func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { func libc_connect_trampoline() -//go:linkname libc_connect libc_connect //go:cgo_import_dynamic libc_connect connect "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -118,7 +113,6 @@ func socket(domain int, typ int, proto int) (fd int, err error) { func libc_socket_trampoline() -//go:linkname libc_socket libc_socket //go:cgo_import_dynamic libc_socket socket "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -133,7 +127,6 @@ func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen func libc_getsockopt_trampoline() -//go:linkname libc_getsockopt libc_getsockopt //go:cgo_import_dynamic libc_getsockopt getsockopt "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -148,7 +141,6 @@ func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) func libc_setsockopt_trampoline() -//go:linkname libc_setsockopt libc_setsockopt //go:cgo_import_dynamic libc_setsockopt setsockopt "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -163,7 +155,6 @@ func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { func libc_getpeername_trampoline() -//go:linkname libc_getpeername libc_getpeername //go:cgo_import_dynamic libc_getpeername getpeername "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -178,7 +169,6 @@ func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { func libc_getsockname_trampoline() -//go:linkname libc_getsockname libc_getsockname //go:cgo_import_dynamic libc_getsockname getsockname "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -193,7 +183,6 @@ func Shutdown(s int, how int) (err error) { func libc_shutdown_trampoline() -//go:linkname libc_shutdown libc_shutdown //go:cgo_import_dynamic libc_shutdown shutdown "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -208,7 +197,6 @@ func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { func libc_socketpair_trampoline() -//go:linkname libc_socketpair libc_socketpair //go:cgo_import_dynamic libc_socketpair socketpair "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -230,7 +218,6 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl func libc_recvfrom_trampoline() -//go:linkname libc_recvfrom libc_recvfrom //go:cgo_import_dynamic libc_recvfrom recvfrom "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -251,7 +238,6 @@ func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) ( func libc_sendto_trampoline() -//go:linkname libc_sendto libc_sendto //go:cgo_import_dynamic libc_sendto sendto "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -267,7 +253,6 @@ func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { func libc_recvmsg_trampoline() -//go:linkname libc_recvmsg libc_recvmsg //go:cgo_import_dynamic libc_recvmsg recvmsg "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -283,7 +268,6 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { func libc_sendmsg_trampoline() -//go:linkname libc_sendmsg libc_sendmsg //go:cgo_import_dynamic libc_sendmsg sendmsg "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -299,7 +283,6 @@ func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, ne func libc_kevent_trampoline() -//go:linkname libc_kevent libc_kevent //go:cgo_import_dynamic libc_kevent kevent "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -319,7 +302,6 @@ func utimes(path string, timeval *[2]Timeval) (err error) { func libc_utimes_trampoline() -//go:linkname libc_utimes libc_utimes //go:cgo_import_dynamic libc_utimes utimes "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -334,7 +316,6 @@ func futimes(fd int, timeval *[2]Timeval) (err error) { func libc_futimes_trampoline() -//go:linkname libc_futimes libc_futimes //go:cgo_import_dynamic libc_futimes futimes "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -350,7 +331,6 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { func libc_poll_trampoline() -//go:linkname libc_poll libc_poll //go:cgo_import_dynamic libc_poll poll "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -371,7 +351,6 @@ func Madvise(b []byte, behav int) (err error) { func libc_madvise_trampoline() -//go:linkname libc_madvise libc_madvise //go:cgo_import_dynamic libc_madvise madvise "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -392,7 +371,6 @@ func Mlock(b []byte) (err error) { func libc_mlock_trampoline() -//go:linkname libc_mlock libc_mlock //go:cgo_import_dynamic libc_mlock mlock "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -407,7 +385,6 @@ func Mlockall(flags int) (err error) { func libc_mlockall_trampoline() -//go:linkname libc_mlockall libc_mlockall //go:cgo_import_dynamic libc_mlockall mlockall "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -428,7 +405,6 @@ func Mprotect(b []byte, prot int) (err error) { func libc_mprotect_trampoline() -//go:linkname libc_mprotect libc_mprotect //go:cgo_import_dynamic libc_mprotect mprotect "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -449,7 +425,6 @@ func Msync(b []byte, flags int) (err error) { func libc_msync_trampoline() -//go:linkname libc_msync libc_msync //go:cgo_import_dynamic libc_msync msync "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -470,7 +445,6 @@ func Munlock(b []byte) (err error) { func libc_munlock_trampoline() -//go:linkname libc_munlock libc_munlock //go:cgo_import_dynamic libc_munlock munlock "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -485,15 +459,12 @@ func Munlockall() (err error) { func libc_munlockall_trampoline() -//go:linkname libc_munlockall libc_munlockall //go:cgo_import_dynamic libc_munlockall munlockall "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe() (r int, w int, err error) { - r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0) - r = int(r0) - w = int(r1) +func pipe(p *[2]int32) (err error) { + _, _, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), uintptr(unsafe.Pointer(p)), 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -502,7 +473,6 @@ func pipe() (r int, w int, err error) { func libc_pipe_trampoline() -//go:linkname libc_pipe libc_pipe //go:cgo_import_dynamic libc_pipe pipe "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -528,7 +498,6 @@ func getxattr(path string, attr string, dest *byte, size int, position uint32, o func libc_getxattr_trampoline() -//go:linkname libc_getxattr libc_getxattr //go:cgo_import_dynamic libc_getxattr getxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -549,7 +518,6 @@ func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, optio func libc_fgetxattr_trampoline() -//go:linkname libc_fgetxattr libc_fgetxattr //go:cgo_import_dynamic libc_fgetxattr fgetxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -574,7 +542,6 @@ func setxattr(path string, attr string, data *byte, size int, position uint32, o func libc_setxattr_trampoline() -//go:linkname libc_setxattr libc_setxattr //go:cgo_import_dynamic libc_setxattr setxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -594,7 +561,6 @@ func fsetxattr(fd int, attr string, data *byte, size int, position uint32, optio func libc_fsetxattr_trampoline() -//go:linkname libc_fsetxattr libc_fsetxattr //go:cgo_import_dynamic libc_fsetxattr fsetxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -619,7 +585,6 @@ func removexattr(path string, attr string, options int) (err error) { func libc_removexattr_trampoline() -//go:linkname libc_removexattr libc_removexattr //go:cgo_import_dynamic libc_removexattr removexattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -639,7 +604,6 @@ func fremovexattr(fd int, attr string, options int) (err error) { func libc_fremovexattr_trampoline() -//go:linkname libc_fremovexattr libc_fremovexattr //go:cgo_import_dynamic libc_fremovexattr fremovexattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -660,7 +624,6 @@ func listxattr(path string, dest *byte, size int, options int) (sz int, err erro func libc_listxattr_trampoline() -//go:linkname libc_listxattr libc_listxattr //go:cgo_import_dynamic libc_listxattr listxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -676,7 +639,6 @@ func flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) { func libc_flistxattr_trampoline() -//go:linkname libc_flistxattr libc_flistxattr //go:cgo_import_dynamic libc_flistxattr flistxattr "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -691,7 +653,6 @@ func setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintp func libc_setattrlist_trampoline() -//go:linkname libc_setattrlist libc_setattrlist //go:cgo_import_dynamic libc_setattrlist setattrlist "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -707,7 +668,6 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { func libc_fcntl_trampoline() -//go:linkname libc_fcntl libc_fcntl //go:cgo_import_dynamic libc_fcntl fcntl "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -722,7 +682,6 @@ func kill(pid int, signum int, posix int) (err error) { func libc_kill_trampoline() -//go:linkname libc_kill libc_kill //go:cgo_import_dynamic libc_kill kill "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -737,7 +696,6 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { func libc_ioctl_trampoline() -//go:linkname libc_ioctl libc_ioctl //go:cgo_import_dynamic libc_ioctl ioctl "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -758,7 +716,6 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) func libc_sysctl_trampoline() -//go:linkname libc_sysctl libc_sysctl //go:cgo_import_dynamic libc_sysctl sysctl "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -773,7 +730,6 @@ func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer func libc_sendfile_trampoline() -//go:linkname libc_sendfile libc_sendfile //go:cgo_import_dynamic libc_sendfile sendfile "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -793,7 +749,6 @@ func Access(path string, mode uint32) (err error) { func libc_access_trampoline() -//go:linkname libc_access libc_access //go:cgo_import_dynamic libc_access access "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -808,7 +763,6 @@ func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { func libc_adjtime_trampoline() -//go:linkname libc_adjtime libc_adjtime //go:cgo_import_dynamic libc_adjtime adjtime "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -828,7 +782,6 @@ func Chdir(path string) (err error) { func libc_chdir_trampoline() -//go:linkname libc_chdir libc_chdir //go:cgo_import_dynamic libc_chdir chdir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -848,7 +801,6 @@ func Chflags(path string, flags int) (err error) { func libc_chflags_trampoline() -//go:linkname libc_chflags libc_chflags //go:cgo_import_dynamic libc_chflags chflags "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -868,7 +820,6 @@ func Chmod(path string, mode uint32) (err error) { func libc_chmod_trampoline() -//go:linkname libc_chmod libc_chmod //go:cgo_import_dynamic libc_chmod chmod "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -888,7 +839,6 @@ func Chown(path string, uid int, gid int) (err error) { func libc_chown_trampoline() -//go:linkname libc_chown libc_chown //go:cgo_import_dynamic libc_chown chown "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -908,7 +858,6 @@ func Chroot(path string) (err error) { func libc_chroot_trampoline() -//go:linkname libc_chroot libc_chroot //go:cgo_import_dynamic libc_chroot chroot "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -923,7 +872,6 @@ func ClockGettime(clockid int32, time *Timespec) (err error) { func libc_clock_gettime_trampoline() -//go:linkname libc_clock_gettime libc_clock_gettime //go:cgo_import_dynamic libc_clock_gettime clock_gettime "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -938,7 +886,6 @@ func Close(fd int) (err error) { func libc_close_trampoline() -//go:linkname libc_close libc_close //go:cgo_import_dynamic libc_close close "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -963,7 +910,6 @@ func Clonefile(src string, dst string, flags int) (err error) { func libc_clonefile_trampoline() -//go:linkname libc_clonefile libc_clonefile //go:cgo_import_dynamic libc_clonefile clonefile "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -988,7 +934,6 @@ func Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) func libc_clonefileat_trampoline() -//go:linkname libc_clonefileat libc_clonefileat //go:cgo_import_dynamic libc_clonefileat clonefileat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1004,7 +949,6 @@ func Dup(fd int) (nfd int, err error) { func libc_dup_trampoline() -//go:linkname libc_dup libc_dup //go:cgo_import_dynamic libc_dup dup "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1019,7 +963,6 @@ func Dup2(from int, to int) (err error) { func libc_dup2_trampoline() -//go:linkname libc_dup2 libc_dup2 //go:cgo_import_dynamic libc_dup2 dup2 "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1044,7 +987,6 @@ func Exchangedata(path1 string, path2 string, options int) (err error) { func libc_exchangedata_trampoline() -//go:linkname libc_exchangedata libc_exchangedata //go:cgo_import_dynamic libc_exchangedata exchangedata "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1056,7 +998,6 @@ func Exit(code int) { func libc_exit_trampoline() -//go:linkname libc_exit libc_exit //go:cgo_import_dynamic libc_exit exit "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1076,7 +1017,6 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { func libc_faccessat_trampoline() -//go:linkname libc_faccessat libc_faccessat //go:cgo_import_dynamic libc_faccessat faccessat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1091,7 +1031,6 @@ func Fchdir(fd int) (err error) { func libc_fchdir_trampoline() -//go:linkname libc_fchdir libc_fchdir //go:cgo_import_dynamic libc_fchdir fchdir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1106,7 +1045,6 @@ func Fchflags(fd int, flags int) (err error) { func libc_fchflags_trampoline() -//go:linkname libc_fchflags libc_fchflags //go:cgo_import_dynamic libc_fchflags fchflags "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1121,7 +1059,6 @@ func Fchmod(fd int, mode uint32) (err error) { func libc_fchmod_trampoline() -//go:linkname libc_fchmod libc_fchmod //go:cgo_import_dynamic libc_fchmod fchmod "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1141,7 +1078,6 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { func libc_fchmodat_trampoline() -//go:linkname libc_fchmodat libc_fchmodat //go:cgo_import_dynamic libc_fchmodat fchmodat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1156,7 +1092,6 @@ func Fchown(fd int, uid int, gid int) (err error) { func libc_fchown_trampoline() -//go:linkname libc_fchown libc_fchown //go:cgo_import_dynamic libc_fchown fchown "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1176,7 +1111,6 @@ func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { func libc_fchownat_trampoline() -//go:linkname libc_fchownat libc_fchownat //go:cgo_import_dynamic libc_fchownat fchownat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1196,7 +1130,6 @@ func Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error) func libc_fclonefileat_trampoline() -//go:linkname libc_fclonefileat libc_fclonefileat //go:cgo_import_dynamic libc_fclonefileat fclonefileat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1211,7 +1144,6 @@ func Flock(fd int, how int) (err error) { func libc_flock_trampoline() -//go:linkname libc_flock libc_flock //go:cgo_import_dynamic libc_flock flock "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1227,7 +1159,6 @@ func Fpathconf(fd int, name int) (val int, err error) { func libc_fpathconf_trampoline() -//go:linkname libc_fpathconf libc_fpathconf //go:cgo_import_dynamic libc_fpathconf fpathconf "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1242,7 +1173,6 @@ func Fsync(fd int) (err error) { func libc_fsync_trampoline() -//go:linkname libc_fsync libc_fsync //go:cgo_import_dynamic libc_fsync fsync "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1257,7 +1187,6 @@ func Ftruncate(fd int, length int64) (err error) { func libc_ftruncate_trampoline() -//go:linkname libc_ftruncate libc_ftruncate //go:cgo_import_dynamic libc_ftruncate ftruncate "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1279,7 +1208,6 @@ func Getcwd(buf []byte) (n int, err error) { func libc_getcwd_trampoline() -//go:linkname libc_getcwd libc_getcwd //go:cgo_import_dynamic libc_getcwd getcwd "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1292,7 +1220,6 @@ func Getdtablesize() (size int) { func libc_getdtablesize_trampoline() -//go:linkname libc_getdtablesize libc_getdtablesize //go:cgo_import_dynamic libc_getdtablesize getdtablesize "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1305,7 +1232,6 @@ func Getegid() (egid int) { func libc_getegid_trampoline() -//go:linkname libc_getegid libc_getegid //go:cgo_import_dynamic libc_getegid getegid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1318,7 +1244,6 @@ func Geteuid() (uid int) { func libc_geteuid_trampoline() -//go:linkname libc_geteuid libc_geteuid //go:cgo_import_dynamic libc_geteuid geteuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1331,7 +1256,6 @@ func Getgid() (gid int) { func libc_getgid_trampoline() -//go:linkname libc_getgid libc_getgid //go:cgo_import_dynamic libc_getgid getgid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1347,7 +1271,6 @@ func Getpgid(pid int) (pgid int, err error) { func libc_getpgid_trampoline() -//go:linkname libc_getpgid libc_getpgid //go:cgo_import_dynamic libc_getpgid getpgid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1360,7 +1283,6 @@ func Getpgrp() (pgrp int) { func libc_getpgrp_trampoline() -//go:linkname libc_getpgrp libc_getpgrp //go:cgo_import_dynamic libc_getpgrp getpgrp "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1373,7 +1295,6 @@ func Getpid() (pid int) { func libc_getpid_trampoline() -//go:linkname libc_getpid libc_getpid //go:cgo_import_dynamic libc_getpid getpid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1386,7 +1307,6 @@ func Getppid() (ppid int) { func libc_getppid_trampoline() -//go:linkname libc_getppid libc_getppid //go:cgo_import_dynamic libc_getppid getppid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1402,7 +1322,6 @@ func Getpriority(which int, who int) (prio int, err error) { func libc_getpriority_trampoline() -//go:linkname libc_getpriority libc_getpriority //go:cgo_import_dynamic libc_getpriority getpriority "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1417,7 +1336,6 @@ func Getrlimit(which int, lim *Rlimit) (err error) { func libc_getrlimit_trampoline() -//go:linkname libc_getrlimit libc_getrlimit //go:cgo_import_dynamic libc_getrlimit getrlimit "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1432,7 +1350,6 @@ func Getrusage(who int, rusage *Rusage) (err error) { func libc_getrusage_trampoline() -//go:linkname libc_getrusage libc_getrusage //go:cgo_import_dynamic libc_getrusage getrusage "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1448,7 +1365,6 @@ func Getsid(pid int) (sid int, err error) { func libc_getsid_trampoline() -//go:linkname libc_getsid libc_getsid //go:cgo_import_dynamic libc_getsid getsid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1463,7 +1379,6 @@ func Gettimeofday(tp *Timeval) (err error) { func libc_gettimeofday_trampoline() -//go:linkname libc_gettimeofday libc_gettimeofday //go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1476,7 +1391,6 @@ func Getuid() (uid int) { func libc_getuid_trampoline() -//go:linkname libc_getuid libc_getuid //go:cgo_import_dynamic libc_getuid getuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1489,7 +1403,6 @@ func Issetugid() (tainted bool) { func libc_issetugid_trampoline() -//go:linkname libc_issetugid libc_issetugid //go:cgo_import_dynamic libc_issetugid issetugid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1505,7 +1418,6 @@ func Kqueue() (fd int, err error) { func libc_kqueue_trampoline() -//go:linkname libc_kqueue libc_kqueue //go:cgo_import_dynamic libc_kqueue kqueue "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1525,7 +1437,6 @@ func Lchown(path string, uid int, gid int) (err error) { func libc_lchown_trampoline() -//go:linkname libc_lchown libc_lchown //go:cgo_import_dynamic libc_lchown lchown "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1550,7 +1461,6 @@ func Link(path string, link string) (err error) { func libc_link_trampoline() -//go:linkname libc_link libc_link //go:cgo_import_dynamic libc_link link "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1575,7 +1485,6 @@ func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err er func libc_linkat_trampoline() -//go:linkname libc_linkat libc_linkat //go:cgo_import_dynamic libc_linkat linkat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1590,7 +1499,6 @@ func Listen(s int, backlog int) (err error) { func libc_listen_trampoline() -//go:linkname libc_listen libc_listen //go:cgo_import_dynamic libc_listen listen "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1610,7 +1518,6 @@ func Mkdir(path string, mode uint32) (err error) { func libc_mkdir_trampoline() -//go:linkname libc_mkdir libc_mkdir //go:cgo_import_dynamic libc_mkdir mkdir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1630,7 +1537,6 @@ func Mkdirat(dirfd int, path string, mode uint32) (err error) { func libc_mkdirat_trampoline() -//go:linkname libc_mkdirat libc_mkdirat //go:cgo_import_dynamic libc_mkdirat mkdirat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1650,7 +1556,6 @@ func Mkfifo(path string, mode uint32) (err error) { func libc_mkfifo_trampoline() -//go:linkname libc_mkfifo libc_mkfifo //go:cgo_import_dynamic libc_mkfifo mkfifo "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1670,7 +1575,6 @@ func Mknod(path string, mode uint32, dev int) (err error) { func libc_mknod_trampoline() -//go:linkname libc_mknod libc_mknod //go:cgo_import_dynamic libc_mknod mknod "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1691,7 +1595,6 @@ func Open(path string, mode int, perm uint32) (fd int, err error) { func libc_open_trampoline() -//go:linkname libc_open libc_open //go:cgo_import_dynamic libc_open open "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1712,7 +1615,6 @@ func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) { func libc_openat_trampoline() -//go:linkname libc_openat libc_openat //go:cgo_import_dynamic libc_openat openat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1733,7 +1635,6 @@ func Pathconf(path string, name int) (val int, err error) { func libc_pathconf_trampoline() -//go:linkname libc_pathconf libc_pathconf //go:cgo_import_dynamic libc_pathconf pathconf "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1755,7 +1656,6 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { func libc_pread_trampoline() -//go:linkname libc_pread libc_pread //go:cgo_import_dynamic libc_pread pread "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1777,7 +1677,6 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) { func libc_pwrite_trampoline() -//go:linkname libc_pwrite libc_pwrite //go:cgo_import_dynamic libc_pwrite pwrite "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1799,7 +1698,6 @@ func read(fd int, p []byte) (n int, err error) { func libc_read_trampoline() -//go:linkname libc_read libc_read //go:cgo_import_dynamic libc_read read "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1826,7 +1724,6 @@ func Readlink(path string, buf []byte) (n int, err error) { func libc_readlink_trampoline() -//go:linkname libc_readlink libc_readlink //go:cgo_import_dynamic libc_readlink readlink "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1853,7 +1750,6 @@ func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) { func libc_readlinkat_trampoline() -//go:linkname libc_readlinkat libc_readlinkat //go:cgo_import_dynamic libc_readlinkat readlinkat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1878,7 +1774,6 @@ func Rename(from string, to string) (err error) { func libc_rename_trampoline() -//go:linkname libc_rename libc_rename //go:cgo_import_dynamic libc_rename rename "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1903,7 +1798,6 @@ func Renameat(fromfd int, from string, tofd int, to string) (err error) { func libc_renameat_trampoline() -//go:linkname libc_renameat libc_renameat //go:cgo_import_dynamic libc_renameat renameat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1923,7 +1817,6 @@ func Revoke(path string) (err error) { func libc_revoke_trampoline() -//go:linkname libc_revoke libc_revoke //go:cgo_import_dynamic libc_revoke revoke "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1943,7 +1836,6 @@ func Rmdir(path string) (err error) { func libc_rmdir_trampoline() -//go:linkname libc_rmdir libc_rmdir //go:cgo_import_dynamic libc_rmdir rmdir "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1959,7 +1851,6 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { func libc_lseek_trampoline() -//go:linkname libc_lseek libc_lseek //go:cgo_import_dynamic libc_lseek lseek "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1975,7 +1866,6 @@ func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err func libc_select_trampoline() -//go:linkname libc_select libc_select //go:cgo_import_dynamic libc_select select "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1990,7 +1880,6 @@ func Setegid(egid int) (err error) { func libc_setegid_trampoline() -//go:linkname libc_setegid libc_setegid //go:cgo_import_dynamic libc_setegid setegid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2005,7 +1894,6 @@ func Seteuid(euid int) (err error) { func libc_seteuid_trampoline() -//go:linkname libc_seteuid libc_seteuid //go:cgo_import_dynamic libc_seteuid seteuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2020,7 +1908,6 @@ func Setgid(gid int) (err error) { func libc_setgid_trampoline() -//go:linkname libc_setgid libc_setgid //go:cgo_import_dynamic libc_setgid setgid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2040,7 +1927,6 @@ func Setlogin(name string) (err error) { func libc_setlogin_trampoline() -//go:linkname libc_setlogin libc_setlogin //go:cgo_import_dynamic libc_setlogin setlogin "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2055,7 +1941,6 @@ func Setpgid(pid int, pgid int) (err error) { func libc_setpgid_trampoline() -//go:linkname libc_setpgid libc_setpgid //go:cgo_import_dynamic libc_setpgid setpgid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2070,7 +1955,6 @@ func Setpriority(which int, who int, prio int) (err error) { func libc_setpriority_trampoline() -//go:linkname libc_setpriority libc_setpriority //go:cgo_import_dynamic libc_setpriority setpriority "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2085,7 +1969,6 @@ func Setprivexec(flag int) (err error) { func libc_setprivexec_trampoline() -//go:linkname libc_setprivexec libc_setprivexec //go:cgo_import_dynamic libc_setprivexec setprivexec "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2100,7 +1983,6 @@ func Setregid(rgid int, egid int) (err error) { func libc_setregid_trampoline() -//go:linkname libc_setregid libc_setregid //go:cgo_import_dynamic libc_setregid setregid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2115,7 +1997,6 @@ func Setreuid(ruid int, euid int) (err error) { func libc_setreuid_trampoline() -//go:linkname libc_setreuid libc_setreuid //go:cgo_import_dynamic libc_setreuid setreuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2130,7 +2011,6 @@ func Setrlimit(which int, lim *Rlimit) (err error) { func libc_setrlimit_trampoline() -//go:linkname libc_setrlimit libc_setrlimit //go:cgo_import_dynamic libc_setrlimit setrlimit "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2146,7 +2026,6 @@ func Setsid() (pid int, err error) { func libc_setsid_trampoline() -//go:linkname libc_setsid libc_setsid //go:cgo_import_dynamic libc_setsid setsid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2161,7 +2040,6 @@ func Settimeofday(tp *Timeval) (err error) { func libc_settimeofday_trampoline() -//go:linkname libc_settimeofday libc_settimeofday //go:cgo_import_dynamic libc_settimeofday settimeofday "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2176,7 +2054,6 @@ func Setuid(uid int) (err error) { func libc_setuid_trampoline() -//go:linkname libc_setuid libc_setuid //go:cgo_import_dynamic libc_setuid setuid "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2201,7 +2078,6 @@ func Symlink(path string, link string) (err error) { func libc_symlink_trampoline() -//go:linkname libc_symlink libc_symlink //go:cgo_import_dynamic libc_symlink symlink "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2226,7 +2102,6 @@ func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { func libc_symlinkat_trampoline() -//go:linkname libc_symlinkat libc_symlinkat //go:cgo_import_dynamic libc_symlinkat symlinkat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2241,7 +2116,6 @@ func Sync() (err error) { func libc_sync_trampoline() -//go:linkname libc_sync libc_sync //go:cgo_import_dynamic libc_sync sync "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2261,7 +2135,6 @@ func Truncate(path string, length int64) (err error) { func libc_truncate_trampoline() -//go:linkname libc_truncate libc_truncate //go:cgo_import_dynamic libc_truncate truncate "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2274,7 +2147,6 @@ func Umask(newmask int) (oldmask int) { func libc_umask_trampoline() -//go:linkname libc_umask libc_umask //go:cgo_import_dynamic libc_umask umask "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2294,7 +2166,6 @@ func Undelete(path string) (err error) { func libc_undelete_trampoline() -//go:linkname libc_undelete libc_undelete //go:cgo_import_dynamic libc_undelete undelete "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2314,7 +2185,6 @@ func Unlink(path string) (err error) { func libc_unlink_trampoline() -//go:linkname libc_unlink libc_unlink //go:cgo_import_dynamic libc_unlink unlink "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2334,7 +2204,6 @@ func Unlinkat(dirfd int, path string, flags int) (err error) { func libc_unlinkat_trampoline() -//go:linkname libc_unlinkat libc_unlinkat //go:cgo_import_dynamic libc_unlinkat unlinkat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2354,7 +2223,6 @@ func Unmount(path string, flags int) (err error) { func libc_unmount_trampoline() -//go:linkname libc_unmount libc_unmount //go:cgo_import_dynamic libc_unmount unmount "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2376,7 +2244,6 @@ func write(fd int, p []byte) (n int, err error) { func libc_write_trampoline() -//go:linkname libc_write libc_write //go:cgo_import_dynamic libc_write write "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2392,7 +2259,6 @@ func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) ( func libc_mmap_trampoline() -//go:linkname libc_mmap libc_mmap //go:cgo_import_dynamic libc_mmap mmap "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2407,7 +2273,6 @@ func munmap(addr uintptr, length uintptr) (err error) { func libc_munmap_trampoline() -//go:linkname libc_munmap libc_munmap //go:cgo_import_dynamic libc_munmap munmap "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2444,7 +2309,6 @@ func Fstat(fd int, stat *Stat_t) (err error) { func libc_fstat_trampoline() -//go:linkname libc_fstat libc_fstat //go:cgo_import_dynamic libc_fstat fstat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2464,7 +2328,6 @@ func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) { func libc_fstatat_trampoline() -//go:linkname libc_fstatat libc_fstatat //go:cgo_import_dynamic libc_fstatat fstatat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2479,7 +2342,6 @@ func Fstatfs(fd int, stat *Statfs_t) (err error) { func libc_fstatfs_trampoline() -//go:linkname libc_fstatfs libc_fstatfs //go:cgo_import_dynamic libc_fstatfs fstatfs "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2495,7 +2357,6 @@ func getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) { func libc_getfsstat_trampoline() -//go:linkname libc_getfsstat libc_getfsstat //go:cgo_import_dynamic libc_getfsstat getfsstat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2515,12 +2376,11 @@ func Lstat(path string, stat *Stat_t) (err error) { func libc_lstat_trampoline() -//go:linkname libc_lstat libc_lstat //go:cgo_import_dynamic libc_lstat lstat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { +func ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) { _, _, e1 := syscall_syscall6(funcPC(libc_ptrace_trampoline), uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) if e1 != 0 { err = errnoErr(e1) @@ -2530,7 +2390,6 @@ func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { func libc_ptrace_trampoline() -//go:linkname libc_ptrace libc_ptrace //go:cgo_import_dynamic libc_ptrace ptrace "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2550,7 +2409,6 @@ func Stat(path string, stat *Stat_t) (err error) { func libc_stat_trampoline() -//go:linkname libc_stat libc_stat //go:cgo_import_dynamic libc_stat stat "/usr/lib/libSystem.B.dylib" // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2570,5 +2428,4 @@ func Statfs(path string, stat *Statfs_t) (err error) { func libc_statfs_trampoline() -//go:linkname libc_statfs libc_statfs //go:cgo_import_dynamic libc_statfs statfs "/usr/lib/libSystem.B.dylib" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go index 1aaccd3615e..1b6eedfa611 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go @@ -1,6 +1,7 @@ // go run mksyscall.go -dragonfly -tags dragonfly,amd64 syscall_bsd.go syscall_dragonfly.go syscall_dragonfly_amd64.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build dragonfly && amd64 // +build dragonfly,amd64 package unix @@ -362,8 +363,10 @@ func pipe() (r int, w int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe2(p *[2]_C_int, flags int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) +func pipe2(p *[2]_C_int, flags int) (r int, w int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + r = int(r0) + w = int(r1) if e1 != 0 { err = errnoErr(e1) } diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go index 600f1d26d21..3e9bddb7b22 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go @@ -1,6 +1,7 @@ // go run mksyscall.go -l32 -tags freebsd,386 syscall_bsd.go syscall_freebsd.go syscall_freebsd_386.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build freebsd && 386 // +build freebsd,386 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go index 064934b0d13..c72a462b91e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go @@ -1,6 +1,7 @@ // go run mksyscall.go -tags freebsd,amd64 syscall_bsd.go syscall_freebsd.go syscall_freebsd_amd64.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build freebsd && amd64 // +build freebsd,amd64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go index 31d2c461657..530d5df90c0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go @@ -1,6 +1,7 @@ // go run mksyscall.go -l32 -arm -tags freebsd,arm syscall_bsd.go syscall_freebsd.go syscall_freebsd_arm.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build freebsd && arm // +build freebsd,arm package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go index 4adaaa56183..71e7df9e855 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go @@ -1,6 +1,7 @@ // go run mksyscall.go -tags freebsd,arm64 syscall_bsd.go syscall_freebsd.go syscall_freebsd_arm64.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build freebsd && arm64 // +build freebsd,arm64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go index d3af083f4e7..af5cb064ec4 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go @@ -1,6 +1,7 @@ // go run mksyscall_solaris.go -illumos -tags illumos,amd64 syscall_illumos.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build illumos && amd64 // +build illumos,amd64 package unix @@ -14,14 +15,16 @@ import ( //go:cgo_import_dynamic libc_writev writev "libc.so" //go:cgo_import_dynamic libc_pwritev pwritev "libc.so" //go:cgo_import_dynamic libc_accept4 accept4 "libsocket.so" -//go:cgo_import_dynamic libc_pipe2 pipe2 "libc.so" +//go:cgo_import_dynamic libc_putmsg putmsg "libc.so" +//go:cgo_import_dynamic libc_getmsg getmsg "libc.so" //go:linkname procreadv libc_readv //go:linkname procpreadv libc_preadv //go:linkname procwritev libc_writev //go:linkname procpwritev libc_pwritev //go:linkname procaccept4 libc_accept4 -//go:linkname procpipe2 libc_pipe2 +//go:linkname procputmsg libc_putmsg +//go:linkname procgetmsg libc_getmsg var ( procreadv, @@ -29,7 +32,8 @@ var ( procwritev, procpwritev, procaccept4, - procpipe2 syscallFunc + procputmsg, + procgetmsg syscallFunc ) // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -105,8 +109,18 @@ func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe2(p *[2]_C_int, flags int) (err error) { - _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procpipe2)), 2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0, 0, 0, 0) +func putmsg(fd int, clptr *strbuf, dataptr *strbuf, flags int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procputmsg)), 4, uintptr(fd), uintptr(unsafe.Pointer(clptr)), uintptr(unsafe.Pointer(dataptr)), uintptr(flags), 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getmsg(fd int, clptr *strbuf, dataptr *strbuf, flags *int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetmsg)), 4, uintptr(fd), uintptr(unsafe.Pointer(clptr)), uintptr(unsafe.Pointer(dataptr)), uintptr(unsafe.Pointer(flags)), 0, 0) if e1 != 0 { err = e1 } diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 2fbbbe5a898..7305cc915b7 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -1,5 +1,6 @@ // Code generated by mkmerge.go; DO NOT EDIT. +//go:build linux // +build linux package unix @@ -531,6 +532,16 @@ func Close(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func CloseRange(first uint, last uint, flags uint) (err error) { + _, _, e1 := Syscall(SYS_CLOSE_RANGE, uintptr(first), uintptr(last), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) { r0, _, e1 := Syscall6(SYS_COPY_FILE_RANGE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) n = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go index 19ebd3ff75f..e37096e4dec 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go @@ -1,6 +1,7 @@ // go run mksyscall.go -l32 -tags linux,386 syscall_linux.go syscall_linux_386.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build linux && 386 // +build linux,386 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go index 5c562182a19..9919d8486d4 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go @@ -1,6 +1,7 @@ // go run mksyscall.go -tags linux,amd64 syscall_linux.go syscall_linux_amd64.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build linux && amd64 // +build linux,amd64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go index dc69d99c612..076754d48d1 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go @@ -1,6 +1,7 @@ // go run mksyscall.go -l32 -arm -tags linux,arm syscall_linux.go syscall_linux_arm.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build linux && arm // +build linux,arm package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go index 1b897dee05d..e893f987f91 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go @@ -1,6 +1,7 @@ // go run mksyscall.go -tags linux,arm64 syscall_linux.go syscall_linux_arm64.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build linux && arm64 // +build linux,arm64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go index 49186843ae5..4703cf3c338 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go @@ -1,6 +1,7 @@ // go run mksyscall.go -b32 -arm -tags linux,mips syscall_linux.go syscall_linux_mipsx.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build linux && mips // +build linux,mips package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go index 9171d3bd2a6..a134f9a4d2e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go @@ -1,6 +1,7 @@ // go run mksyscall.go -tags linux,mips64 syscall_linux.go syscall_linux_mips64x.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build linux && mips64 // +build linux,mips64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go index 82286f04f9a..b1fff2d946a 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go @@ -1,6 +1,7 @@ // go run mksyscall.go -tags linux,mips64le syscall_linux.go syscall_linux_mips64x.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build linux && mips64le // +build linux,mips64le package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go index 15920621c47..d13d6da01ef 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go @@ -1,6 +1,7 @@ // go run mksyscall.go -l32 -arm -tags linux,mipsle syscall_linux.go syscall_linux_mipsx.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build linux && mipsle // +build linux,mipsle package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go index 73a42e2ccba..da8ec039666 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go @@ -1,6 +1,7 @@ // go run mksyscall.go -tags linux,ppc64 syscall_linux.go syscall_linux_ppc64x.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build linux && ppc64 // +build linux,ppc64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go index 6b85595366a..083f493bb6f 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go @@ -1,6 +1,7 @@ // go run mksyscall.go -tags linux,ppc64le syscall_linux.go syscall_linux_ppc64x.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build linux && ppc64le // +build linux,ppc64le package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go index b76133447e8..63b393b8027 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go @@ -1,6 +1,7 @@ // go run mksyscall.go -tags linux,riscv64 syscall_linux.go syscall_linux_riscv64.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build linux && riscv64 // +build linux,riscv64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go index d7032ab1e4a..bb347407d3d 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go @@ -1,6 +1,7 @@ // go run mksyscall.go -tags linux,s390x syscall_linux.go syscall_linux_s390x.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build linux && s390x // +build linux,s390x package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go index bcbbdd906e8..8edc517e1e6 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go @@ -1,6 +1,7 @@ // go run mksyscall.go -tags linux,sparc64 syscall_linux.go syscall_linux_sparc64.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build linux && sparc64 // +build linux,sparc64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go index 3bbd9e39cda..4726ab30a8f 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go @@ -1,6 +1,7 @@ // go run mksyscall.go -l32 -netbsd -tags netbsd,386 syscall_bsd.go syscall_netbsd.go syscall_netbsd_386.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build netbsd && 386 // +build netbsd,386 package unix @@ -362,6 +363,16 @@ func pipe() (fd1 int, fd2 int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getdents(fd int, buf []byte) (n int, err error) { var _p0 unsafe.Pointer if len(buf) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go index d8cf5012c27..fe71456dbc0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go @@ -1,6 +1,7 @@ // go run mksyscall.go -netbsd -tags netbsd,amd64 syscall_bsd.go syscall_netbsd.go syscall_netbsd_amd64.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build netbsd && amd64 // +build netbsd,amd64 package unix @@ -362,6 +363,16 @@ func pipe() (fd1 int, fd2 int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getdents(fd int, buf []byte) (n int, err error) { var _p0 unsafe.Pointer if len(buf) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go index 1153fe69b8e..0b5b2f0143b 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go @@ -1,6 +1,7 @@ // go run mksyscall.go -l32 -netbsd -arm -tags netbsd,arm syscall_bsd.go syscall_netbsd.go syscall_netbsd_arm.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build netbsd && arm // +build netbsd,arm package unix @@ -362,6 +363,16 @@ func pipe() (fd1 int, fd2 int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getdents(fd int, buf []byte) (n int, err error) { var _p0 unsafe.Pointer if len(buf) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go index 24b4ebb41fa..bfca28648fb 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go @@ -1,6 +1,7 @@ // go run mksyscall.go -netbsd -tags netbsd,arm64 syscall_bsd.go syscall_netbsd.go syscall_netbsd_arm64.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build netbsd && arm64 // +build netbsd,arm64 package unix @@ -362,6 +363,16 @@ func pipe() (fd1 int, fd2 int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getdents(fd int, buf []byte) (n int, err error) { var _p0 unsafe.Pointer if len(buf) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go index b44b31aeb16..8f80f4ade51 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -1,6 +1,7 @@ // go run mksyscall.go -l32 -openbsd -tags openbsd,386 syscall_bsd.go syscall_openbsd.go syscall_openbsd_386.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build openbsd && 386 // +build openbsd,386 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index 67f93ee76d8..3a47aca7bf7 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -1,6 +1,7 @@ // go run mksyscall.go -openbsd -tags openbsd,amd64 syscall_bsd.go syscall_openbsd.go syscall_openbsd_amd64.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build openbsd && amd64 // +build openbsd,amd64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go index d7c878b1d0a..883a9b45e8e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go @@ -1,6 +1,7 @@ // go run mksyscall.go -l32 -openbsd -arm -tags openbsd,arm syscall_bsd.go syscall_openbsd.go syscall_openbsd_arm.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build openbsd && arm // +build openbsd,arm package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go index 8facd695d5a..aac7fdc95e2 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go @@ -1,6 +1,7 @@ // go run mksyscall.go -openbsd -tags openbsd,arm64 syscall_bsd.go syscall_openbsd.go syscall_openbsd_arm64.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build openbsd && arm64 // +build openbsd,arm64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go index ec6bd5bb73a..8776187462b 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go @@ -1,6 +1,7 @@ // go run mksyscall.go -openbsd -tags openbsd,mips64 syscall_bsd.go syscall_openbsd.go syscall_openbsd_mips64.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build openbsd && mips64 // +build openbsd,mips64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go index a96165d4bf0..4e18d5c99fd 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go @@ -1,6 +1,7 @@ // go run mksyscall_solaris.go -tags solaris,amd64 syscall_solaris.go syscall_solaris_amd64.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build solaris && amd64 // +build solaris,amd64 package unix @@ -11,6 +12,7 @@ import ( ) //go:cgo_import_dynamic libc_pipe pipe "libc.so" +//go:cgo_import_dynamic libc_pipe2 pipe2 "libc.so" //go:cgo_import_dynamic libc_getsockname getsockname "libsocket.so" //go:cgo_import_dynamic libc_getcwd getcwd "libc.so" //go:cgo_import_dynamic libc_getgroups getgroups "libc.so" @@ -114,6 +116,7 @@ import ( //go:cgo_import_dynamic libc_statvfs statvfs "libc.so" //go:cgo_import_dynamic libc_symlink symlink "libc.so" //go:cgo_import_dynamic libc_sync sync "libc.so" +//go:cgo_import_dynamic libc_sysconf sysconf "libc.so" //go:cgo_import_dynamic libc_times times "libc.so" //go:cgo_import_dynamic libc_truncate truncate "libc.so" //go:cgo_import_dynamic libc_fsync fsync "libc.so" @@ -140,6 +143,7 @@ import ( //go:cgo_import_dynamic libc_recvfrom recvfrom "libsocket.so" //go:linkname procpipe libc_pipe +//go:linkname procpipe2 libc_pipe2 //go:linkname procgetsockname libc_getsockname //go:linkname procGetcwd libc_getcwd //go:linkname procgetgroups libc_getgroups @@ -243,6 +247,7 @@ import ( //go:linkname procStatvfs libc_statvfs //go:linkname procSymlink libc_symlink //go:linkname procSync libc_sync +//go:linkname procSysconf libc_sysconf //go:linkname procTimes libc_times //go:linkname procTruncate libc_truncate //go:linkname procFsync libc_fsync @@ -270,6 +275,7 @@ import ( var ( procpipe, + procpipe2, procgetsockname, procGetcwd, procgetgroups, @@ -373,6 +379,7 @@ var ( procStatvfs, procSymlink, procSync, + procSysconf, procTimes, procTruncate, procFsync, @@ -412,6 +419,16 @@ func pipe(p *[2]_C_int) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procpipe2)), 2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetsockname)), 3, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) if e1 != 0 { @@ -602,8 +619,9 @@ func __minor(version int, dev uint64) (val uint) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func ioctl(fd int, req uint, arg uintptr) (err error) { - _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procioctl)), 3, uintptr(fd), uintptr(req), uintptr(arg), 0, 0, 0) +func ioctlRet(fd int, req uint, arg uintptr) (ret int, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procioctl)), 3, uintptr(fd), uintptr(req), uintptr(arg), 0, 0, 0) + ret = int(r0) if e1 != 0 { err = e1 } @@ -1674,6 +1692,17 @@ func Sync() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Sysconf(which int) (n int64, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSysconf)), 1, uintptr(which), 0, 0, 0, 0, 0) + n = int64(r0) + if e1 != 0 { + err = e1 + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Times(tms *Tms) (ticks uintptr, err error) { r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procTimes)), 1, uintptr(unsafe.Pointer(tms)), 0, 0, 0, 0, 0) ticks = uintptr(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go b/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go new file mode 100644 index 00000000000..8285ab8419e --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go @@ -0,0 +1,1217 @@ +// go run mksyscall.go -tags zos,s390x syscall_zos_s390x.go +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build zos && s390x +// +build zos,s390x + +package unix + +import ( + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := syscall_syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := syscall_syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := syscall_syscall(SYS___ACCEPT_A, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := syscall_syscall(SYS___BIND_A, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := syscall_syscall(SYS___CONNECT_A, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := syscall_rawsyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := syscall_rawsyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := syscall_syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := syscall_syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := syscall_rawsyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := syscall_rawsyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := syscall_rawsyscall(SYS___GETPEERNAME_A, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := syscall_rawsyscall(SYS___GETSOCKNAME_A, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall6(SYS___RECVFROM_A, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall6(SYS___SENDTO_A, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := syscall_syscall(SYS___RECVMSG_A, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := syscall_syscall(SYS___SENDMSG_A, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := syscall_syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos)) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := syscall_syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ioctl(fd int, req uint, arg uintptr) (err error) { + _, _, e1 := syscall_syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___ACCESS_A, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___CHDIR_A, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___CHOWN_A, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___CHMOD_A, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Creat(path string, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := syscall_syscall(SYS___CREAT_A, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(oldfd int) (fd int, err error) { + r0, _, e1 := syscall_syscall(SYS_DUP, uintptr(oldfd), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := syscall_syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + syscall_syscall(SYS_EXIT, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := syscall_syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := syscall_syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := syscall_syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func FcntlInt(fd uintptr, cmd int, arg int) (retval int, err error) { + r0, _, e1 := syscall_syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + retval = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fstat(fd int, stat *Stat_LE_t) (err error) { + _, _, e1 := syscall_syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatvfs(fd int, stat *Statvfs_t) (err error) { + _, _, e1 := syscall_syscall(SYS_FSTATVFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := syscall_syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := syscall_syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpagesize() (pgsize int) { + r0, _, _ := syscall_syscall(SYS_GETPAGESIZE, 0, 0, 0) + pgsize = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Poll(fds []PollFd, timeout int) (n int, err error) { + var _p0 unsafe.Pointer + if len(fds) > 0 { + _p0 = unsafe.Pointer(&fds[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(SYS_POLL, uintptr(_p0), uintptr(len(fds)), uintptr(timeout)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := syscall_syscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0) + ticks = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func W_Getmntent(buff *byte, size int) (lastsys int, err error) { + r0, _, e1 := syscall_syscall(SYS_W_GETMNTENT, uintptr(unsafe.Pointer(buff)), uintptr(size), 0) + lastsys = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mount(path string, filesystem string, fstype string, mtm uint32, parmlen int32, parm string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(filesystem) + if err != nil { + return + } + var _p2 *byte + _p2, err = BytePtrFromString(fstype) + if err != nil { + return + } + var _p3 *byte + _p3, err = BytePtrFromString(parm) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(SYS___MOUNT_A, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(mtm), uintptr(parmlen), uintptr(unsafe.Pointer(_p3))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(filesystem string, mtm int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(filesystem) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___UMOUNT_A, uintptr(unsafe.Pointer(_p0)), uintptr(mtm), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___CHROOT_A, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Uname(buf *Utsname) (err error) { + _, _, e1 := syscall_rawsyscall(SYS___UNAME_A, uintptr(unsafe.Pointer(buf)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gethostname(buf []byte) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall(SYS___GETHOSTNAME_A, uintptr(_p0), uintptr(len(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := syscall_rawsyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := syscall_rawsyscall(SYS_GETEUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := syscall_rawsyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := syscall_rawsyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := syscall_rawsyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (pid int) { + r0, _, _ := syscall_rawsyscall(SYS_GETPPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := syscall_syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := syscall_rawsyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getrusage(who int, rusage *rusage_zos) (err error) { + _, _, e1 := syscall_rawsyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := syscall_rawsyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := syscall_rawsyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, sig Signal) (err error) { + _, _, e1 := syscall_rawsyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___LCHOWN_A, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___LINK_A, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, n int) (err error) { + _, _, e1 := syscall_syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lstat(path string, stat *Stat_LE_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___LSTAT_A, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___MKDIR_A, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___MKFIFO_A, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___MKNOD_A, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(SYS___READLINK_A, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___RENAME_A, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___RMDIR_A, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (off int64, err error) { + r0, _, e1 := syscall_syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + off = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := syscall_syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := syscall_rawsyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(resource int, lim *Rlimit) (err error) { + _, _, e1 := syscall_rawsyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := syscall_rawsyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := syscall_rawsyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := syscall_rawsyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := syscall_syscall(SYS_SETUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(uid int) (err error) { + _, _, e1 := syscall_syscall(SYS_SETGID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(fd int, how int) (err error) { + _, _, e1 := syscall_syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func stat(path string, statLE *Stat_LE_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___STAT_A, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(statLE)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___SYMLINK_A, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() { + syscall_syscall(SYS_SYNC, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___TRUNCATE_A, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tcgetattr(fildes int, termptr *Termios) (err error) { + _, _, e1 := syscall_syscall(SYS_TCGETATTR, uintptr(fildes), uintptr(unsafe.Pointer(termptr)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tcsetattr(fildes int, when int, termptr *Termios) (err error) { + _, _, e1 := syscall_syscall(SYS_TCSETATTR, uintptr(fildes), uintptr(when), uintptr(unsafe.Pointer(termptr))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(mask int) (oldmask int) { + r0, _, _ := syscall_syscall(SYS_UMASK, uintptr(mask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___UNLINK_A, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Utime(path string, utim *Utimbuf) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___UTIME_A, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(utim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := syscall_syscall(SYS___OPEN_A, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func remove(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS_REMOVE, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func waitpid(pid int, wstatus *_C_int, options int) (wpid int, err error) { + r0, _, e1 := syscall_syscall(SYS_WAITPID, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options)) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func gettimeofday(tv *timeval_zos) (err error) { + _, _, e1 := syscall_rawsyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe(p *[2]_C_int) (err error) { + _, _, e1 := syscall_rawsyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(SYS___UTIMES_A, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_386.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_386.go index 102f1ab4750..9e9d0b2a9c4 100644 --- a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_386.go @@ -1,6 +1,7 @@ // go run mksysctl_openbsd.go // Code generated by the command above; DO NOT EDIT. +//go:build 386 && openbsd // +build 386,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go index 4866fced8ae..adecd09667d 100644 --- a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go @@ -1,6 +1,7 @@ // go run mksysctl_openbsd.go // Code generated by the command above; DO NOT EDIT. +//go:build amd64 && openbsd // +build amd64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm.go index d3801eb24b3..8ea52a4a181 100644 --- a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm.go @@ -1,6 +1,7 @@ // go run mksysctl_openbsd.go // Code generated by the command above; DO NOT EDIT. +//go:build arm && openbsd // +build arm,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm64.go index ba4304fd233..154b57ae3e2 100644 --- a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm64.go @@ -1,6 +1,7 @@ // go run mksysctl_openbsd.go // Code generated by the command above; DO NOT EDIT. +//go:build arm64 && openbsd // +build arm64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_mips64.go index aca34b34933..d96bb2ba4db 100644 --- a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_mips64.go @@ -1,6 +1,7 @@ // go run mksysctl_openbsd.go // Code generated by the command above; DO NOT EDIT. +//go:build mips64 && openbsd // +build mips64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_darwin_386.go b/vendor/golang.org/x/sys/unix/zsysnum_darwin_386.go index ad62324c7c1..1794ffc9245 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_darwin_386.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_darwin_386.go @@ -1,6 +1,7 @@ // go run mksysnum.go /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/sys/syscall.h // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build 386 && darwin // +build 386,darwin package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_darwin_amd64.go index a2fc91d6a80..f8298ff9b58 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_darwin_amd64.go @@ -1,6 +1,7 @@ // go run mksysnum.go /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/sys/syscall.h // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && darwin // +build amd64,darwin package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm.go index 20d7808ace3..6dc736449a5 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm.go @@ -1,6 +1,7 @@ // go run mksysnum.go /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.1.sdk/usr/include/sys/syscall.h // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm && darwin // +build arm,darwin package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go index 527b9588cc9..5eb433bbf01 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go @@ -1,6 +1,7 @@ // go run mksysnum.go /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.1.sdk/usr/include/sys/syscall.h // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm64 && darwin // +build arm64,darwin package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go index 9912c6ee3d6..703675c0c4a 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go @@ -1,6 +1,7 @@ // go run mksysnum.go https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && dragonfly // +build amd64,dragonfly package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go index 9474974b657..59d5dfc2092 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go @@ -1,6 +1,7 @@ // go run mksysnum.go https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build 386 && freebsd // +build 386,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go index 48a7beae7bb..342d471d2eb 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go @@ -1,6 +1,7 @@ // go run mksysnum.go https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && freebsd // +build amd64,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go index 4a6dfd4a745..e2e3d72c5b0 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go @@ -1,6 +1,7 @@ // go run mksysnum.go https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm && freebsd // +build arm,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm64.go index 3e51af8edd2..61ad5ca3c19 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm64.go @@ -1,6 +1,7 @@ // go run mksysnum.go https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm64 && freebsd // +build arm64,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go index 0f5a3f6970a..8e535971348 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -1,6 +1,7 @@ // go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include -m32 /tmp/include/asm/unistd.h // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build 386 && linux // +build 386,linux package unix @@ -435,4 +436,6 @@ const ( SYS_OPENAT2 = 437 SYS_PIDFD_GETFD = 438 SYS_FACCESSAT2 = 439 + SYS_PROCESS_MADVISE = 440 + SYS_EPOLL_PWAIT2 = 441 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go index 36d5219ef82..d7dceb769b3 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -1,6 +1,7 @@ // go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include -m64 /tmp/include/asm/unistd.h // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && linux // +build amd64,linux package unix @@ -357,4 +358,6 @@ const ( SYS_OPENAT2 = 437 SYS_PIDFD_GETFD = 438 SYS_FACCESSAT2 = 439 + SYS_PROCESS_MADVISE = 440 + SYS_EPOLL_PWAIT2 = 441 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go index 3622ba14b4e..04093a69fd8 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -1,6 +1,7 @@ // go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm && linux // +build arm,linux package unix @@ -399,4 +400,6 @@ const ( SYS_OPENAT2 = 437 SYS_PIDFD_GETFD = 438 SYS_FACCESSAT2 = 439 + SYS_PROCESS_MADVISE = 440 + SYS_EPOLL_PWAIT2 = 441 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go index 6193c3dc07c..48f94f135d6 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -1,6 +1,7 @@ // go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include -fsigned-char /tmp/include/asm/unistd.h // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm64 && linux // +build arm64,linux package unix @@ -302,4 +303,6 @@ const ( SYS_OPENAT2 = 437 SYS_PIDFD_GETFD = 438 SYS_FACCESSAT2 = 439 + SYS_PROCESS_MADVISE = 440 + SYS_EPOLL_PWAIT2 = 441 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go index 640b974345f..499978c3e40 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go @@ -1,6 +1,7 @@ // go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build mips && linux // +build mips,linux package unix @@ -420,4 +421,6 @@ const ( SYS_OPENAT2 = 4437 SYS_PIDFD_GETFD = 4438 SYS_FACCESSAT2 = 4439 + SYS_PROCESS_MADVISE = 4440 + SYS_EPOLL_PWAIT2 = 4441 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go index 3467fbb5ff1..10d1db2be0c 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -1,6 +1,7 @@ // go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build mips64 && linux // +build mips64,linux package unix @@ -350,4 +351,6 @@ const ( SYS_OPENAT2 = 5437 SYS_PIDFD_GETFD = 5438 SYS_FACCESSAT2 = 5439 + SYS_PROCESS_MADVISE = 5440 + SYS_EPOLL_PWAIT2 = 5441 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go index 0fc38d5a72f..208d5dcd5a3 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -1,6 +1,7 @@ // go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build mips64le && linux // +build mips64le,linux package unix @@ -350,4 +351,6 @@ const ( SYS_OPENAT2 = 5437 SYS_PIDFD_GETFD = 5438 SYS_FACCESSAT2 = 5439 + SYS_PROCESS_MADVISE = 5440 + SYS_EPOLL_PWAIT2 = 5441 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go index 999fd55bccb..f8250602eb8 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go @@ -1,6 +1,7 @@ // go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build mipsle && linux // +build mipsle,linux package unix @@ -420,4 +421,6 @@ const ( SYS_OPENAT2 = 4437 SYS_PIDFD_GETFD = 4438 SYS_FACCESSAT2 = 4439 + SYS_PROCESS_MADVISE = 4440 + SYS_EPOLL_PWAIT2 = 4441 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go index 1df0d799355..d5ed3ff5100 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -1,6 +1,7 @@ // go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build ppc64 && linux // +build ppc64,linux package unix @@ -399,4 +400,6 @@ const ( SYS_OPENAT2 = 437 SYS_PIDFD_GETFD = 438 SYS_FACCESSAT2 = 439 + SYS_PROCESS_MADVISE = 440 + SYS_EPOLL_PWAIT2 = 441 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go index 4db39cca4da..e29b4424c24 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -1,6 +1,7 @@ // go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build ppc64le && linux // +build ppc64le,linux package unix @@ -399,4 +400,6 @@ const ( SYS_OPENAT2 = 437 SYS_PIDFD_GETFD = 438 SYS_FACCESSAT2 = 439 + SYS_PROCESS_MADVISE = 440 + SYS_EPOLL_PWAIT2 = 441 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go index e6927401446..41deed6c3a5 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go @@ -1,6 +1,7 @@ // go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build riscv64 && linux // +build riscv64,linux package unix @@ -301,4 +302,6 @@ const ( SYS_OPENAT2 = 437 SYS_PIDFD_GETFD = 438 SYS_FACCESSAT2 = 439 + SYS_PROCESS_MADVISE = 440 + SYS_EPOLL_PWAIT2 = 441 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go index a585aec4e79..8e53a9e8ceb 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -1,6 +1,7 @@ // go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include -fsigned-char /tmp/include/asm/unistd.h // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build s390x && linux // +build s390x,linux package unix @@ -364,4 +365,6 @@ const ( SYS_OPENAT2 = 437 SYS_PIDFD_GETFD = 438 SYS_FACCESSAT2 = 439 + SYS_PROCESS_MADVISE = 440 + SYS_EPOLL_PWAIT2 = 441 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go index d047e567afc..596e5bc7d35 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go @@ -1,6 +1,7 @@ // go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build sparc64 && linux // +build sparc64,linux package unix @@ -378,4 +379,6 @@ const ( SYS_OPENAT2 = 437 SYS_PIDFD_GETFD = 438 SYS_FACCESSAT2 = 439 + SYS_PROCESS_MADVISE = 440 + SYS_EPOLL_PWAIT2 = 441 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go index e66a8c9d39e..3a6699eba98 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go @@ -1,6 +1,7 @@ // go run mksysnum.go http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build 386 && netbsd // +build 386,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go index 42c788f2490..5677cd4f158 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go @@ -1,6 +1,7 @@ // go run mksysnum.go http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && netbsd // +build amd64,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go index 0a0757179ba..e784cb6db1c 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go @@ -1,6 +1,7 @@ // go run mksysnum.go http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm && netbsd // +build arm,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm64.go index 0291c0931b4..bd4952efa5b 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm64.go @@ -1,6 +1,7 @@ // go run mksysnum.go http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master // Code generated by the command above; DO NOT EDIT. +//go:build arm64 && netbsd // +build arm64,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_386.go b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_386.go index b0207d1c9bb..817edbf95c0 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_386.go @@ -1,6 +1,7 @@ // go run mksysnum.go https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build 386 && openbsd // +build 386,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go index f0dec6f0b43..ea453614e69 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go @@ -1,6 +1,7 @@ // go run mksysnum.go https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && openbsd // +build amd64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm.go index 33d1dc5404e..467971eed66 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm.go @@ -1,6 +1,7 @@ // go run mksysnum.go https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm && openbsd // +build arm,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm64.go index fe2b689b637..32eec5ed56f 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm64.go @@ -1,6 +1,7 @@ // go run mksysnum.go https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm64 && openbsd // +build arm64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_mips64.go index 5c08d573b3e..a37f7737563 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_mips64.go @@ -1,6 +1,7 @@ // go run mksysnum.go https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build mips64 && openbsd // +build mips64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_zos_s390x.go b/vendor/golang.org/x/sys/unix/zsysnum_zos_s390x.go new file mode 100644 index 00000000000..073daad43b7 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_zos_s390x.go @@ -0,0 +1,2670 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build zos && s390x +// +build zos,s390x + +package unix + +// TODO: auto-generate. + +const ( + SYS_ACOSD128 = 0xB80 + SYS_ACOSD32 = 0xB7E + SYS_ACOSD64 = 0xB7F + SYS_ACOSHD128 = 0xB83 + SYS_ACOSHD32 = 0xB81 + SYS_ACOSHD64 = 0xB82 + SYS_AIO_FSYNC = 0xC69 + SYS_ASCTIME = 0x0AE + SYS_ASCTIME64 = 0xCD7 + SYS_ASCTIME64_R = 0xCD8 + SYS_ASIND128 = 0xB86 + SYS_ASIND32 = 0xB84 + SYS_ASIND64 = 0xB85 + SYS_ASINHD128 = 0xB89 + SYS_ASINHD32 = 0xB87 + SYS_ASINHD64 = 0xB88 + SYS_ATAN2D128 = 0xB8F + SYS_ATAN2D32 = 0xB8D + SYS_ATAN2D64 = 0xB8E + SYS_ATAND128 = 0xB8C + SYS_ATAND32 = 0xB8A + SYS_ATAND64 = 0xB8B + SYS_ATANHD128 = 0xB92 + SYS_ATANHD32 = 0xB90 + SYS_ATANHD64 = 0xB91 + SYS_BIND2ADDRSEL = 0xD59 + SYS_C16RTOMB = 0xD40 + SYS_C32RTOMB = 0xD41 + SYS_CBRTD128 = 0xB95 + SYS_CBRTD32 = 0xB93 + SYS_CBRTD64 = 0xB94 + SYS_CEILD128 = 0xB98 + SYS_CEILD32 = 0xB96 + SYS_CEILD64 = 0xB97 + SYS_CLEARENV = 0x0C9 + SYS_CLEARERR_UNLOCKED = 0xCA1 + SYS_CLOCK = 0x0AA + SYS_CLOGL = 0xA00 + SYS_CLRMEMF = 0x0BD + SYS_CONJ = 0xA03 + SYS_CONJF = 0xA06 + SYS_CONJL = 0xA09 + SYS_COPYSIGND128 = 0xB9E + SYS_COPYSIGND32 = 0xB9C + SYS_COPYSIGND64 = 0xB9D + SYS_COSD128 = 0xBA1 + SYS_COSD32 = 0xB9F + SYS_COSD64 = 0xBA0 + SYS_COSHD128 = 0xBA4 + SYS_COSHD32 = 0xBA2 + SYS_COSHD64 = 0xBA3 + SYS_CPOW = 0xA0C + SYS_CPOWF = 0xA0F + SYS_CPOWL = 0xA12 + SYS_CPROJ = 0xA15 + SYS_CPROJF = 0xA18 + SYS_CPROJL = 0xA1B + SYS_CREAL = 0xA1E + SYS_CREALF = 0xA21 + SYS_CREALL = 0xA24 + SYS_CSIN = 0xA27 + SYS_CSINF = 0xA2A + SYS_CSINH = 0xA30 + SYS_CSINHF = 0xA33 + SYS_CSINHL = 0xA36 + SYS_CSINL = 0xA2D + SYS_CSNAP = 0x0C5 + SYS_CSQRT = 0xA39 + SYS_CSQRTF = 0xA3C + SYS_CSQRTL = 0xA3F + SYS_CTAN = 0xA42 + SYS_CTANF = 0xA45 + SYS_CTANH = 0xA4B + SYS_CTANHF = 0xA4E + SYS_CTANHL = 0xA51 + SYS_CTANL = 0xA48 + SYS_CTIME = 0x0AB + SYS_CTIME64 = 0xCD9 + SYS_CTIME64_R = 0xCDA + SYS_CTRACE = 0x0C6 + SYS_DIFFTIME = 0x0A7 + SYS_DIFFTIME64 = 0xCDB + SYS_DLADDR = 0xC82 + SYS_DYNALLOC = 0x0C3 + SYS_DYNFREE = 0x0C2 + SYS_ERFCD128 = 0xBAA + SYS_ERFCD32 = 0xBA8 + SYS_ERFCD64 = 0xBA9 + SYS_ERFD128 = 0xBA7 + SYS_ERFD32 = 0xBA5 + SYS_ERFD64 = 0xBA6 + SYS_EXP2D128 = 0xBB0 + SYS_EXP2D32 = 0xBAE + SYS_EXP2D64 = 0xBAF + SYS_EXPD128 = 0xBAD + SYS_EXPD32 = 0xBAB + SYS_EXPD64 = 0xBAC + SYS_EXPM1D128 = 0xBB3 + SYS_EXPM1D32 = 0xBB1 + SYS_EXPM1D64 = 0xBB2 + SYS_FABSD128 = 0xBB6 + SYS_FABSD32 = 0xBB4 + SYS_FABSD64 = 0xBB5 + SYS_FDELREC_UNLOCKED = 0xCA2 + SYS_FDIMD128 = 0xBB9 + SYS_FDIMD32 = 0xBB7 + SYS_FDIMD64 = 0xBB8 + SYS_FDOPEN_UNLOCKED = 0xCFC + SYS_FECLEAREXCEPT = 0xAEA + SYS_FEGETENV = 0xAEB + SYS_FEGETEXCEPTFLAG = 0xAEC + SYS_FEGETROUND = 0xAED + SYS_FEHOLDEXCEPT = 0xAEE + SYS_FEOF_UNLOCKED = 0xCA3 + SYS_FERAISEEXCEPT = 0xAEF + SYS_FERROR_UNLOCKED = 0xCA4 + SYS_FESETENV = 0xAF0 + SYS_FESETEXCEPTFLAG = 0xAF1 + SYS_FESETROUND = 0xAF2 + SYS_FETCHEP = 0x0BF + SYS_FETESTEXCEPT = 0xAF3 + SYS_FEUPDATEENV = 0xAF4 + SYS_FE_DEC_GETROUND = 0xBBA + SYS_FE_DEC_SETROUND = 0xBBB + SYS_FFLUSH_UNLOCKED = 0xCA5 + SYS_FGETC_UNLOCKED = 0xC80 + SYS_FGETPOS64 = 0xCEE + SYS_FGETPOS64_UNLOCKED = 0xCF4 + SYS_FGETPOS_UNLOCKED = 0xCA6 + SYS_FGETS_UNLOCKED = 0xC7C + SYS_FGETWC_UNLOCKED = 0xCA7 + SYS_FGETWS_UNLOCKED = 0xCA8 + SYS_FILENO_UNLOCKED = 0xCA9 + SYS_FLDATA = 0x0C1 + SYS_FLDATA_UNLOCKED = 0xCAA + SYS_FLOCATE_UNLOCKED = 0xCAB + SYS_FLOORD128 = 0xBBE + SYS_FLOORD32 = 0xBBC + SYS_FLOORD64 = 0xBBD + SYS_FMA = 0xA63 + SYS_FMAD128 = 0xBC1 + SYS_FMAD32 = 0xBBF + SYS_FMAD64 = 0xBC0 + SYS_FMAF = 0xA66 + SYS_FMAL = 0xA69 + SYS_FMAX = 0xA6C + SYS_FMAXD128 = 0xBC4 + SYS_FMAXD32 = 0xBC2 + SYS_FMAXD64 = 0xBC3 + SYS_FMAXF = 0xA6F + SYS_FMAXL = 0xA72 + SYS_FMIN = 0xA75 + SYS_FMIND128 = 0xBC7 + SYS_FMIND32 = 0xBC5 + SYS_FMIND64 = 0xBC6 + SYS_FMINF = 0xA78 + SYS_FMINL = 0xA7B + SYS_FMODD128 = 0xBCA + SYS_FMODD32 = 0xBC8 + SYS_FMODD64 = 0xBC9 + SYS_FOPEN64 = 0xD49 + SYS_FOPEN64_UNLOCKED = 0xD4A + SYS_FOPEN_UNLOCKED = 0xCFA + SYS_FPRINTF_UNLOCKED = 0xCAC + SYS_FPUTC_UNLOCKED = 0xC81 + SYS_FPUTS_UNLOCKED = 0xC7E + SYS_FPUTWC_UNLOCKED = 0xCAD + SYS_FPUTWS_UNLOCKED = 0xCAE + SYS_FREAD_NOUPDATE = 0xCEC + SYS_FREAD_NOUPDATE_UNLOCKED = 0xCED + SYS_FREAD_UNLOCKED = 0xC7B + SYS_FREEIFADDRS = 0xCE6 + SYS_FREOPEN64 = 0xD4B + SYS_FREOPEN64_UNLOCKED = 0xD4C + SYS_FREOPEN_UNLOCKED = 0xCFB + SYS_FREXPD128 = 0xBCE + SYS_FREXPD32 = 0xBCC + SYS_FREXPD64 = 0xBCD + SYS_FSCANF_UNLOCKED = 0xCAF + SYS_FSEEK64 = 0xCEF + SYS_FSEEK64_UNLOCKED = 0xCF5 + SYS_FSEEKO64 = 0xCF0 + SYS_FSEEKO64_UNLOCKED = 0xCF6 + SYS_FSEEKO_UNLOCKED = 0xCB1 + SYS_FSEEK_UNLOCKED = 0xCB0 + SYS_FSETPOS64 = 0xCF1 + SYS_FSETPOS64_UNLOCKED = 0xCF7 + SYS_FSETPOS_UNLOCKED = 0xCB3 + SYS_FTELL64 = 0xCF2 + SYS_FTELL64_UNLOCKED = 0xCF8 + SYS_FTELLO64 = 0xCF3 + SYS_FTELLO64_UNLOCKED = 0xCF9 + SYS_FTELLO_UNLOCKED = 0xCB5 + SYS_FTELL_UNLOCKED = 0xCB4 + SYS_FUPDATE = 0x0B5 + SYS_FUPDATE_UNLOCKED = 0xCB7 + SYS_FWIDE_UNLOCKED = 0xCB8 + SYS_FWPRINTF_UNLOCKED = 0xCB9 + SYS_FWRITE_UNLOCKED = 0xC7A + SYS_FWSCANF_UNLOCKED = 0xCBA + SYS_GETDATE64 = 0xD4F + SYS_GETIFADDRS = 0xCE7 + SYS_GETIPV4SOURCEFILTER = 0xC77 + SYS_GETSOURCEFILTER = 0xC79 + SYS_GETSYNTX = 0x0FD + SYS_GETS_UNLOCKED = 0xC7D + SYS_GETTIMEOFDAY64 = 0xD50 + SYS_GETWCHAR_UNLOCKED = 0xCBC + SYS_GETWC_UNLOCKED = 0xCBB + SYS_GMTIME = 0x0B0 + SYS_GMTIME64 = 0xCDC + SYS_GMTIME64_R = 0xCDD + SYS_HYPOTD128 = 0xBD1 + SYS_HYPOTD32 = 0xBCF + SYS_HYPOTD64 = 0xBD0 + SYS_ILOGBD128 = 0xBD4 + SYS_ILOGBD32 = 0xBD2 + SYS_ILOGBD64 = 0xBD3 + SYS_ILOGBF = 0xA7E + SYS_ILOGBL = 0xA81 + SYS_INET6_IS_SRCADDR = 0xD5A + SYS_ISBLANK = 0x0FE + SYS_ISWALNUM = 0x0FF + SYS_LDEXPD128 = 0xBD7 + SYS_LDEXPD32 = 0xBD5 + SYS_LDEXPD64 = 0xBD6 + SYS_LGAMMAD128 = 0xBDA + SYS_LGAMMAD32 = 0xBD8 + SYS_LGAMMAD64 = 0xBD9 + SYS_LIO_LISTIO = 0xC6A + SYS_LLRINT = 0xA84 + SYS_LLRINTD128 = 0xBDD + SYS_LLRINTD32 = 0xBDB + SYS_LLRINTD64 = 0xBDC + SYS_LLRINTF = 0xA87 + SYS_LLRINTL = 0xA8A + SYS_LLROUND = 0xA8D + SYS_LLROUNDD128 = 0xBE0 + SYS_LLROUNDD32 = 0xBDE + SYS_LLROUNDD64 = 0xBDF + SYS_LLROUNDF = 0xA90 + SYS_LLROUNDL = 0xA93 + SYS_LOCALTIM = 0x0B1 + SYS_LOCALTIME = 0x0B1 + SYS_LOCALTIME64 = 0xCDE + SYS_LOCALTIME64_R = 0xCDF + SYS_LOG10D128 = 0xBE6 + SYS_LOG10D32 = 0xBE4 + SYS_LOG10D64 = 0xBE5 + SYS_LOG1PD128 = 0xBE9 + SYS_LOG1PD32 = 0xBE7 + SYS_LOG1PD64 = 0xBE8 + SYS_LOG2D128 = 0xBEC + SYS_LOG2D32 = 0xBEA + SYS_LOG2D64 = 0xBEB + SYS_LOGBD128 = 0xBEF + SYS_LOGBD32 = 0xBED + SYS_LOGBD64 = 0xBEE + SYS_LOGBF = 0xA96 + SYS_LOGBL = 0xA99 + SYS_LOGD128 = 0xBE3 + SYS_LOGD32 = 0xBE1 + SYS_LOGD64 = 0xBE2 + SYS_LRINT = 0xA9C + SYS_LRINTD128 = 0xBF2 + SYS_LRINTD32 = 0xBF0 + SYS_LRINTD64 = 0xBF1 + SYS_LRINTF = 0xA9F + SYS_LRINTL = 0xAA2 + SYS_LROUNDD128 = 0xBF5 + SYS_LROUNDD32 = 0xBF3 + SYS_LROUNDD64 = 0xBF4 + SYS_LROUNDL = 0xAA5 + SYS_MBLEN = 0x0AF + SYS_MBRTOC16 = 0xD42 + SYS_MBRTOC32 = 0xD43 + SYS_MEMSET = 0x0A3 + SYS_MKTIME = 0x0AC + SYS_MKTIME64 = 0xCE0 + SYS_MODFD128 = 0xBF8 + SYS_MODFD32 = 0xBF6 + SYS_MODFD64 = 0xBF7 + SYS_NAN = 0xAA8 + SYS_NAND128 = 0xBFB + SYS_NAND32 = 0xBF9 + SYS_NAND64 = 0xBFA + SYS_NANF = 0xAAA + SYS_NANL = 0xAAC + SYS_NEARBYINT = 0xAAE + SYS_NEARBYINTD128 = 0xBFE + SYS_NEARBYINTD32 = 0xBFC + SYS_NEARBYINTD64 = 0xBFD + SYS_NEARBYINTF = 0xAB1 + SYS_NEARBYINTL = 0xAB4 + SYS_NEXTAFTERD128 = 0xC01 + SYS_NEXTAFTERD32 = 0xBFF + SYS_NEXTAFTERD64 = 0xC00 + SYS_NEXTAFTERF = 0xAB7 + SYS_NEXTAFTERL = 0xABA + SYS_NEXTTOWARD = 0xABD + SYS_NEXTTOWARDD128 = 0xC04 + SYS_NEXTTOWARDD32 = 0xC02 + SYS_NEXTTOWARDD64 = 0xC03 + SYS_NEXTTOWARDF = 0xAC0 + SYS_NEXTTOWARDL = 0xAC3 + SYS_NL_LANGINFO = 0x0FC + SYS_PERROR_UNLOCKED = 0xCBD + SYS_POSIX_FALLOCATE = 0xCE8 + SYS_POSIX_MEMALIGN = 0xCE9 + SYS_POSIX_OPENPT = 0xC66 + SYS_POWD128 = 0xC07 + SYS_POWD32 = 0xC05 + SYS_POWD64 = 0xC06 + SYS_PRINTF_UNLOCKED = 0xCBE + SYS_PSELECT = 0xC67 + SYS_PTHREAD_ATTR_GETSTACK = 0xB3E + SYS_PTHREAD_ATTR_SETSTACK = 0xB3F + SYS_PTHREAD_SECURITY_APPLID_NP = 0xCE4 + SYS_PUTS_UNLOCKED = 0xC7F + SYS_PUTWCHAR_UNLOCKED = 0xCC0 + SYS_PUTWC_UNLOCKED = 0xCBF + SYS_QUANTEXPD128 = 0xD46 + SYS_QUANTEXPD32 = 0xD44 + SYS_QUANTEXPD64 = 0xD45 + SYS_QUANTIZED128 = 0xC0A + SYS_QUANTIZED32 = 0xC08 + SYS_QUANTIZED64 = 0xC09 + SYS_REMAINDERD128 = 0xC0D + SYS_REMAINDERD32 = 0xC0B + SYS_REMAINDERD64 = 0xC0C + SYS_RESIZE_ALLOC = 0xCEB + SYS_REWIND_UNLOCKED = 0xCC1 + SYS_RINTD128 = 0xC13 + SYS_RINTD32 = 0xC11 + SYS_RINTD64 = 0xC12 + SYS_RINTF = 0xACB + SYS_RINTL = 0xACD + SYS_ROUND = 0xACF + SYS_ROUNDD128 = 0xC16 + SYS_ROUNDD32 = 0xC14 + SYS_ROUNDD64 = 0xC15 + SYS_ROUNDF = 0xAD2 + SYS_ROUNDL = 0xAD5 + SYS_SAMEQUANTUMD128 = 0xC19 + SYS_SAMEQUANTUMD32 = 0xC17 + SYS_SAMEQUANTUMD64 = 0xC18 + SYS_SCALBLN = 0xAD8 + SYS_SCALBLND128 = 0xC1C + SYS_SCALBLND32 = 0xC1A + SYS_SCALBLND64 = 0xC1B + SYS_SCALBLNF = 0xADB + SYS_SCALBLNL = 0xADE + SYS_SCALBND128 = 0xC1F + SYS_SCALBND32 = 0xC1D + SYS_SCALBND64 = 0xC1E + SYS_SCALBNF = 0xAE3 + SYS_SCALBNL = 0xAE6 + SYS_SCANF_UNLOCKED = 0xCC2 + SYS_SCHED_YIELD = 0xB32 + SYS_SETENV = 0x0C8 + SYS_SETIPV4SOURCEFILTER = 0xC76 + SYS_SETSOURCEFILTER = 0xC78 + SYS_SHM_OPEN = 0xC8C + SYS_SHM_UNLINK = 0xC8D + SYS_SIND128 = 0xC22 + SYS_SIND32 = 0xC20 + SYS_SIND64 = 0xC21 + SYS_SINHD128 = 0xC25 + SYS_SINHD32 = 0xC23 + SYS_SINHD64 = 0xC24 + SYS_SIZEOF_ALLOC = 0xCEA + SYS_SOCKATMARK = 0xC68 + SYS_SQRTD128 = 0xC28 + SYS_SQRTD32 = 0xC26 + SYS_SQRTD64 = 0xC27 + SYS_STRCHR = 0x0A0 + SYS_STRCSPN = 0x0A1 + SYS_STRERROR = 0x0A8 + SYS_STRERROR_R = 0xB33 + SYS_STRFTIME = 0x0B2 + SYS_STRLEN = 0x0A9 + SYS_STRPBRK = 0x0A2 + SYS_STRSPN = 0x0A4 + SYS_STRSTR = 0x0A5 + SYS_STRTOD128 = 0xC2B + SYS_STRTOD32 = 0xC29 + SYS_STRTOD64 = 0xC2A + SYS_STRTOK = 0x0A6 + SYS_TAND128 = 0xC2E + SYS_TAND32 = 0xC2C + SYS_TAND64 = 0xC2D + SYS_TANHD128 = 0xC31 + SYS_TANHD32 = 0xC2F + SYS_TANHD64 = 0xC30 + SYS_TGAMMAD128 = 0xC34 + SYS_TGAMMAD32 = 0xC32 + SYS_TGAMMAD64 = 0xC33 + SYS_TIME = 0x0AD + SYS_TIME64 = 0xCE1 + SYS_TMPFILE64 = 0xD4D + SYS_TMPFILE64_UNLOCKED = 0xD4E + SYS_TMPFILE_UNLOCKED = 0xCFD + SYS_TRUNCD128 = 0xC40 + SYS_TRUNCD32 = 0xC3E + SYS_TRUNCD64 = 0xC3F + SYS_UNGETC_UNLOCKED = 0xCC3 + SYS_UNGETWC_UNLOCKED = 0xCC4 + SYS_UNSETENV = 0xB34 + SYS_VFPRINTF_UNLOCKED = 0xCC5 + SYS_VFSCANF_UNLOCKED = 0xCC7 + SYS_VFWPRINTF_UNLOCKED = 0xCC9 + SYS_VFWSCANF_UNLOCKED = 0xCCB + SYS_VPRINTF_UNLOCKED = 0xCCD + SYS_VSCANF_UNLOCKED = 0xCCF + SYS_VWPRINTF_UNLOCKED = 0xCD1 + SYS_VWSCANF_UNLOCKED = 0xCD3 + SYS_WCSTOD128 = 0xC43 + SYS_WCSTOD32 = 0xC41 + SYS_WCSTOD64 = 0xC42 + SYS_WPRINTF_UNLOCKED = 0xCD5 + SYS_WSCANF_UNLOCKED = 0xCD6 + SYS__FLUSHLBF = 0xD68 + SYS__FLUSHLBF_UNLOCKED = 0xD6F + SYS___ACOSHF_H = 0xA54 + SYS___ACOSHL_H = 0xA55 + SYS___ASINHF_H = 0xA56 + SYS___ASINHL_H = 0xA57 + SYS___ATANPID128 = 0xC6D + SYS___ATANPID32 = 0xC6B + SYS___ATANPID64 = 0xC6C + SYS___CBRTF_H = 0xA58 + SYS___CBRTL_H = 0xA59 + SYS___CDUMP = 0x0C4 + SYS___CLASS = 0xAFA + SYS___CLASS2 = 0xB99 + SYS___CLASS2D128 = 0xC99 + SYS___CLASS2D32 = 0xC97 + SYS___CLASS2D64 = 0xC98 + SYS___CLASS2F = 0xC91 + SYS___CLASS2F_B = 0xC93 + SYS___CLASS2F_H = 0xC94 + SYS___CLASS2L = 0xC92 + SYS___CLASS2L_B = 0xC95 + SYS___CLASS2L_H = 0xC96 + SYS___CLASS2_B = 0xB9A + SYS___CLASS2_H = 0xB9B + SYS___CLASS_B = 0xAFB + SYS___CLASS_H = 0xAFC + SYS___CLOGL_B = 0xA01 + SYS___CLOGL_H = 0xA02 + SYS___CLRENV = 0x0C9 + SYS___CLRMF = 0x0BD + SYS___CODEPAGE_INFO = 0xC64 + SYS___CONJF_B = 0xA07 + SYS___CONJF_H = 0xA08 + SYS___CONJL_B = 0xA0A + SYS___CONJL_H = 0xA0B + SYS___CONJ_B = 0xA04 + SYS___CONJ_H = 0xA05 + SYS___COPYSIGN_B = 0xA5A + SYS___COPYSIGN_H = 0xAF5 + SYS___COSPID128 = 0xC70 + SYS___COSPID32 = 0xC6E + SYS___COSPID64 = 0xC6F + SYS___CPOWF_B = 0xA10 + SYS___CPOWF_H = 0xA11 + SYS___CPOWL_B = 0xA13 + SYS___CPOWL_H = 0xA14 + SYS___CPOW_B = 0xA0D + SYS___CPOW_H = 0xA0E + SYS___CPROJF_B = 0xA19 + SYS___CPROJF_H = 0xA1A + SYS___CPROJL_B = 0xA1C + SYS___CPROJL_H = 0xA1D + SYS___CPROJ_B = 0xA16 + SYS___CPROJ_H = 0xA17 + SYS___CREALF_B = 0xA22 + SYS___CREALF_H = 0xA23 + SYS___CREALL_B = 0xA25 + SYS___CREALL_H = 0xA26 + SYS___CREAL_B = 0xA1F + SYS___CREAL_H = 0xA20 + SYS___CSINF_B = 0xA2B + SYS___CSINF_H = 0xA2C + SYS___CSINHF_B = 0xA34 + SYS___CSINHF_H = 0xA35 + SYS___CSINHL_B = 0xA37 + SYS___CSINHL_H = 0xA38 + SYS___CSINH_B = 0xA31 + SYS___CSINH_H = 0xA32 + SYS___CSINL_B = 0xA2E + SYS___CSINL_H = 0xA2F + SYS___CSIN_B = 0xA28 + SYS___CSIN_H = 0xA29 + SYS___CSNAP = 0x0C5 + SYS___CSQRTF_B = 0xA3D + SYS___CSQRTF_H = 0xA3E + SYS___CSQRTL_B = 0xA40 + SYS___CSQRTL_H = 0xA41 + SYS___CSQRT_B = 0xA3A + SYS___CSQRT_H = 0xA3B + SYS___CTANF_B = 0xA46 + SYS___CTANF_H = 0xA47 + SYS___CTANHF_B = 0xA4F + SYS___CTANHF_H = 0xA50 + SYS___CTANHL_B = 0xA52 + SYS___CTANHL_H = 0xA53 + SYS___CTANH_B = 0xA4C + SYS___CTANH_H = 0xA4D + SYS___CTANL_B = 0xA49 + SYS___CTANL_H = 0xA4A + SYS___CTAN_B = 0xA43 + SYS___CTAN_H = 0xA44 + SYS___CTEST = 0x0C7 + SYS___CTRACE = 0x0C6 + SYS___D1TOP = 0xC9B + SYS___D2TOP = 0xC9C + SYS___D4TOP = 0xC9D + SYS___DYNALL = 0x0C3 + SYS___DYNFRE = 0x0C2 + SYS___EXP2F_H = 0xA5E + SYS___EXP2L_H = 0xA5F + SYS___EXP2_H = 0xA5D + SYS___EXPM1F_H = 0xA5B + SYS___EXPM1L_H = 0xA5C + SYS___FBUFSIZE = 0xD60 + SYS___FLBF = 0xD62 + SYS___FLDATA = 0x0C1 + SYS___FMAF_B = 0xA67 + SYS___FMAF_H = 0xA68 + SYS___FMAL_B = 0xA6A + SYS___FMAL_H = 0xA6B + SYS___FMAXF_B = 0xA70 + SYS___FMAXF_H = 0xA71 + SYS___FMAXL_B = 0xA73 + SYS___FMAXL_H = 0xA74 + SYS___FMAX_B = 0xA6D + SYS___FMAX_H = 0xA6E + SYS___FMA_B = 0xA64 + SYS___FMA_H = 0xA65 + SYS___FMINF_B = 0xA79 + SYS___FMINF_H = 0xA7A + SYS___FMINL_B = 0xA7C + SYS___FMINL_H = 0xA7D + SYS___FMIN_B = 0xA76 + SYS___FMIN_H = 0xA77 + SYS___FPENDING = 0xD61 + SYS___FPENDING_UNLOCKED = 0xD6C + SYS___FPURGE = 0xD69 + SYS___FPURGE_UNLOCKED = 0xD70 + SYS___FP_CAST_D = 0xBCB + SYS___FREADABLE = 0xD63 + SYS___FREADAHEAD = 0xD6A + SYS___FREADAHEAD_UNLOCKED = 0xD71 + SYS___FREADING = 0xD65 + SYS___FREADING_UNLOCKED = 0xD6D + SYS___FSEEK2 = 0xB3C + SYS___FSETERR = 0xD6B + SYS___FSETLOCKING = 0xD67 + SYS___FTCHEP = 0x0BF + SYS___FTELL2 = 0xB3B + SYS___FUPDT = 0x0B5 + SYS___FWRITABLE = 0xD64 + SYS___FWRITING = 0xD66 + SYS___FWRITING_UNLOCKED = 0xD6E + SYS___GETCB = 0x0B4 + SYS___GETGRGID1 = 0xD5B + SYS___GETGRNAM1 = 0xD5C + SYS___GETTHENT = 0xCE5 + SYS___GETTOD = 0xD3E + SYS___HYPOTF_H = 0xAF6 + SYS___HYPOTL_H = 0xAF7 + SYS___ILOGBF_B = 0xA7F + SYS___ILOGBF_H = 0xA80 + SYS___ILOGBL_B = 0xA82 + SYS___ILOGBL_H = 0xA83 + SYS___ISBLANK_A = 0xB2E + SYS___ISBLNK = 0x0FE + SYS___ISWBLANK_A = 0xB2F + SYS___LE_CEEGTJS = 0xD72 + SYS___LE_TRACEBACK = 0xB7A + SYS___LGAMMAL_H = 0xA62 + SYS___LGAMMA_B_C99 = 0xB39 + SYS___LGAMMA_H_C99 = 0xB38 + SYS___LGAMMA_R_C99 = 0xB3A + SYS___LLRINTF_B = 0xA88 + SYS___LLRINTF_H = 0xA89 + SYS___LLRINTL_B = 0xA8B + SYS___LLRINTL_H = 0xA8C + SYS___LLRINT_B = 0xA85 + SYS___LLRINT_H = 0xA86 + SYS___LLROUNDF_B = 0xA91 + SYS___LLROUNDF_H = 0xA92 + SYS___LLROUNDL_B = 0xA94 + SYS___LLROUNDL_H = 0xA95 + SYS___LLROUND_B = 0xA8E + SYS___LLROUND_H = 0xA8F + SYS___LOCALE_CTL = 0xD47 + SYS___LOG1PF_H = 0xA60 + SYS___LOG1PL_H = 0xA61 + SYS___LOGBF_B = 0xA97 + SYS___LOGBF_H = 0xA98 + SYS___LOGBL_B = 0xA9A + SYS___LOGBL_H = 0xA9B + SYS___LOGIN_APPLID = 0xCE2 + SYS___LRINTF_B = 0xAA0 + SYS___LRINTF_H = 0xAA1 + SYS___LRINTL_B = 0xAA3 + SYS___LRINTL_H = 0xAA4 + SYS___LRINT_B = 0xA9D + SYS___LRINT_H = 0xA9E + SYS___LROUNDF_FIXUP = 0xB31 + SYS___LROUNDL_B = 0xAA6 + SYS___LROUNDL_H = 0xAA7 + SYS___LROUND_FIXUP = 0xB30 + SYS___MOSERVICES = 0xD3D + SYS___MUST_STAY_CLEAN = 0xB7C + SYS___NANF_B = 0xAAB + SYS___NANL_B = 0xAAD + SYS___NAN_B = 0xAA9 + SYS___NEARBYINTF_B = 0xAB2 + SYS___NEARBYINTF_H = 0xAB3 + SYS___NEARBYINTL_B = 0xAB5 + SYS___NEARBYINTL_H = 0xAB6 + SYS___NEARBYINT_B = 0xAAF + SYS___NEARBYINT_H = 0xAB0 + SYS___NEXTAFTERF_B = 0xAB8 + SYS___NEXTAFTERF_H = 0xAB9 + SYS___NEXTAFTERL_B = 0xABB + SYS___NEXTAFTERL_H = 0xABC + SYS___NEXTTOWARDF_B = 0xAC1 + SYS___NEXTTOWARDF_H = 0xAC2 + SYS___NEXTTOWARDL_B = 0xAC4 + SYS___NEXTTOWARDL_H = 0xAC5 + SYS___NEXTTOWARD_B = 0xABE + SYS___NEXTTOWARD_H = 0xABF + SYS___O_ENV = 0xB7D + SYS___PASSWD_APPLID = 0xCE3 + SYS___PTOD1 = 0xC9E + SYS___PTOD2 = 0xC9F + SYS___PTOD4 = 0xCA0 + SYS___REGCOMP_STD = 0x0EA + SYS___REMAINDERF_H = 0xAC6 + SYS___REMAINDERL_H = 0xAC7 + SYS___REMQUOD128 = 0xC10 + SYS___REMQUOD32 = 0xC0E + SYS___REMQUOD64 = 0xC0F + SYS___REMQUOF_H = 0xAC9 + SYS___REMQUOL_H = 0xACA + SYS___REMQUO_H = 0xAC8 + SYS___RINTF_B = 0xACC + SYS___RINTL_B = 0xACE + SYS___ROUNDF_B = 0xAD3 + SYS___ROUNDF_H = 0xAD4 + SYS___ROUNDL_B = 0xAD6 + SYS___ROUNDL_H = 0xAD7 + SYS___ROUND_B = 0xAD0 + SYS___ROUND_H = 0xAD1 + SYS___SCALBLNF_B = 0xADC + SYS___SCALBLNF_H = 0xADD + SYS___SCALBLNL_B = 0xADF + SYS___SCALBLNL_H = 0xAE0 + SYS___SCALBLN_B = 0xAD9 + SYS___SCALBLN_H = 0xADA + SYS___SCALBNF_B = 0xAE4 + SYS___SCALBNF_H = 0xAE5 + SYS___SCALBNL_B = 0xAE7 + SYS___SCALBNL_H = 0xAE8 + SYS___SCALBN_B = 0xAE1 + SYS___SCALBN_H = 0xAE2 + SYS___SETENV = 0x0C8 + SYS___SINPID128 = 0xC73 + SYS___SINPID32 = 0xC71 + SYS___SINPID64 = 0xC72 + SYS___SMF_RECORD2 = 0xD48 + SYS___STATIC_REINIT = 0xB3D + SYS___TGAMMAF_H_C99 = 0xB79 + SYS___TGAMMAL_H = 0xAE9 + SYS___TGAMMA_H_C99 = 0xB78 + SYS___TOCSNAME2 = 0xC9A + SYS_CEIL = 0x01F + SYS_CHAUDIT = 0x1E0 + SYS_EXP = 0x01A + SYS_FCHAUDIT = 0x1E1 + SYS_FREXP = 0x01D + SYS_GETGROUPSBYNAME = 0x1E2 + SYS_GETPWUID = 0x1A0 + SYS_GETUID = 0x1A1 + SYS_ISATTY = 0x1A3 + SYS_KILL = 0x1A4 + SYS_LDEXP = 0x01E + SYS_LINK = 0x1A5 + SYS_LOG10 = 0x01C + SYS_LSEEK = 0x1A6 + SYS_LSTAT = 0x1A7 + SYS_MKDIR = 0x1A8 + SYS_MKFIFO = 0x1A9 + SYS_MKNOD = 0x1AA + SYS_MODF = 0x01B + SYS_MOUNT = 0x1AB + SYS_OPEN = 0x1AC + SYS_OPENDIR = 0x1AD + SYS_PATHCONF = 0x1AE + SYS_PAUSE = 0x1AF + SYS_PIPE = 0x1B0 + SYS_PTHREAD_ATTR_DESTROY = 0x1E7 + SYS_PTHREAD_ATTR_GETDETACHSTATE = 0x1EB + SYS_PTHREAD_ATTR_GETSTACKSIZE = 0x1E9 + SYS_PTHREAD_ATTR_GETWEIGHT_NP = 0x1ED + SYS_PTHREAD_ATTR_INIT = 0x1E6 + SYS_PTHREAD_ATTR_SETDETACHSTATE = 0x1EA + SYS_PTHREAD_ATTR_SETSTACKSIZE = 0x1E8 + SYS_PTHREAD_ATTR_SETWEIGHT_NP = 0x1EC + SYS_PTHREAD_CANCEL = 0x1EE + SYS_PTHREAD_CLEANUP_POP = 0x1F0 + SYS_PTHREAD_CLEANUP_PUSH = 0x1EF + SYS_PTHREAD_CONDATTR_DESTROY = 0x1F2 + SYS_PTHREAD_CONDATTR_INIT = 0x1F1 + SYS_PTHREAD_COND_BROADCAST = 0x1F6 + SYS_PTHREAD_COND_DESTROY = 0x1F4 + SYS_PTHREAD_COND_INIT = 0x1F3 + SYS_PTHREAD_COND_SIGNAL = 0x1F5 + SYS_PTHREAD_COND_TIMEDWAIT = 0x1F8 + SYS_PTHREAD_COND_WAIT = 0x1F7 + SYS_PTHREAD_CREATE = 0x1F9 + SYS_PTHREAD_DETACH = 0x1FA + SYS_PTHREAD_EQUAL = 0x1FB + SYS_PTHREAD_EXIT = 0x1E4 + SYS_PTHREAD_GETSPECIFIC = 0x1FC + SYS_PTHREAD_JOIN = 0x1FD + SYS_PTHREAD_KEY_CREATE = 0x1FE + SYS_PTHREAD_KILL = 0x1E5 + SYS_PTHREAD_MUTEXATTR_INIT = 0x1FF + SYS_READ = 0x1B2 + SYS_READDIR = 0x1B3 + SYS_READLINK = 0x1B4 + SYS_REWINDDIR = 0x1B5 + SYS_RMDIR = 0x1B6 + SYS_SETEGID = 0x1B7 + SYS_SETEUID = 0x1B8 + SYS_SETGID = 0x1B9 + SYS_SETPGID = 0x1BA + SYS_SETSID = 0x1BB + SYS_SETUID = 0x1BC + SYS_SIGACTION = 0x1BD + SYS_SIGADDSET = 0x1BE + SYS_SIGDELSET = 0x1BF + SYS_SIGEMPTYSET = 0x1C0 + SYS_SIGFILLSET = 0x1C1 + SYS_SIGISMEMBER = 0x1C2 + SYS_SIGLONGJMP = 0x1C3 + SYS_SIGPENDING = 0x1C4 + SYS_SIGPROCMASK = 0x1C5 + SYS_SIGSETJMP = 0x1C6 + SYS_SIGSUSPEND = 0x1C7 + SYS_SIGWAIT = 0x1E3 + SYS_SLEEP = 0x1C8 + SYS_STAT = 0x1C9 + SYS_SYMLINK = 0x1CB + SYS_SYSCONF = 0x1CC + SYS_TCDRAIN = 0x1CD + SYS_TCFLOW = 0x1CE + SYS_TCFLUSH = 0x1CF + SYS_TCGETATTR = 0x1D0 + SYS_TCGETPGRP = 0x1D1 + SYS_TCSENDBREAK = 0x1D2 + SYS_TCSETATTR = 0x1D3 + SYS_TCSETPGRP = 0x1D4 + SYS_TIMES = 0x1D5 + SYS_TTYNAME = 0x1D6 + SYS_TZSET = 0x1D7 + SYS_UMASK = 0x1D8 + SYS_UMOUNT = 0x1D9 + SYS_UNAME = 0x1DA + SYS_UNLINK = 0x1DB + SYS_UTIME = 0x1DC + SYS_WAIT = 0x1DD + SYS_WAITPID = 0x1DE + SYS_WRITE = 0x1DF + SYS_W_GETPSENT = 0x1B1 + SYS_W_IOCTL = 0x1A2 + SYS_W_STATFS = 0x1CA + SYS_A64L = 0x2EF + SYS_BCMP = 0x2B9 + SYS_BCOPY = 0x2BA + SYS_BZERO = 0x2BB + SYS_CATCLOSE = 0x2B6 + SYS_CATGETS = 0x2B7 + SYS_CATOPEN = 0x2B8 + SYS_CRYPT = 0x2AC + SYS_DBM_CLEARERR = 0x2F7 + SYS_DBM_CLOSE = 0x2F8 + SYS_DBM_DELETE = 0x2F9 + SYS_DBM_ERROR = 0x2FA + SYS_DBM_FETCH = 0x2FB + SYS_DBM_FIRSTKEY = 0x2FC + SYS_DBM_NEXTKEY = 0x2FD + SYS_DBM_OPEN = 0x2FE + SYS_DBM_STORE = 0x2FF + SYS_DRAND48 = 0x2B2 + SYS_ENCRYPT = 0x2AD + SYS_ENDUTXENT = 0x2E1 + SYS_ERAND48 = 0x2B3 + SYS_ERF = 0x02C + SYS_ERFC = 0x02D + SYS_FCHDIR = 0x2D9 + SYS_FFS = 0x2BC + SYS_FMTMSG = 0x2E5 + SYS_FSTATVFS = 0x2B4 + SYS_FTIME = 0x2F5 + SYS_GAMMA = 0x02E + SYS_GETDATE = 0x2A6 + SYS_GETPAGESIZE = 0x2D8 + SYS_GETTIMEOFDAY = 0x2F6 + SYS_GETUTXENT = 0x2E0 + SYS_GETUTXID = 0x2E2 + SYS_GETUTXLINE = 0x2E3 + SYS_HCREATE = 0x2C6 + SYS_HDESTROY = 0x2C7 + SYS_HSEARCH = 0x2C8 + SYS_HYPOT = 0x02B + SYS_INDEX = 0x2BD + SYS_INITSTATE = 0x2C2 + SYS_INSQUE = 0x2CF + SYS_ISASCII = 0x2ED + SYS_JRAND48 = 0x2E6 + SYS_L64A = 0x2F0 + SYS_LCONG48 = 0x2EA + SYS_LFIND = 0x2C9 + SYS_LRAND48 = 0x2E7 + SYS_LSEARCH = 0x2CA + SYS_MEMCCPY = 0x2D4 + SYS_MRAND48 = 0x2E8 + SYS_NRAND48 = 0x2E9 + SYS_PCLOSE = 0x2D2 + SYS_POPEN = 0x2D1 + SYS_PUTUTXLINE = 0x2E4 + SYS_RANDOM = 0x2C4 + SYS_REMQUE = 0x2D0 + SYS_RINDEX = 0x2BE + SYS_SEED48 = 0x2EC + SYS_SETKEY = 0x2AE + SYS_SETSTATE = 0x2C3 + SYS_SETUTXENT = 0x2DF + SYS_SRAND48 = 0x2EB + SYS_SRANDOM = 0x2C5 + SYS_STATVFS = 0x2B5 + SYS_STRCASECMP = 0x2BF + SYS_STRDUP = 0x2C0 + SYS_STRNCASECMP = 0x2C1 + SYS_SWAB = 0x2D3 + SYS_TDELETE = 0x2CB + SYS_TFIND = 0x2CC + SYS_TOASCII = 0x2EE + SYS_TSEARCH = 0x2CD + SYS_TWALK = 0x2CE + SYS_UALARM = 0x2F1 + SYS_USLEEP = 0x2F2 + SYS_WAIT3 = 0x2A7 + SYS_WAITID = 0x2A8 + SYS_Y1 = 0x02A + SYS___ATOE = 0x2DB + SYS___ATOE_L = 0x2DC + SYS___CATTRM = 0x2A9 + SYS___CNVBLK = 0x2AF + SYS___CRYTRM = 0x2B0 + SYS___DLGHT = 0x2A1 + SYS___ECRTRM = 0x2B1 + SYS___ETOA = 0x2DD + SYS___ETOA_L = 0x2DE + SYS___GDTRM = 0x2AA + SYS___OCLCK = 0x2DA + SYS___OPARGF = 0x2A2 + SYS___OPERRF = 0x2A5 + SYS___OPINDF = 0x2A4 + SYS___OPOPTF = 0x2A3 + SYS___RNDTRM = 0x2AB + SYS___SRCTRM = 0x2F4 + SYS___TZONE = 0x2A0 + SYS___UTXTRM = 0x2F3 + SYS_ASIN = 0x03E + SYS_ISXDIGIT = 0x03B + SYS_SETLOCAL = 0x03A + SYS_SETLOCALE = 0x03A + SYS_SIN = 0x03F + SYS_TOLOWER = 0x03C + SYS_TOUPPER = 0x03D + SYS_ACCEPT_AND_RECV = 0x4F7 + SYS_ATOL = 0x04E + SYS_CHECKSCH = 0x4BC + SYS_CHECKSCHENV = 0x4BC + SYS_CLEARERR = 0x04C + SYS_CONNECTS = 0x4B5 + SYS_CONNECTSERVER = 0x4B5 + SYS_CONNECTW = 0x4B4 + SYS_CONNECTWORKMGR = 0x4B4 + SYS_CONTINUE = 0x4B3 + SYS_CONTINUEWORKUNIT = 0x4B3 + SYS_COPYSIGN = 0x4C2 + SYS_CREATEWO = 0x4B2 + SYS_CREATEWORKUNIT = 0x4B2 + SYS_DELETEWO = 0x4B9 + SYS_DELETEWORKUNIT = 0x4B9 + SYS_DISCONNE = 0x4B6 + SYS_DISCONNECTSERVER = 0x4B6 + SYS_FEOF = 0x04D + SYS_FERROR = 0x04A + SYS_FINITE = 0x4C8 + SYS_GAMMA_R = 0x4E2 + SYS_JOINWORK = 0x4B7 + SYS_JOINWORKUNIT = 0x4B7 + SYS_LEAVEWOR = 0x4B8 + SYS_LEAVEWORKUNIT = 0x4B8 + SYS_LGAMMA_R = 0x4EB + SYS_MATHERR = 0x4D0 + SYS_PERROR = 0x04F + SYS_QUERYMET = 0x4BA + SYS_QUERYMETRICS = 0x4BA + SYS_QUERYSCH = 0x4BB + SYS_QUERYSCHENV = 0x4BB + SYS_REWIND = 0x04B + SYS_SCALBN = 0x4D4 + SYS_SIGNIFIC = 0x4D5 + SYS_SIGNIFICAND = 0x4D5 + SYS___ACOSH_B = 0x4DA + SYS___ACOS_B = 0x4D9 + SYS___ASINH_B = 0x4BE + SYS___ASIN_B = 0x4DB + SYS___ATAN2_B = 0x4DC + SYS___ATANH_B = 0x4DD + SYS___ATAN_B = 0x4BF + SYS___CBRT_B = 0x4C0 + SYS___CEIL_B = 0x4C1 + SYS___COSH_B = 0x4DE + SYS___COS_B = 0x4C3 + SYS___DGHT = 0x4A8 + SYS___ENVN = 0x4B0 + SYS___ERFC_B = 0x4C5 + SYS___ERF_B = 0x4C4 + SYS___EXPM1_B = 0x4C6 + SYS___EXP_B = 0x4DF + SYS___FABS_B = 0x4C7 + SYS___FLOOR_B = 0x4C9 + SYS___FMOD_B = 0x4E0 + SYS___FP_SETMODE = 0x4F8 + SYS___FREXP_B = 0x4CA + SYS___GAMMA_B = 0x4E1 + SYS___GDRR = 0x4A1 + SYS___HRRNO = 0x4A2 + SYS___HYPOT_B = 0x4E3 + SYS___ILOGB_B = 0x4CB + SYS___ISNAN_B = 0x4CC + SYS___J0_B = 0x4E4 + SYS___J1_B = 0x4E6 + SYS___JN_B = 0x4E8 + SYS___LDEXP_B = 0x4CD + SYS___LGAMMA_B = 0x4EA + SYS___LOG10_B = 0x4ED + SYS___LOG1P_B = 0x4CE + SYS___LOGB_B = 0x4CF + SYS___LOGIN = 0x4F5 + SYS___LOG_B = 0x4EC + SYS___MLOCKALL = 0x4B1 + SYS___MODF_B = 0x4D1 + SYS___NEXTAFTER_B = 0x4D2 + SYS___OPENDIR2 = 0x4F3 + SYS___OPEN_STAT = 0x4F6 + SYS___OPND = 0x4A5 + SYS___OPPT = 0x4A6 + SYS___OPRG = 0x4A3 + SYS___OPRR = 0x4A4 + SYS___PID_AFFINITY = 0x4BD + SYS___POW_B = 0x4EE + SYS___READDIR2 = 0x4F4 + SYS___REMAINDER_B = 0x4EF + SYS___RINT_B = 0x4D3 + SYS___SCALB_B = 0x4F0 + SYS___SIGACTIONSET = 0x4FB + SYS___SIGGM = 0x4A7 + SYS___SINH_B = 0x4F1 + SYS___SIN_B = 0x4D6 + SYS___SQRT_B = 0x4F2 + SYS___TANH_B = 0x4D8 + SYS___TAN_B = 0x4D7 + SYS___TRRNO = 0x4AF + SYS___TZNE = 0x4A9 + SYS___TZZN = 0x4AA + SYS___UCREATE = 0x4FC + SYS___UFREE = 0x4FE + SYS___UHEAPREPORT = 0x4FF + SYS___UMALLOC = 0x4FD + SYS___Y0_B = 0x4E5 + SYS___Y1_B = 0x4E7 + SYS___YN_B = 0x4E9 + SYS_ABORT = 0x05C + SYS_ASCTIME_R = 0x5E0 + SYS_ATEXIT = 0x05D + SYS_CONNECTE = 0x5AE + SYS_CONNECTEXPORTIMPORT = 0x5AE + SYS_CTIME_R = 0x5E1 + SYS_DN_COMP = 0x5DF + SYS_DN_EXPAND = 0x5DD + SYS_DN_SKIPNAME = 0x5DE + SYS_EXIT = 0x05A + SYS_EXPORTWO = 0x5A1 + SYS_EXPORTWORKUNIT = 0x5A1 + SYS_EXTRACTW = 0x5A5 + SYS_EXTRACTWORKUNIT = 0x5A5 + SYS_FSEEKO = 0x5C9 + SYS_FTELLO = 0x5C8 + SYS_GETGRGID_R = 0x5E7 + SYS_GETGRNAM_R = 0x5E8 + SYS_GETLOGIN_R = 0x5E9 + SYS_GETPWNAM_R = 0x5EA + SYS_GETPWUID_R = 0x5EB + SYS_GMTIME_R = 0x5E2 + SYS_IMPORTWO = 0x5A3 + SYS_IMPORTWORKUNIT = 0x5A3 + SYS_INET_NTOP = 0x5D3 + SYS_INET_PTON = 0x5D4 + SYS_LLABS = 0x5CE + SYS_LLDIV = 0x5CB + SYS_LOCALTIME_R = 0x5E3 + SYS_PTHREAD_ATFORK = 0x5ED + SYS_PTHREAD_ATTR_GETDETACHSTATE_U98 = 0x5FB + SYS_PTHREAD_ATTR_GETGUARDSIZE = 0x5EE + SYS_PTHREAD_ATTR_GETSCHEDPARAM = 0x5F9 + SYS_PTHREAD_ATTR_GETSTACKADDR = 0x5EF + SYS_PTHREAD_ATTR_SETDETACHSTATE_U98 = 0x5FC + SYS_PTHREAD_ATTR_SETGUARDSIZE = 0x5F0 + SYS_PTHREAD_ATTR_SETSCHEDPARAM = 0x5FA + SYS_PTHREAD_ATTR_SETSTACKADDR = 0x5F1 + SYS_PTHREAD_CONDATTR_GETPSHARED = 0x5F2 + SYS_PTHREAD_CONDATTR_SETPSHARED = 0x5F3 + SYS_PTHREAD_DETACH_U98 = 0x5FD + SYS_PTHREAD_GETCONCURRENCY = 0x5F4 + SYS_PTHREAD_GETSPECIFIC_U98 = 0x5FE + SYS_PTHREAD_KEY_DELETE = 0x5F5 + SYS_PTHREAD_SETCANCELSTATE = 0x5FF + SYS_PTHREAD_SETCONCURRENCY = 0x5F6 + SYS_PTHREAD_SIGMASK = 0x5F7 + SYS_QUERYENC = 0x5AD + SYS_QUERYWORKUNITCLASSIFICATION = 0x5AD + SYS_RAISE = 0x05E + SYS_RAND_R = 0x5E4 + SYS_READDIR_R = 0x5E6 + SYS_REALLOC = 0x05B + SYS_RES_INIT = 0x5D8 + SYS_RES_MKQUERY = 0x5D7 + SYS_RES_QUERY = 0x5D9 + SYS_RES_QUERYDOMAIN = 0x5DC + SYS_RES_SEARCH = 0x5DA + SYS_RES_SEND = 0x5DB + SYS_SETJMP = 0x05F + SYS_SIGQUEUE = 0x5A9 + SYS_STRTOK_R = 0x5E5 + SYS_STRTOLL = 0x5B0 + SYS_STRTOULL = 0x5B1 + SYS_TTYNAME_R = 0x5EC + SYS_UNDOEXPO = 0x5A2 + SYS_UNDOEXPORTWORKUNIT = 0x5A2 + SYS_UNDOIMPO = 0x5A4 + SYS_UNDOIMPORTWORKUNIT = 0x5A4 + SYS_WCSTOLL = 0x5CC + SYS_WCSTOULL = 0x5CD + SYS___ABORT = 0x05C + SYS___CONSOLE2 = 0x5D2 + SYS___CPL = 0x5A6 + SYS___DISCARDDATA = 0x5F8 + SYS___DSA_PREV = 0x5B2 + SYS___EP_FIND = 0x5B3 + SYS___FP_SWAPMODE = 0x5AF + SYS___GETUSERID = 0x5AB + SYS___GET_CPUID = 0x5B9 + SYS___GET_SYSTEM_SETTINGS = 0x5BA + SYS___IPDOMAINNAME = 0x5AC + SYS___MAP_INIT = 0x5A7 + SYS___MAP_SERVICE = 0x5A8 + SYS___MOUNT = 0x5AA + SYS___MSGRCV_TIMED = 0x5B7 + SYS___RES = 0x5D6 + SYS___SEMOP_TIMED = 0x5B8 + SYS___SERVER_THREADS_QUERY = 0x5B4 + SYS_FPRINTF = 0x06D + SYS_FSCANF = 0x06A + SYS_PRINTF = 0x06F + SYS_SETBUF = 0x06B + SYS_SETVBUF = 0x06C + SYS_SSCANF = 0x06E + SYS___CATGETS_A = 0x6C0 + SYS___CHAUDIT_A = 0x6F4 + SYS___CHMOD_A = 0x6E8 + SYS___COLLATE_INIT_A = 0x6AC + SYS___CREAT_A = 0x6F6 + SYS___CTYPE_INIT_A = 0x6AF + SYS___DLLLOAD_A = 0x6DF + SYS___DLLQUERYFN_A = 0x6E0 + SYS___DLLQUERYVAR_A = 0x6E1 + SYS___E2A_L = 0x6E3 + SYS___EXECLE_A = 0x6A0 + SYS___EXECLP_A = 0x6A4 + SYS___EXECVE_A = 0x6C1 + SYS___EXECVP_A = 0x6C2 + SYS___EXECV_A = 0x6B1 + SYS___FPRINTF_A = 0x6FA + SYS___GETADDRINFO_A = 0x6BF + SYS___GETNAMEINFO_A = 0x6C4 + SYS___GET_WCTYPE_STD_A = 0x6AE + SYS___ICONV_OPEN_A = 0x6DE + SYS___IF_INDEXTONAME_A = 0x6DC + SYS___IF_NAMETOINDEX_A = 0x6DB + SYS___ISWCTYPE_A = 0x6B0 + SYS___IS_WCTYPE_STD_A = 0x6B2 + SYS___LOCALECONV_A = 0x6B8 + SYS___LOCALECONV_STD_A = 0x6B9 + SYS___LOCALE_INIT_A = 0x6B7 + SYS___LSTAT_A = 0x6EE + SYS___LSTAT_O_A = 0x6EF + SYS___MKDIR_A = 0x6E9 + SYS___MKFIFO_A = 0x6EC + SYS___MKNOD_A = 0x6F0 + SYS___MONETARY_INIT_A = 0x6BC + SYS___MOUNT_A = 0x6F1 + SYS___NL_CSINFO_A = 0x6D6 + SYS___NL_LANGINFO_A = 0x6BA + SYS___NL_LNAGINFO_STD_A = 0x6BB + SYS___NL_MONINFO_A = 0x6D7 + SYS___NL_NUMINFO_A = 0x6D8 + SYS___NL_RESPINFO_A = 0x6D9 + SYS___NL_TIMINFO_A = 0x6DA + SYS___NUMERIC_INIT_A = 0x6C6 + SYS___OPEN_A = 0x6F7 + SYS___PRINTF_A = 0x6DD + SYS___RESP_INIT_A = 0x6C7 + SYS___RPMATCH_A = 0x6C8 + SYS___RPMATCH_C_A = 0x6C9 + SYS___RPMATCH_STD_A = 0x6CA + SYS___SETLOCALE_A = 0x6F9 + SYS___SPAWNP_A = 0x6C5 + SYS___SPAWN_A = 0x6C3 + SYS___SPRINTF_A = 0x6FB + SYS___STAT_A = 0x6EA + SYS___STAT_O_A = 0x6EB + SYS___STRCOLL_STD_A = 0x6A1 + SYS___STRFMON_A = 0x6BD + SYS___STRFMON_STD_A = 0x6BE + SYS___STRFTIME_A = 0x6CC + SYS___STRFTIME_STD_A = 0x6CD + SYS___STRPTIME_A = 0x6CE + SYS___STRPTIME_STD_A = 0x6CF + SYS___STRXFRM_A = 0x6A2 + SYS___STRXFRM_C_A = 0x6A3 + SYS___STRXFRM_STD_A = 0x6A5 + SYS___SYNTAX_INIT_A = 0x6D4 + SYS___TIME_INIT_A = 0x6CB + SYS___TOD_INIT_A = 0x6D5 + SYS___TOWLOWER_A = 0x6B3 + SYS___TOWLOWER_STD_A = 0x6B4 + SYS___TOWUPPER_A = 0x6B5 + SYS___TOWUPPER_STD_A = 0x6B6 + SYS___UMOUNT_A = 0x6F2 + SYS___VFPRINTF_A = 0x6FC + SYS___VPRINTF_A = 0x6FD + SYS___VSPRINTF_A = 0x6FE + SYS___VSWPRINTF_A = 0x6FF + SYS___WCSCOLL_A = 0x6A6 + SYS___WCSCOLL_C_A = 0x6A7 + SYS___WCSCOLL_STD_A = 0x6A8 + SYS___WCSFTIME_A = 0x6D0 + SYS___WCSFTIME_STD_A = 0x6D1 + SYS___WCSXFRM_A = 0x6A9 + SYS___WCSXFRM_C_A = 0x6AA + SYS___WCSXFRM_STD_A = 0x6AB + SYS___WCTYPE_A = 0x6AD + SYS___W_GETMNTENT_A = 0x6F5 + SYS_____CCSIDTYPE_A = 0x6E6 + SYS_____CHATTR_A = 0x6E2 + SYS_____CSNAMETYPE_A = 0x6E7 + SYS_____OPEN_STAT_A = 0x6ED + SYS_____SPAWN2_A = 0x6D2 + SYS_____SPAWNP2_A = 0x6D3 + SYS_____TOCCSID_A = 0x6E4 + SYS_____TOCSNAME_A = 0x6E5 + SYS_ACL_FREE = 0x7FF + SYS_ACL_INIT = 0x7FE + SYS_FWIDE = 0x7DF + SYS_FWPRINTF = 0x7D1 + SYS_FWRITE = 0x07E + SYS_FWSCANF = 0x7D5 + SYS_GETCHAR = 0x07B + SYS_GETS = 0x07C + SYS_M_CREATE_LAYOUT = 0x7C9 + SYS_M_DESTROY_LAYOUT = 0x7CA + SYS_M_GETVALUES_LAYOUT = 0x7CB + SYS_M_SETVALUES_LAYOUT = 0x7CC + SYS_M_TRANSFORM_LAYOUT = 0x7CD + SYS_M_WTRANSFORM_LAYOUT = 0x7CE + SYS_PREAD = 0x7C7 + SYS_PUTC = 0x07D + SYS_PUTCHAR = 0x07A + SYS_PUTS = 0x07F + SYS_PWRITE = 0x7C8 + SYS_TOWCTRAN = 0x7D8 + SYS_TOWCTRANS = 0x7D8 + SYS_UNATEXIT = 0x7B5 + SYS_VFWPRINT = 0x7D3 + SYS_VFWPRINTF = 0x7D3 + SYS_VWPRINTF = 0x7D4 + SYS_WCTRANS = 0x7D7 + SYS_WPRINTF = 0x7D2 + SYS_WSCANF = 0x7D6 + SYS___ASCTIME_R_A = 0x7A1 + SYS___BASENAME_A = 0x7DC + SYS___BTOWC_A = 0x7E4 + SYS___CDUMP_A = 0x7B7 + SYS___CEE3DMP_A = 0x7B6 + SYS___CEILF_H = 0x7F4 + SYS___CEILL_H = 0x7F5 + SYS___CEIL_H = 0x7EA + SYS___CRYPT_A = 0x7BE + SYS___CSNAP_A = 0x7B8 + SYS___CTEST_A = 0x7B9 + SYS___CTIME_R_A = 0x7A2 + SYS___CTRACE_A = 0x7BA + SYS___DBM_OPEN_A = 0x7E6 + SYS___DIRNAME_A = 0x7DD + SYS___FABSF_H = 0x7FA + SYS___FABSL_H = 0x7FB + SYS___FABS_H = 0x7ED + SYS___FGETWC_A = 0x7AA + SYS___FGETWS_A = 0x7AD + SYS___FLOORF_H = 0x7F6 + SYS___FLOORL_H = 0x7F7 + SYS___FLOOR_H = 0x7EB + SYS___FPUTWC_A = 0x7A5 + SYS___FPUTWS_A = 0x7A8 + SYS___GETTIMEOFDAY_A = 0x7AE + SYS___GETWCHAR_A = 0x7AC + SYS___GETWC_A = 0x7AB + SYS___GLOB_A = 0x7DE + SYS___GMTIME_A = 0x7AF + SYS___GMTIME_R_A = 0x7B0 + SYS___INET_PTON_A = 0x7BC + SYS___J0_H = 0x7EE + SYS___J1_H = 0x7EF + SYS___JN_H = 0x7F0 + SYS___LOCALTIME_A = 0x7B1 + SYS___LOCALTIME_R_A = 0x7B2 + SYS___MALLOC24 = 0x7FC + SYS___MALLOC31 = 0x7FD + SYS___MKTIME_A = 0x7B3 + SYS___MODFF_H = 0x7F8 + SYS___MODFL_H = 0x7F9 + SYS___MODF_H = 0x7EC + SYS___OPENDIR_A = 0x7C2 + SYS___OSNAME = 0x7E0 + SYS___PUTWCHAR_A = 0x7A7 + SYS___PUTWC_A = 0x7A6 + SYS___READDIR_A = 0x7C3 + SYS___STRTOLL_A = 0x7A3 + SYS___STRTOULL_A = 0x7A4 + SYS___SYSLOG_A = 0x7BD + SYS___TZZNA = 0x7B4 + SYS___UNGETWC_A = 0x7A9 + SYS___UTIME_A = 0x7A0 + SYS___VFPRINTF2_A = 0x7E7 + SYS___VPRINTF2_A = 0x7E8 + SYS___VSPRINTF2_A = 0x7E9 + SYS___VSWPRNTF2_A = 0x7BB + SYS___WCSTOD_A = 0x7D9 + SYS___WCSTOL_A = 0x7DA + SYS___WCSTOUL_A = 0x7DB + SYS___WCTOB_A = 0x7E5 + SYS___Y0_H = 0x7F1 + SYS___Y1_H = 0x7F2 + SYS___YN_H = 0x7F3 + SYS_____OPENDIR2_A = 0x7BF + SYS_____OSNAME_A = 0x7E1 + SYS_____READDIR2_A = 0x7C0 + SYS_DLCLOSE = 0x8DF + SYS_DLERROR = 0x8E0 + SYS_DLOPEN = 0x8DD + SYS_DLSYM = 0x8DE + SYS_FLOCKFILE = 0x8D3 + SYS_FTRYLOCKFILE = 0x8D4 + SYS_FUNLOCKFILE = 0x8D5 + SYS_GETCHAR_UNLOCKED = 0x8D7 + SYS_GETC_UNLOCKED = 0x8D6 + SYS_PUTCHAR_UNLOCKED = 0x8D9 + SYS_PUTC_UNLOCKED = 0x8D8 + SYS_SNPRINTF = 0x8DA + SYS_VSNPRINTF = 0x8DB + SYS_WCSCSPN = 0x08B + SYS_WCSLEN = 0x08C + SYS_WCSNCAT = 0x08D + SYS_WCSNCMP = 0x08A + SYS_WCSNCPY = 0x08F + SYS_WCSSPN = 0x08E + SYS___ABSF_H = 0x8E7 + SYS___ABSL_H = 0x8E8 + SYS___ABS_H = 0x8E6 + SYS___ACOSF_H = 0x8EA + SYS___ACOSH_H = 0x8EC + SYS___ACOSL_H = 0x8EB + SYS___ACOS_H = 0x8E9 + SYS___ASINF_H = 0x8EE + SYS___ASINH_H = 0x8F0 + SYS___ASINL_H = 0x8EF + SYS___ASIN_H = 0x8ED + SYS___ATAN2F_H = 0x8F8 + SYS___ATAN2L_H = 0x8F9 + SYS___ATAN2_H = 0x8F7 + SYS___ATANF_H = 0x8F2 + SYS___ATANHF_H = 0x8F5 + SYS___ATANHL_H = 0x8F6 + SYS___ATANH_H = 0x8F4 + SYS___ATANL_H = 0x8F3 + SYS___ATAN_H = 0x8F1 + SYS___CBRT_H = 0x8FA + SYS___COPYSIGNF_H = 0x8FB + SYS___COPYSIGNL_H = 0x8FC + SYS___COSF_H = 0x8FE + SYS___COSL_H = 0x8FF + SYS___COS_H = 0x8FD + SYS___DLERROR_A = 0x8D2 + SYS___DLOPEN_A = 0x8D0 + SYS___DLSYM_A = 0x8D1 + SYS___GETUTXENT_A = 0x8C6 + SYS___GETUTXID_A = 0x8C7 + SYS___GETUTXLINE_A = 0x8C8 + SYS___ITOA = 0x8AA + SYS___ITOA_A = 0x8B0 + SYS___LE_CONDITION_TOKEN_BUILD = 0x8A5 + SYS___LE_MSG_ADD_INSERT = 0x8A6 + SYS___LE_MSG_GET = 0x8A7 + SYS___LE_MSG_GET_AND_WRITE = 0x8A8 + SYS___LE_MSG_WRITE = 0x8A9 + SYS___LLTOA = 0x8AE + SYS___LLTOA_A = 0x8B4 + SYS___LTOA = 0x8AC + SYS___LTOA_A = 0x8B2 + SYS___PUTCHAR_UNLOCKED_A = 0x8CC + SYS___PUTC_UNLOCKED_A = 0x8CB + SYS___PUTUTXLINE_A = 0x8C9 + SYS___RESET_EXCEPTION_HANDLER = 0x8E3 + SYS___REXEC_A = 0x8C4 + SYS___REXEC_AF_A = 0x8C5 + SYS___SET_EXCEPTION_HANDLER = 0x8E2 + SYS___SNPRINTF_A = 0x8CD + SYS___SUPERKILL = 0x8A4 + SYS___TCGETATTR_A = 0x8A1 + SYS___TCSETATTR_A = 0x8A2 + SYS___ULLTOA = 0x8AF + SYS___ULLTOA_A = 0x8B5 + SYS___ULTOA = 0x8AD + SYS___ULTOA_A = 0x8B3 + SYS___UTOA = 0x8AB + SYS___UTOA_A = 0x8B1 + SYS___VHM_EVENT = 0x8E4 + SYS___VSNPRINTF_A = 0x8CE + SYS_____GETENV_A = 0x8C3 + SYS_____UTMPXNAME_A = 0x8CA + SYS_CACOSH = 0x9A0 + SYS_CACOSHF = 0x9A3 + SYS_CACOSHL = 0x9A6 + SYS_CARG = 0x9A9 + SYS_CARGF = 0x9AC + SYS_CARGL = 0x9AF + SYS_CASIN = 0x9B2 + SYS_CASINF = 0x9B5 + SYS_CASINH = 0x9BB + SYS_CASINHF = 0x9BE + SYS_CASINHL = 0x9C1 + SYS_CASINL = 0x9B8 + SYS_CATAN = 0x9C4 + SYS_CATANF = 0x9C7 + SYS_CATANH = 0x9CD + SYS_CATANHF = 0x9D0 + SYS_CATANHL = 0x9D3 + SYS_CATANL = 0x9CA + SYS_CCOS = 0x9D6 + SYS_CCOSF = 0x9D9 + SYS_CCOSH = 0x9DF + SYS_CCOSHF = 0x9E2 + SYS_CCOSHL = 0x9E5 + SYS_CCOSL = 0x9DC + SYS_CEXP = 0x9E8 + SYS_CEXPF = 0x9EB + SYS_CEXPL = 0x9EE + SYS_CIMAG = 0x9F1 + SYS_CIMAGF = 0x9F4 + SYS_CIMAGL = 0x9F7 + SYS_CLOGF = 0x9FD + SYS_MEMCHR = 0x09B + SYS_MEMCMP = 0x09A + SYS_STRCOLL = 0x09C + SYS_STRNCMP = 0x09D + SYS_STRRCHR = 0x09F + SYS_STRXFRM = 0x09E + SYS___CACOSHF_B = 0x9A4 + SYS___CACOSHF_H = 0x9A5 + SYS___CACOSHL_B = 0x9A7 + SYS___CACOSHL_H = 0x9A8 + SYS___CACOSH_B = 0x9A1 + SYS___CACOSH_H = 0x9A2 + SYS___CARGF_B = 0x9AD + SYS___CARGF_H = 0x9AE + SYS___CARGL_B = 0x9B0 + SYS___CARGL_H = 0x9B1 + SYS___CARG_B = 0x9AA + SYS___CARG_H = 0x9AB + SYS___CASINF_B = 0x9B6 + SYS___CASINF_H = 0x9B7 + SYS___CASINHF_B = 0x9BF + SYS___CASINHF_H = 0x9C0 + SYS___CASINHL_B = 0x9C2 + SYS___CASINHL_H = 0x9C3 + SYS___CASINH_B = 0x9BC + SYS___CASINH_H = 0x9BD + SYS___CASINL_B = 0x9B9 + SYS___CASINL_H = 0x9BA + SYS___CASIN_B = 0x9B3 + SYS___CASIN_H = 0x9B4 + SYS___CATANF_B = 0x9C8 + SYS___CATANF_H = 0x9C9 + SYS___CATANHF_B = 0x9D1 + SYS___CATANHF_H = 0x9D2 + SYS___CATANHL_B = 0x9D4 + SYS___CATANHL_H = 0x9D5 + SYS___CATANH_B = 0x9CE + SYS___CATANH_H = 0x9CF + SYS___CATANL_B = 0x9CB + SYS___CATANL_H = 0x9CC + SYS___CATAN_B = 0x9C5 + SYS___CATAN_H = 0x9C6 + SYS___CCOSF_B = 0x9DA + SYS___CCOSF_H = 0x9DB + SYS___CCOSHF_B = 0x9E3 + SYS___CCOSHF_H = 0x9E4 + SYS___CCOSHL_B = 0x9E6 + SYS___CCOSHL_H = 0x9E7 + SYS___CCOSH_B = 0x9E0 + SYS___CCOSH_H = 0x9E1 + SYS___CCOSL_B = 0x9DD + SYS___CCOSL_H = 0x9DE + SYS___CCOS_B = 0x9D7 + SYS___CCOS_H = 0x9D8 + SYS___CEXPF_B = 0x9EC + SYS___CEXPF_H = 0x9ED + SYS___CEXPL_B = 0x9EF + SYS___CEXPL_H = 0x9F0 + SYS___CEXP_B = 0x9E9 + SYS___CEXP_H = 0x9EA + SYS___CIMAGF_B = 0x9F5 + SYS___CIMAGF_H = 0x9F6 + SYS___CIMAGL_B = 0x9F8 + SYS___CIMAGL_H = 0x9F9 + SYS___CIMAG_B = 0x9F2 + SYS___CIMAG_H = 0x9F3 + SYS___CLOG = 0x9FA + SYS___CLOGF_B = 0x9FE + SYS___CLOGF_H = 0x9FF + SYS___CLOG_B = 0x9FB + SYS___CLOG_H = 0x9FC + SYS_ISWCTYPE = 0x10C + SYS_ISWXDIGI = 0x10A + SYS_ISWXDIGIT = 0x10A + SYS_MBSINIT = 0x10F + SYS_TOWLOWER = 0x10D + SYS_TOWUPPER = 0x10E + SYS_WCTYPE = 0x10B + SYS_WCSSTR = 0x11B + SYS___RPMTCH = 0x11A + SYS_WCSTOD = 0x12E + SYS_WCSTOK = 0x12C + SYS_WCSTOL = 0x12D + SYS_WCSTOUL = 0x12F + SYS_FGETWC = 0x13C + SYS_FGETWS = 0x13D + SYS_FPUTWC = 0x13E + SYS_FPUTWS = 0x13F + SYS_REGERROR = 0x13B + SYS_REGFREE = 0x13A + SYS_COLLEQUIV = 0x14F + SYS_COLLTOSTR = 0x14E + SYS_ISMCCOLLEL = 0x14C + SYS_STRTOCOLL = 0x14D + SYS_DLLFREE = 0x16F + SYS_DLLQUERYFN = 0x16D + SYS_DLLQUERYVAR = 0x16E + SYS_GETMCCOLL = 0x16A + SYS_GETWMCCOLL = 0x16B + SYS___ERR2AD = 0x16C + SYS_CFSETOSPEED = 0x17A + SYS_CHDIR = 0x17B + SYS_CHMOD = 0x17C + SYS_CHOWN = 0x17D + SYS_CLOSE = 0x17E + SYS_CLOSEDIR = 0x17F + SYS_LOG = 0x017 + SYS_COSH = 0x018 + SYS_FCHMOD = 0x18A + SYS_FCHOWN = 0x18B + SYS_FCNTL = 0x18C + SYS_FILENO = 0x18D + SYS_FORK = 0x18E + SYS_FPATHCONF = 0x18F + SYS_GETLOGIN = 0x19A + SYS_GETPGRP = 0x19C + SYS_GETPID = 0x19D + SYS_GETPPID = 0x19E + SYS_GETPWNAM = 0x19F + SYS_TANH = 0x019 + SYS_W_GETMNTENT = 0x19B + SYS_POW = 0x020 + SYS_PTHREAD_SELF = 0x20A + SYS_PTHREAD_SETINTR = 0x20B + SYS_PTHREAD_SETINTRTYPE = 0x20C + SYS_PTHREAD_SETSPECIFIC = 0x20D + SYS_PTHREAD_TESTINTR = 0x20E + SYS_PTHREAD_YIELD = 0x20F + SYS_SQRT = 0x021 + SYS_FLOOR = 0x022 + SYS_J1 = 0x023 + SYS_WCSPBRK = 0x23F + SYS_BSEARCH = 0x24C + SYS_FABS = 0x024 + SYS_GETENV = 0x24A + SYS_LDIV = 0x24D + SYS_SYSTEM = 0x24B + SYS_FMOD = 0x025 + SYS___RETHROW = 0x25F + SYS___THROW = 0x25E + SYS_J0 = 0x026 + SYS_PUTENV = 0x26A + SYS___GETENV = 0x26F + SYS_SEMCTL = 0x27A + SYS_SEMGET = 0x27B + SYS_SEMOP = 0x27C + SYS_SHMAT = 0x27D + SYS_SHMCTL = 0x27E + SYS_SHMDT = 0x27F + SYS_YN = 0x027 + SYS_JN = 0x028 + SYS_SIGALTSTACK = 0x28A + SYS_SIGHOLD = 0x28B + SYS_SIGIGNORE = 0x28C + SYS_SIGINTERRUPT = 0x28D + SYS_SIGPAUSE = 0x28E + SYS_SIGRELSE = 0x28F + SYS_GETOPT = 0x29A + SYS_GETSUBOPT = 0x29D + SYS_LCHOWN = 0x29B + SYS_SETPGRP = 0x29E + SYS_TRUNCATE = 0x29C + SYS_Y0 = 0x029 + SYS___GDERR = 0x29F + SYS_ISALPHA = 0x030 + SYS_VFORK = 0x30F + SYS__LONGJMP = 0x30D + SYS__SETJMP = 0x30E + SYS_GLOB = 0x31A + SYS_GLOBFREE = 0x31B + SYS_ISALNUM = 0x031 + SYS_PUTW = 0x31C + SYS_SEEKDIR = 0x31D + SYS_TELLDIR = 0x31E + SYS_TEMPNAM = 0x31F + SYS_GETTIMEOFDAY_R = 0x32E + SYS_ISLOWER = 0x032 + SYS_LGAMMA = 0x32C + SYS_REMAINDER = 0x32A + SYS_SCALB = 0x32B + SYS_SYNC = 0x32F + SYS_TTYSLOT = 0x32D + SYS_ENDPROTOENT = 0x33A + SYS_ENDSERVENT = 0x33B + SYS_GETHOSTBYADDR = 0x33D + SYS_GETHOSTBYADDR_R = 0x33C + SYS_GETHOSTBYNAME = 0x33F + SYS_GETHOSTBYNAME_R = 0x33E + SYS_ISCNTRL = 0x033 + SYS_GETSERVBYNAME = 0x34A + SYS_GETSERVBYPORT = 0x34B + SYS_GETSERVENT = 0x34C + SYS_GETSOCKNAME = 0x34D + SYS_GETSOCKOPT = 0x34E + SYS_INET_ADDR = 0x34F + SYS_ISDIGIT = 0x034 + SYS_ISGRAPH = 0x035 + SYS_SELECT = 0x35B + SYS_SELECTEX = 0x35C + SYS_SEND = 0x35D + SYS_SENDTO = 0x35F + SYS_CHROOT = 0x36A + SYS_ISNAN = 0x36D + SYS_ISUPPER = 0x036 + SYS_ULIMIT = 0x36C + SYS_UTIMES = 0x36E + SYS_W_STATVFS = 0x36B + SYS___H_ERRNO = 0x36F + SYS_GRANTPT = 0x37A + SYS_ISPRINT = 0x037 + SYS_TCGETSID = 0x37C + SYS_UNLOCKPT = 0x37B + SYS___TCGETCP = 0x37D + SYS___TCSETCP = 0x37E + SYS___TCSETTABLES = 0x37F + SYS_ISPUNCT = 0x038 + SYS_NLIST = 0x38C + SYS___IPDBCS = 0x38D + SYS___IPDSPX = 0x38E + SYS___IPMSGC = 0x38F + SYS___STHOSTENT = 0x38B + SYS___STSERVENT = 0x38A + SYS_ISSPACE = 0x039 + SYS_COS = 0x040 + SYS_T_ALLOC = 0x40A + SYS_T_BIND = 0x40B + SYS_T_CLOSE = 0x40C + SYS_T_CONNECT = 0x40D + SYS_T_ERROR = 0x40E + SYS_T_FREE = 0x40F + SYS_TAN = 0x041 + SYS_T_RCVREL = 0x41A + SYS_T_RCVUDATA = 0x41B + SYS_T_RCVUDERR = 0x41C + SYS_T_SND = 0x41D + SYS_T_SNDDIS = 0x41E + SYS_T_SNDREL = 0x41F + SYS_GETPMSG = 0x42A + SYS_ISASTREAM = 0x42B + SYS_PUTMSG = 0x42C + SYS_PUTPMSG = 0x42D + SYS_SINH = 0x042 + SYS___ISPOSIXON = 0x42E + SYS___OPENMVSREL = 0x42F + SYS_ACOS = 0x043 + SYS_ATAN = 0x044 + SYS_ATAN2 = 0x045 + SYS_FTELL = 0x046 + SYS_FGETPOS = 0x047 + SYS_SOCK_DEBUG = 0x47A + SYS_SOCK_DO_TESTSTOR = 0x47D + SYS_TAKESOCKET = 0x47E + SYS___SERVER_INIT = 0x47F + SYS_FSEEK = 0x048 + SYS___IPHOST = 0x48B + SYS___IPNODE = 0x48C + SYS___SERVER_CLASSIFY_CREATE = 0x48D + SYS___SERVER_CLASSIFY_DESTROY = 0x48E + SYS___SERVER_CLASSIFY_RESET = 0x48F + SYS___SMF_RECORD = 0x48A + SYS_FSETPOS = 0x049 + SYS___FNWSA = 0x49B + SYS___SPAWN2 = 0x49D + SYS___SPAWNP2 = 0x49E + SYS_ATOF = 0x050 + SYS_PTHREAD_MUTEXATTR_GETPSHARED = 0x50A + SYS_PTHREAD_MUTEXATTR_SETPSHARED = 0x50B + SYS_PTHREAD_RWLOCK_DESTROY = 0x50C + SYS_PTHREAD_RWLOCK_INIT = 0x50D + SYS_PTHREAD_RWLOCK_RDLOCK = 0x50E + SYS_PTHREAD_RWLOCK_TRYRDLOCK = 0x50F + SYS_ATOI = 0x051 + SYS___FP_CLASS = 0x51D + SYS___FP_CLR_FLAG = 0x51A + SYS___FP_FINITE = 0x51E + SYS___FP_ISNAN = 0x51F + SYS___FP_RAISE_XCP = 0x51C + SYS___FP_READ_FLAG = 0x51B + SYS_RAND = 0x052 + SYS_SIGTIMEDWAIT = 0x52D + SYS_SIGWAITINFO = 0x52E + SYS___CHKBFP = 0x52F + SYS___FPC_RS = 0x52C + SYS___FPC_RW = 0x52A + SYS___FPC_SM = 0x52B + SYS_STRTOD = 0x053 + SYS_STRTOL = 0x054 + SYS_STRTOUL = 0x055 + SYS_MALLOC = 0x056 + SYS_SRAND = 0x057 + SYS_CALLOC = 0x058 + SYS_FREE = 0x059 + SYS___OSENV = 0x59F + SYS___W_PIOCTL = 0x59E + SYS_LONGJMP = 0x060 + SYS___FLOORF_B = 0x60A + SYS___FLOORL_B = 0x60B + SYS___FREXPF_B = 0x60C + SYS___FREXPL_B = 0x60D + SYS___LDEXPF_B = 0x60E + SYS___LDEXPL_B = 0x60F + SYS_SIGNAL = 0x061 + SYS___ATAN2F_B = 0x61A + SYS___ATAN2L_B = 0x61B + SYS___COSHF_B = 0x61C + SYS___COSHL_B = 0x61D + SYS___EXPF_B = 0x61E + SYS___EXPL_B = 0x61F + SYS_TMPNAM = 0x062 + SYS___ABSF_B = 0x62A + SYS___ABSL_B = 0x62C + SYS___ABS_B = 0x62B + SYS___FMODF_B = 0x62D + SYS___FMODL_B = 0x62E + SYS___MODFF_B = 0x62F + SYS_ATANL = 0x63A + SYS_CEILF = 0x63B + SYS_CEILL = 0x63C + SYS_COSF = 0x63D + SYS_COSHF = 0x63F + SYS_COSL = 0x63E + SYS_REMOVE = 0x063 + SYS_POWL = 0x64A + SYS_RENAME = 0x064 + SYS_SINF = 0x64B + SYS_SINHF = 0x64F + SYS_SINL = 0x64C + SYS_SQRTF = 0x64D + SYS_SQRTL = 0x64E + SYS_BTOWC = 0x65F + SYS_FREXPL = 0x65A + SYS_LDEXPF = 0x65B + SYS_LDEXPL = 0x65C + SYS_MODFF = 0x65D + SYS_MODFL = 0x65E + SYS_TMPFILE = 0x065 + SYS_FREOPEN = 0x066 + SYS___CHARMAP_INIT_A = 0x66E + SYS___GETHOSTBYADDR_R_A = 0x66C + SYS___GETHOSTBYNAME_A = 0x66A + SYS___GETHOSTBYNAME_R_A = 0x66D + SYS___MBLEN_A = 0x66F + SYS___RES_INIT_A = 0x66B + SYS_FCLOSE = 0x067 + SYS___GETGRGID_R_A = 0x67D + SYS___WCSTOMBS_A = 0x67A + SYS___WCSTOMBS_STD_A = 0x67B + SYS___WCSWIDTH_A = 0x67C + SYS___WCSWIDTH_ASIA = 0x67F + SYS___WCSWIDTH_STD_A = 0x67E + SYS_FFLUSH = 0x068 + SYS___GETLOGIN_R_A = 0x68E + SYS___GETPWNAM_R_A = 0x68C + SYS___GETPWUID_R_A = 0x68D + SYS___TTYNAME_R_A = 0x68F + SYS___WCWIDTH_ASIA = 0x68B + SYS___WCWIDTH_STD_A = 0x68A + SYS_FOPEN = 0x069 + SYS___REGEXEC_A = 0x69A + SYS___REGEXEC_STD_A = 0x69B + SYS___REGFREE_A = 0x69C + SYS___REGFREE_STD_A = 0x69D + SYS___STRCOLL_A = 0x69E + SYS___STRCOLL_C_A = 0x69F + SYS_SCANF = 0x070 + SYS___A64L_A = 0x70C + SYS___ECVT_A = 0x70D + SYS___FCVT_A = 0x70E + SYS___GCVT_A = 0x70F + SYS___STRTOUL_A = 0x70A + SYS_____AE_CORRESTBL_QUERY_A = 0x70B + SYS_SPRINTF = 0x071 + SYS___ACCESS_A = 0x71F + SYS___CATOPEN_A = 0x71E + SYS___GETOPT_A = 0x71D + SYS___REALPATH_A = 0x71A + SYS___SETENV_A = 0x71B + SYS___SYSTEM_A = 0x71C + SYS_FGETC = 0x072 + SYS___GAI_STRERROR_A = 0x72F + SYS___RMDIR_A = 0x72A + SYS___STATVFS_A = 0x72B + SYS___SYMLINK_A = 0x72C + SYS___TRUNCATE_A = 0x72D + SYS___UNLINK_A = 0x72E + SYS_VFPRINTF = 0x073 + SYS___ISSPACE_A = 0x73A + SYS___ISUPPER_A = 0x73B + SYS___ISWALNUM_A = 0x73F + SYS___ISXDIGIT_A = 0x73C + SYS___TOLOWER_A = 0x73D + SYS___TOUPPER_A = 0x73E + SYS_VPRINTF = 0x074 + SYS___CONFSTR_A = 0x74B + SYS___FDOPEN_A = 0x74E + SYS___FLDATA_A = 0x74F + SYS___FTOK_A = 0x74C + SYS___ISWXDIGIT_A = 0x74A + SYS___MKTEMP_A = 0x74D + SYS_VSPRINTF = 0x075 + SYS___GETGRGID_A = 0x75A + SYS___GETGRNAM_A = 0x75B + SYS___GETGROUPSBYNAME_A = 0x75C + SYS___GETHOSTENT_A = 0x75D + SYS___GETHOSTNAME_A = 0x75E + SYS___GETLOGIN_A = 0x75F + SYS_GETC = 0x076 + SYS___CREATEWORKUNIT_A = 0x76A + SYS___CTERMID_A = 0x76B + SYS___FMTMSG_A = 0x76C + SYS___INITGROUPS_A = 0x76D + SYS___MSGRCV_A = 0x76F + SYS_____LOGIN_A = 0x76E + SYS_FGETS = 0x077 + SYS___STRCASECMP_A = 0x77B + SYS___STRNCASECMP_A = 0x77C + SYS___TTYNAME_A = 0x77D + SYS___UNAME_A = 0x77E + SYS___UTIMES_A = 0x77F + SYS_____SERVER_PWU_A = 0x77A + SYS_FPUTC = 0x078 + SYS___CREAT_O_A = 0x78E + SYS___ENVNA = 0x78F + SYS___FREAD_A = 0x78A + SYS___FWRITE_A = 0x78B + SYS___ISASCII = 0x78D + SYS___OPEN_O_A = 0x78C + SYS_FPUTS = 0x079 + SYS___ASCTIME_A = 0x79C + SYS___CTIME_A = 0x79D + SYS___GETDATE_A = 0x79E + SYS___GETSERVBYPORT_A = 0x79A + SYS___GETSERVENT_A = 0x79B + SYS___TZSET_A = 0x79F + SYS_ACL_FROM_TEXT = 0x80C + SYS_ACL_SET_FD = 0x80A + SYS_ACL_SET_FILE = 0x80B + SYS_ACL_SORT = 0x80E + SYS_ACL_TO_TEXT = 0x80D + SYS_UNGETC = 0x080 + SYS___SHUTDOWN_REGISTRATION = 0x80F + SYS_FREAD = 0x081 + SYS_FREEADDRINFO = 0x81A + SYS_GAI_STRERROR = 0x81B + SYS_REXEC_AF = 0x81C + SYS___DYNALLOC_A = 0x81F + SYS___POE = 0x81D + SYS_WCSTOMBS = 0x082 + SYS___INET_ADDR_A = 0x82F + SYS___NLIST_A = 0x82A + SYS_____TCGETCP_A = 0x82B + SYS_____TCSETCP_A = 0x82C + SYS_____W_PIOCTL_A = 0x82E + SYS_MBTOWC = 0x083 + SYS___CABEND = 0x83D + SYS___LE_CIB_GET = 0x83E + SYS___RECVMSG_A = 0x83B + SYS___SENDMSG_A = 0x83A + SYS___SET_LAA_FOR_JIT = 0x83F + SYS_____LCHATTR_A = 0x83C + SYS_WCTOMB = 0x084 + SYS___CBRTL_B = 0x84A + SYS___COPYSIGNF_B = 0x84B + SYS___COPYSIGNL_B = 0x84C + SYS___COTANF_B = 0x84D + SYS___COTANL_B = 0x84F + SYS___COTAN_B = 0x84E + SYS_MBSTOWCS = 0x085 + SYS___LOG1PL_B = 0x85A + SYS___LOG2F_B = 0x85B + SYS___LOG2L_B = 0x85D + SYS___LOG2_B = 0x85C + SYS___REMAINDERF_B = 0x85E + SYS___REMAINDERL_B = 0x85F + SYS_ACOSHF = 0x86E + SYS_ACOSHL = 0x86F + SYS_WCSCPY = 0x086 + SYS___ERFCF_B = 0x86D + SYS___ERFF_B = 0x86C + SYS___LROUNDF_B = 0x86A + SYS___LROUND_B = 0x86B + SYS_COTANL = 0x87A + SYS_EXP2F = 0x87B + SYS_EXP2L = 0x87C + SYS_EXPM1F = 0x87D + SYS_EXPM1L = 0x87E + SYS_FDIMF = 0x87F + SYS_WCSCAT = 0x087 + SYS___COTANL = 0x87A + SYS_REMAINDERF = 0x88A + SYS_REMAINDERL = 0x88B + SYS_REMAINDF = 0x88A + SYS_REMAINDL = 0x88B + SYS_REMQUO = 0x88D + SYS_REMQUOF = 0x88C + SYS_REMQUOL = 0x88E + SYS_TGAMMAF = 0x88F + SYS_WCSCHR = 0x088 + SYS_ERFCF = 0x89B + SYS_ERFCL = 0x89C + SYS_ERFL = 0x89A + SYS_EXP2 = 0x89E + SYS_WCSCMP = 0x089 + SYS___EXP2_B = 0x89D + SYS___FAR_JUMP = 0x89F + SYS_ABS = 0x090 + SYS___ERFCL_H = 0x90A + SYS___EXPF_H = 0x90C + SYS___EXPL_H = 0x90D + SYS___EXPM1_H = 0x90E + SYS___EXP_H = 0x90B + SYS___FDIM_H = 0x90F + SYS_DIV = 0x091 + SYS___LOG2F_H = 0x91F + SYS___LOG2_H = 0x91E + SYS___LOGB_H = 0x91D + SYS___LOGF_H = 0x91B + SYS___LOGL_H = 0x91C + SYS___LOG_H = 0x91A + SYS_LABS = 0x092 + SYS___POWL_H = 0x92A + SYS___REMAINDER_H = 0x92B + SYS___RINT_H = 0x92C + SYS___SCALB_H = 0x92D + SYS___SINF_H = 0x92F + SYS___SIN_H = 0x92E + SYS_STRNCPY = 0x093 + SYS___TANHF_H = 0x93B + SYS___TANHL_H = 0x93C + SYS___TANH_H = 0x93A + SYS___TGAMMAF_H = 0x93E + SYS___TGAMMA_H = 0x93D + SYS___TRUNC_H = 0x93F + SYS_MEMCPY = 0x094 + SYS_VFWSCANF = 0x94A + SYS_VSWSCANF = 0x94E + SYS_VWSCANF = 0x94C + SYS_INET6_RTH_ADD = 0x95D + SYS_INET6_RTH_INIT = 0x95C + SYS_INET6_RTH_REVERSE = 0x95E + SYS_INET6_RTH_SEGMENTS = 0x95F + SYS_INET6_RTH_SPACE = 0x95B + SYS_MEMMOVE = 0x095 + SYS_WCSTOLD = 0x95A + SYS_STRCPY = 0x096 + SYS_STRCMP = 0x097 + SYS_CABS = 0x98E + SYS_STRCAT = 0x098 + SYS___CABS_B = 0x98F + SYS___POW_II = 0x98A + SYS___POW_II_B = 0x98B + SYS___POW_II_H = 0x98C + SYS_CACOSF = 0x99A + SYS_CACOSL = 0x99D + SYS_STRNCAT = 0x099 + SYS___CACOSF_B = 0x99B + SYS___CACOSF_H = 0x99C + SYS___CACOSL_B = 0x99E + SYS___CACOSL_H = 0x99F + SYS_ISWALPHA = 0x100 + SYS_ISWBLANK = 0x101 + SYS___ISWBLK = 0x101 + SYS_ISWCNTRL = 0x102 + SYS_ISWDIGIT = 0x103 + SYS_ISWGRAPH = 0x104 + SYS_ISWLOWER = 0x105 + SYS_ISWPRINT = 0x106 + SYS_ISWPUNCT = 0x107 + SYS_ISWSPACE = 0x108 + SYS_ISWUPPER = 0x109 + SYS_WCTOB = 0x110 + SYS_MBRLEN = 0x111 + SYS_MBRTOWC = 0x112 + SYS_MBSRTOWC = 0x113 + SYS_MBSRTOWCS = 0x113 + SYS_WCRTOMB = 0x114 + SYS_WCSRTOMB = 0x115 + SYS_WCSRTOMBS = 0x115 + SYS___CSID = 0x116 + SYS___WCSID = 0x117 + SYS_STRPTIME = 0x118 + SYS___STRPTM = 0x118 + SYS_STRFMON = 0x119 + SYS_WCSCOLL = 0x130 + SYS_WCSXFRM = 0x131 + SYS_WCSWIDTH = 0x132 + SYS_WCWIDTH = 0x133 + SYS_WCSFTIME = 0x134 + SYS_SWPRINTF = 0x135 + SYS_VSWPRINT = 0x136 + SYS_VSWPRINTF = 0x136 + SYS_SWSCANF = 0x137 + SYS_REGCOMP = 0x138 + SYS_REGEXEC = 0x139 + SYS_GETWC = 0x140 + SYS_GETWCHAR = 0x141 + SYS_PUTWC = 0x142 + SYS_PUTWCHAR = 0x143 + SYS_UNGETWC = 0x144 + SYS_ICONV_OPEN = 0x145 + SYS_ICONV = 0x146 + SYS_ICONV_CLOSE = 0x147 + SYS_COLLRANGE = 0x150 + SYS_CCLASS = 0x151 + SYS_COLLORDER = 0x152 + SYS___DEMANGLE = 0x154 + SYS_FDOPEN = 0x155 + SYS___ERRNO = 0x156 + SYS___ERRNO2 = 0x157 + SYS___TERROR = 0x158 + SYS_MAXCOLL = 0x169 + SYS_DLLLOAD = 0x170 + SYS__EXIT = 0x174 + SYS_ACCESS = 0x175 + SYS_ALARM = 0x176 + SYS_CFGETISPEED = 0x177 + SYS_CFGETOSPEED = 0x178 + SYS_CFSETISPEED = 0x179 + SYS_CREAT = 0x180 + SYS_CTERMID = 0x181 + SYS_DUP = 0x182 + SYS_DUP2 = 0x183 + SYS_EXECL = 0x184 + SYS_EXECLE = 0x185 + SYS_EXECLP = 0x186 + SYS_EXECV = 0x187 + SYS_EXECVE = 0x188 + SYS_EXECVP = 0x189 + SYS_FSTAT = 0x190 + SYS_FSYNC = 0x191 + SYS_FTRUNCATE = 0x192 + SYS_GETCWD = 0x193 + SYS_GETEGID = 0x194 + SYS_GETEUID = 0x195 + SYS_GETGID = 0x196 + SYS_GETGRGID = 0x197 + SYS_GETGRNAM = 0x198 + SYS_GETGROUPS = 0x199 + SYS_PTHREAD_MUTEXATTR_DESTROY = 0x200 + SYS_PTHREAD_MUTEXATTR_SETKIND_NP = 0x201 + SYS_PTHREAD_MUTEXATTR_GETKIND_NP = 0x202 + SYS_PTHREAD_MUTEX_INIT = 0x203 + SYS_PTHREAD_MUTEX_DESTROY = 0x204 + SYS_PTHREAD_MUTEX_LOCK = 0x205 + SYS_PTHREAD_MUTEX_TRYLOCK = 0x206 + SYS_PTHREAD_MUTEX_UNLOCK = 0x207 + SYS_PTHREAD_ONCE = 0x209 + SYS_TW_OPEN = 0x210 + SYS_TW_FCNTL = 0x211 + SYS_PTHREAD_JOIN_D4_NP = 0x212 + SYS_PTHREAD_CONDATTR_SETKIND_NP = 0x213 + SYS_PTHREAD_CONDATTR_GETKIND_NP = 0x214 + SYS_EXTLINK_NP = 0x215 + SYS___PASSWD = 0x216 + SYS_SETGROUPS = 0x217 + SYS_INITGROUPS = 0x218 + SYS_WCSRCHR = 0x240 + SYS_SVC99 = 0x241 + SYS___SVC99 = 0x241 + SYS_WCSWCS = 0x242 + SYS_LOCALECO = 0x243 + SYS_LOCALECONV = 0x243 + SYS___LIBREL = 0x244 + SYS_RELEASE = 0x245 + SYS___RLSE = 0x245 + SYS_FLOCATE = 0x246 + SYS___FLOCT = 0x246 + SYS_FDELREC = 0x247 + SYS___FDLREC = 0x247 + SYS_FETCH = 0x248 + SYS___FETCH = 0x248 + SYS_QSORT = 0x249 + SYS___CLEANUPCATCH = 0x260 + SYS___CATCHMATCH = 0x261 + SYS___CLEAN2UPCATCH = 0x262 + SYS_GETPRIORITY = 0x270 + SYS_NICE = 0x271 + SYS_SETPRIORITY = 0x272 + SYS_GETITIMER = 0x273 + SYS_SETITIMER = 0x274 + SYS_MSGCTL = 0x275 + SYS_MSGGET = 0x276 + SYS_MSGRCV = 0x277 + SYS_MSGSND = 0x278 + SYS_MSGXRCV = 0x279 + SYS___MSGXR = 0x279 + SYS_SHMGET = 0x280 + SYS___GETIPC = 0x281 + SYS_SETGRENT = 0x282 + SYS_GETGRENT = 0x283 + SYS_ENDGRENT = 0x284 + SYS_SETPWENT = 0x285 + SYS_GETPWENT = 0x286 + SYS_ENDPWENT = 0x287 + SYS_BSD_SIGNAL = 0x288 + SYS_KILLPG = 0x289 + SYS_SIGSET = 0x290 + SYS_SIGSTACK = 0x291 + SYS_GETRLIMIT = 0x292 + SYS_SETRLIMIT = 0x293 + SYS_GETRUSAGE = 0x294 + SYS_MMAP = 0x295 + SYS_MPROTECT = 0x296 + SYS_MSYNC = 0x297 + SYS_MUNMAP = 0x298 + SYS_CONFSTR = 0x299 + SYS___NDMTRM = 0x300 + SYS_FTOK = 0x301 + SYS_BASENAME = 0x302 + SYS_DIRNAME = 0x303 + SYS_GETDTABLESIZE = 0x304 + SYS_MKSTEMP = 0x305 + SYS_MKTEMP = 0x306 + SYS_NFTW = 0x307 + SYS_GETWD = 0x308 + SYS_LOCKF = 0x309 + SYS_WORDEXP = 0x310 + SYS_WORDFREE = 0x311 + SYS_GETPGID = 0x312 + SYS_GETSID = 0x313 + SYS___UTMPXNAME = 0x314 + SYS_CUSERID = 0x315 + SYS_GETPASS = 0x316 + SYS_FNMATCH = 0x317 + SYS_FTW = 0x318 + SYS_GETW = 0x319 + SYS_ACOSH = 0x320 + SYS_ASINH = 0x321 + SYS_ATANH = 0x322 + SYS_CBRT = 0x323 + SYS_EXPM1 = 0x324 + SYS_ILOGB = 0x325 + SYS_LOGB = 0x326 + SYS_LOG1P = 0x327 + SYS_NEXTAFTER = 0x328 + SYS_RINT = 0x329 + SYS_SPAWN = 0x330 + SYS_SPAWNP = 0x331 + SYS_GETLOGIN_UU = 0x332 + SYS_ECVT = 0x333 + SYS_FCVT = 0x334 + SYS_GCVT = 0x335 + SYS_ACCEPT = 0x336 + SYS_BIND = 0x337 + SYS_CONNECT = 0x338 + SYS_ENDHOSTENT = 0x339 + SYS_GETHOSTENT = 0x340 + SYS_GETHOSTID = 0x341 + SYS_GETHOSTNAME = 0x342 + SYS_GETNETBYADDR = 0x343 + SYS_GETNETBYNAME = 0x344 + SYS_GETNETENT = 0x345 + SYS_GETPEERNAME = 0x346 + SYS_GETPROTOBYNAME = 0x347 + SYS_GETPROTOBYNUMBER = 0x348 + SYS_GETPROTOENT = 0x349 + SYS_INET_LNAOF = 0x350 + SYS_INET_MAKEADDR = 0x351 + SYS_INET_NETOF = 0x352 + SYS_INET_NETWORK = 0x353 + SYS_INET_NTOA = 0x354 + SYS_IOCTL = 0x355 + SYS_LISTEN = 0x356 + SYS_READV = 0x357 + SYS_RECV = 0x358 + SYS_RECVFROM = 0x359 + SYS_SETHOSTENT = 0x360 + SYS_SETNETENT = 0x361 + SYS_SETPEER = 0x362 + SYS_SETPROTOENT = 0x363 + SYS_SETSERVENT = 0x364 + SYS_SETSOCKOPT = 0x365 + SYS_SHUTDOWN = 0x366 + SYS_SOCKET = 0x367 + SYS_SOCKETPAIR = 0x368 + SYS_WRITEV = 0x369 + SYS_ENDNETENT = 0x370 + SYS_CLOSELOG = 0x371 + SYS_OPENLOG = 0x372 + SYS_SETLOGMASK = 0x373 + SYS_SYSLOG = 0x374 + SYS_PTSNAME = 0x375 + SYS_SETREUID = 0x376 + SYS_SETREGID = 0x377 + SYS_REALPATH = 0x378 + SYS___SIGNGAM = 0x379 + SYS_POLL = 0x380 + SYS_REXEC = 0x381 + SYS___ISASCII2 = 0x382 + SYS___TOASCII2 = 0x383 + SYS_CHPRIORITY = 0x384 + SYS_PTHREAD_ATTR_SETSYNCTYPE_NP = 0x385 + SYS_PTHREAD_ATTR_GETSYNCTYPE_NP = 0x386 + SYS_PTHREAD_SET_LIMIT_NP = 0x387 + SYS___STNETENT = 0x388 + SYS___STPROTOENT = 0x389 + SYS___SELECT1 = 0x390 + SYS_PTHREAD_SECURITY_NP = 0x391 + SYS___CHECK_RESOURCE_AUTH_NP = 0x392 + SYS___CONVERT_ID_NP = 0x393 + SYS___OPENVMREL = 0x394 + SYS_WMEMCHR = 0x395 + SYS_WMEMCMP = 0x396 + SYS_WMEMCPY = 0x397 + SYS_WMEMMOVE = 0x398 + SYS_WMEMSET = 0x399 + SYS___FPUTWC = 0x400 + SYS___PUTWC = 0x401 + SYS___PWCHAR = 0x402 + SYS___WCSFTM = 0x403 + SYS___WCSTOK = 0x404 + SYS___WCWDTH = 0x405 + SYS_T_ACCEPT = 0x409 + SYS_T_GETINFO = 0x410 + SYS_T_GETPROTADDR = 0x411 + SYS_T_GETSTATE = 0x412 + SYS_T_LISTEN = 0x413 + SYS_T_LOOK = 0x414 + SYS_T_OPEN = 0x415 + SYS_T_OPTMGMT = 0x416 + SYS_T_RCV = 0x417 + SYS_T_RCVCONNECT = 0x418 + SYS_T_RCVDIS = 0x419 + SYS_T_SNDUDATA = 0x420 + SYS_T_STRERROR = 0x421 + SYS_T_SYNC = 0x422 + SYS_T_UNBIND = 0x423 + SYS___T_ERRNO = 0x424 + SYS___RECVMSG2 = 0x425 + SYS___SENDMSG2 = 0x426 + SYS_FATTACH = 0x427 + SYS_FDETACH = 0x428 + SYS_GETMSG = 0x429 + SYS_GETCONTEXT = 0x430 + SYS_SETCONTEXT = 0x431 + SYS_MAKECONTEXT = 0x432 + SYS_SWAPCONTEXT = 0x433 + SYS_PTHREAD_GETSPECIFIC_D8_NP = 0x434 + SYS_GETCLIENTID = 0x470 + SYS___GETCLIENTID = 0x471 + SYS_GETSTABLESIZE = 0x472 + SYS_GETIBMOPT = 0x473 + SYS_GETIBMSOCKOPT = 0x474 + SYS_GIVESOCKET = 0x475 + SYS_IBMSFLUSH = 0x476 + SYS_MAXDESC = 0x477 + SYS_SETIBMOPT = 0x478 + SYS_SETIBMSOCKOPT = 0x479 + SYS___SERVER_PWU = 0x480 + SYS_PTHREAD_TAG_NP = 0x481 + SYS___CONSOLE = 0x482 + SYS___WSINIT = 0x483 + SYS___IPTCPN = 0x489 + SYS___SERVER_CLASSIFY = 0x490 + SYS___HEAPRPT = 0x496 + SYS___ISBFP = 0x500 + SYS___FP_CAST = 0x501 + SYS___CERTIFICATE = 0x502 + SYS_SEND_FILE = 0x503 + SYS_AIO_CANCEL = 0x504 + SYS_AIO_ERROR = 0x505 + SYS_AIO_READ = 0x506 + SYS_AIO_RETURN = 0x507 + SYS_AIO_SUSPEND = 0x508 + SYS_AIO_WRITE = 0x509 + SYS_PTHREAD_RWLOCK_TRYWRLOCK = 0x510 + SYS_PTHREAD_RWLOCK_UNLOCK = 0x511 + SYS_PTHREAD_RWLOCK_WRLOCK = 0x512 + SYS_PTHREAD_RWLOCKATTR_GETPSHARED = 0x513 + SYS_PTHREAD_RWLOCKATTR_SETPSHARED = 0x514 + SYS_PTHREAD_RWLOCKATTR_INIT = 0x515 + SYS_PTHREAD_RWLOCKATTR_DESTROY = 0x516 + SYS___CTTBL = 0x517 + SYS_PTHREAD_MUTEXATTR_SETTYPE = 0x518 + SYS_PTHREAD_MUTEXATTR_GETTYPE = 0x519 + SYS___FP_UNORDERED = 0x520 + SYS___FP_READ_RND = 0x521 + SYS___FP_READ_RND_B = 0x522 + SYS___FP_SWAP_RND = 0x523 + SYS___FP_SWAP_RND_B = 0x524 + SYS___FP_LEVEL = 0x525 + SYS___FP_BTOH = 0x526 + SYS___FP_HTOB = 0x527 + SYS___FPC_RD = 0x528 + SYS___FPC_WR = 0x529 + SYS_PTHREAD_SETCANCELTYPE = 0x600 + SYS_PTHREAD_TESTCANCEL = 0x601 + SYS___ATANF_B = 0x602 + SYS___ATANL_B = 0x603 + SYS___CEILF_B = 0x604 + SYS___CEILL_B = 0x605 + SYS___COSF_B = 0x606 + SYS___COSL_B = 0x607 + SYS___FABSF_B = 0x608 + SYS___FABSL_B = 0x609 + SYS___SINF_B = 0x610 + SYS___SINL_B = 0x611 + SYS___TANF_B = 0x612 + SYS___TANL_B = 0x613 + SYS___TANHF_B = 0x614 + SYS___TANHL_B = 0x615 + SYS___ACOSF_B = 0x616 + SYS___ACOSL_B = 0x617 + SYS___ASINF_B = 0x618 + SYS___ASINL_B = 0x619 + SYS___LOGF_B = 0x620 + SYS___LOGL_B = 0x621 + SYS___LOG10F_B = 0x622 + SYS___LOG10L_B = 0x623 + SYS___POWF_B = 0x624 + SYS___POWL_B = 0x625 + SYS___SINHF_B = 0x626 + SYS___SINHL_B = 0x627 + SYS___SQRTF_B = 0x628 + SYS___SQRTL_B = 0x629 + SYS___MODFL_B = 0x630 + SYS_ABSF = 0x631 + SYS_ABSL = 0x632 + SYS_ACOSF = 0x633 + SYS_ACOSL = 0x634 + SYS_ASINF = 0x635 + SYS_ASINL = 0x636 + SYS_ATAN2F = 0x637 + SYS_ATAN2L = 0x638 + SYS_ATANF = 0x639 + SYS_COSHL = 0x640 + SYS_EXPF = 0x641 + SYS_EXPL = 0x642 + SYS_TANHF = 0x643 + SYS_TANHL = 0x644 + SYS_LOG10F = 0x645 + SYS_LOG10L = 0x646 + SYS_LOGF = 0x647 + SYS_LOGL = 0x648 + SYS_POWF = 0x649 + SYS_SINHL = 0x650 + SYS_TANF = 0x651 + SYS_TANL = 0x652 + SYS_FABSF = 0x653 + SYS_FABSL = 0x654 + SYS_FLOORF = 0x655 + SYS_FLOORL = 0x656 + SYS_FMODF = 0x657 + SYS_FMODL = 0x658 + SYS_FREXPF = 0x659 + SYS___CHATTR = 0x660 + SYS___FCHATTR = 0x661 + SYS___TOCCSID = 0x662 + SYS___CSNAMETYPE = 0x663 + SYS___TOCSNAME = 0x664 + SYS___CCSIDTYPE = 0x665 + SYS___AE_CORRESTBL_QUERY = 0x666 + SYS___AE_AUTOCONVERT_STATE = 0x667 + SYS_DN_FIND = 0x668 + SYS___GETHOSTBYADDR_A = 0x669 + SYS___MBLEN_SB_A = 0x670 + SYS___MBLEN_STD_A = 0x671 + SYS___MBLEN_UTF = 0x672 + SYS___MBSTOWCS_A = 0x673 + SYS___MBSTOWCS_STD_A = 0x674 + SYS___MBTOWC_A = 0x675 + SYS___MBTOWC_ISO1 = 0x676 + SYS___MBTOWC_SBCS = 0x677 + SYS___MBTOWC_MBCS = 0x678 + SYS___MBTOWC_UTF = 0x679 + SYS___CSID_A = 0x680 + SYS___CSID_STD_A = 0x681 + SYS___WCSID_A = 0x682 + SYS___WCSID_STD_A = 0x683 + SYS___WCTOMB_A = 0x684 + SYS___WCTOMB_ISO1 = 0x685 + SYS___WCTOMB_STD_A = 0x686 + SYS___WCTOMB_UTF = 0x687 + SYS___WCWIDTH_A = 0x688 + SYS___GETGRNAM_R_A = 0x689 + SYS___READDIR_R_A = 0x690 + SYS___E2A_S = 0x691 + SYS___FNMATCH_A = 0x692 + SYS___FNMATCH_C_A = 0x693 + SYS___EXECL_A = 0x694 + SYS___FNMATCH_STD_A = 0x695 + SYS___REGCOMP_A = 0x696 + SYS___REGCOMP_STD_A = 0x697 + SYS___REGERROR_A = 0x698 + SYS___REGERROR_STD_A = 0x699 + SYS___SWPRINTF_A = 0x700 + SYS___FSCANF_A = 0x701 + SYS___SCANF_A = 0x702 + SYS___SSCANF_A = 0x703 + SYS___SWSCANF_A = 0x704 + SYS___ATOF_A = 0x705 + SYS___ATOI_A = 0x706 + SYS___ATOL_A = 0x707 + SYS___STRTOD_A = 0x708 + SYS___STRTOL_A = 0x709 + SYS___L64A_A = 0x710 + SYS___STRERROR_A = 0x711 + SYS___PERROR_A = 0x712 + SYS___FETCH_A = 0x713 + SYS___GETENV_A = 0x714 + SYS___MKSTEMP_A = 0x717 + SYS___PTSNAME_A = 0x718 + SYS___PUTENV_A = 0x719 + SYS___CHDIR_A = 0x720 + SYS___CHOWN_A = 0x721 + SYS___CHROOT_A = 0x722 + SYS___GETCWD_A = 0x723 + SYS___GETWD_A = 0x724 + SYS___LCHOWN_A = 0x725 + SYS___LINK_A = 0x726 + SYS___PATHCONF_A = 0x727 + SYS___IF_NAMEINDEX_A = 0x728 + SYS___READLINK_A = 0x729 + SYS___EXTLINK_NP_A = 0x730 + SYS___ISALNUM_A = 0x731 + SYS___ISALPHA_A = 0x732 + SYS___A2E_S = 0x733 + SYS___ISCNTRL_A = 0x734 + SYS___ISDIGIT_A = 0x735 + SYS___ISGRAPH_A = 0x736 + SYS___ISLOWER_A = 0x737 + SYS___ISPRINT_A = 0x738 + SYS___ISPUNCT_A = 0x739 + SYS___ISWALPHA_A = 0x740 + SYS___A2E_L = 0x741 + SYS___ISWCNTRL_A = 0x742 + SYS___ISWDIGIT_A = 0x743 + SYS___ISWGRAPH_A = 0x744 + SYS___ISWLOWER_A = 0x745 + SYS___ISWPRINT_A = 0x746 + SYS___ISWPUNCT_A = 0x747 + SYS___ISWSPACE_A = 0x748 + SYS___ISWUPPER_A = 0x749 + SYS___REMOVE_A = 0x750 + SYS___RENAME_A = 0x751 + SYS___TMPNAM_A = 0x752 + SYS___FOPEN_A = 0x753 + SYS___FREOPEN_A = 0x754 + SYS___CUSERID_A = 0x755 + SYS___POPEN_A = 0x756 + SYS___TEMPNAM_A = 0x757 + SYS___FTW_A = 0x758 + SYS___GETGRENT_A = 0x759 + SYS___INET_NTOP_A = 0x760 + SYS___GETPASS_A = 0x761 + SYS___GETPWENT_A = 0x762 + SYS___GETPWNAM_A = 0x763 + SYS___GETPWUID_A = 0x764 + SYS_____CHECK_RESOURCE_AUTH_NP_A = 0x765 + SYS___CHECKSCHENV_A = 0x766 + SYS___CONNECTSERVER_A = 0x767 + SYS___CONNECTWORKMGR_A = 0x768 + SYS_____CONSOLE_A = 0x769 + SYS___MSGSND_A = 0x770 + SYS___MSGXRCV_A = 0x771 + SYS___NFTW_A = 0x772 + SYS_____PASSWD_A = 0x773 + SYS___PTHREAD_SECURITY_NP_A = 0x774 + SYS___QUERYMETRICS_A = 0x775 + SYS___QUERYSCHENV = 0x776 + SYS___READV_A = 0x777 + SYS_____SERVER_CLASSIFY_A = 0x778 + SYS_____SERVER_INIT_A = 0x779 + SYS___W_GETPSENT_A = 0x780 + SYS___WRITEV_A = 0x781 + SYS___W_STATFS_A = 0x782 + SYS___W_STATVFS_A = 0x783 + SYS___FPUTC_A = 0x784 + SYS___PUTCHAR_A = 0x785 + SYS___PUTS_A = 0x786 + SYS___FGETS_A = 0x787 + SYS___GETS_A = 0x788 + SYS___FPUTS_A = 0x789 + SYS___PUTC_A = 0x790 + SYS___AE_THREAD_SETMODE = 0x791 + SYS___AE_THREAD_SWAPMODE = 0x792 + SYS___GETNETBYADDR_A = 0x793 + SYS___GETNETBYNAME_A = 0x794 + SYS___GETNETENT_A = 0x795 + SYS___GETPROTOBYNAME_A = 0x796 + SYS___GETPROTOBYNUMBER_A = 0x797 + SYS___GETPROTOENT_A = 0x798 + SYS___GETSERVBYNAME_A = 0x799 + SYS_ACL_FIRST_ENTRY = 0x800 + SYS_ACL_GET_ENTRY = 0x801 + SYS_ACL_VALID = 0x802 + SYS_ACL_CREATE_ENTRY = 0x803 + SYS_ACL_DELETE_ENTRY = 0x804 + SYS_ACL_UPDATE_ENTRY = 0x805 + SYS_ACL_DELETE_FD = 0x806 + SYS_ACL_DELETE_FILE = 0x807 + SYS_ACL_GET_FD = 0x808 + SYS_ACL_GET_FILE = 0x809 + SYS___ERFL_B = 0x810 + SYS___ERFCL_B = 0x811 + SYS___LGAMMAL_B = 0x812 + SYS___SETHOOKEVENTS = 0x813 + SYS_IF_NAMETOINDEX = 0x814 + SYS_IF_INDEXTONAME = 0x815 + SYS_IF_NAMEINDEX = 0x816 + SYS_IF_FREENAMEINDEX = 0x817 + SYS_GETADDRINFO = 0x818 + SYS_GETNAMEINFO = 0x819 + SYS___DYNFREE_A = 0x820 + SYS___RES_QUERY_A = 0x821 + SYS___RES_SEARCH_A = 0x822 + SYS___RES_QUERYDOMAIN_A = 0x823 + SYS___RES_MKQUERY_A = 0x824 + SYS___RES_SEND_A = 0x825 + SYS___DN_EXPAND_A = 0x826 + SYS___DN_SKIPNAME_A = 0x827 + SYS___DN_COMP_A = 0x828 + SYS___DN_FIND_A = 0x829 + SYS___INET_NTOA_A = 0x830 + SYS___INET_NETWORK_A = 0x831 + SYS___ACCEPT_A = 0x832 + SYS___ACCEPT_AND_RECV_A = 0x833 + SYS___BIND_A = 0x834 + SYS___CONNECT_A = 0x835 + SYS___GETPEERNAME_A = 0x836 + SYS___GETSOCKNAME_A = 0x837 + SYS___RECVFROM_A = 0x838 + SYS___SENDTO_A = 0x839 + SYS___LCHATTR = 0x840 + SYS___WRITEDOWN = 0x841 + SYS_PTHREAD_MUTEX_INIT2 = 0x842 + SYS___ACOSHF_B = 0x843 + SYS___ACOSHL_B = 0x844 + SYS___ASINHF_B = 0x845 + SYS___ASINHL_B = 0x846 + SYS___ATANHF_B = 0x847 + SYS___ATANHL_B = 0x848 + SYS___CBRTF_B = 0x849 + SYS___EXP2F_B = 0x850 + SYS___EXP2L_B = 0x851 + SYS___EXPM1F_B = 0x852 + SYS___EXPM1L_B = 0x853 + SYS___FDIMF_B = 0x854 + SYS___FDIM_B = 0x855 + SYS___FDIML_B = 0x856 + SYS___HYPOTF_B = 0x857 + SYS___HYPOTL_B = 0x858 + SYS___LOG1PF_B = 0x859 + SYS___REMQUOF_B = 0x860 + SYS___REMQUO_B = 0x861 + SYS___REMQUOL_B = 0x862 + SYS___TGAMMAF_B = 0x863 + SYS___TGAMMA_B = 0x864 + SYS___TGAMMAL_B = 0x865 + SYS___TRUNCF_B = 0x866 + SYS___TRUNC_B = 0x867 + SYS___TRUNCL_B = 0x868 + SYS___LGAMMAF_B = 0x869 + SYS_ASINHF = 0x870 + SYS_ASINHL = 0x871 + SYS_ATANHF = 0x872 + SYS_ATANHL = 0x873 + SYS_CBRTF = 0x874 + SYS_CBRTL = 0x875 + SYS_COPYSIGNF = 0x876 + SYS_CPYSIGNF = 0x876 + SYS_COPYSIGNL = 0x877 + SYS_CPYSIGNL = 0x877 + SYS_COTANF = 0x878 + SYS___COTANF = 0x878 + SYS_COTAN = 0x879 + SYS___COTAN = 0x879 + SYS_FDIM = 0x881 + SYS_FDIML = 0x882 + SYS_HYPOTF = 0x883 + SYS_HYPOTL = 0x884 + SYS_LOG1PF = 0x885 + SYS_LOG1PL = 0x886 + SYS_LOG2F = 0x887 + SYS_LOG2 = 0x888 + SYS_LOG2L = 0x889 + SYS_TGAMMA = 0x890 + SYS_TGAMMAL = 0x891 + SYS_TRUNCF = 0x892 + SYS_TRUNC = 0x893 + SYS_TRUNCL = 0x894 + SYS_LGAMMAF = 0x895 + SYS_LGAMMAL = 0x896 + SYS_LROUNDF = 0x897 + SYS_LROUND = 0x898 + SYS_ERFF = 0x899 + SYS___COSHF_H = 0x900 + SYS___COSHL_H = 0x901 + SYS___COTAN_H = 0x902 + SYS___COTANF_H = 0x903 + SYS___COTANL_H = 0x904 + SYS___ERF_H = 0x905 + SYS___ERFF_H = 0x906 + SYS___ERFL_H = 0x907 + SYS___ERFC_H = 0x908 + SYS___ERFCF_H = 0x909 + SYS___FDIMF_H = 0x910 + SYS___FDIML_H = 0x911 + SYS___FMOD_H = 0x912 + SYS___FMODF_H = 0x913 + SYS___FMODL_H = 0x914 + SYS___GAMMA_H = 0x915 + SYS___HYPOT_H = 0x916 + SYS___ILOGB_H = 0x917 + SYS___LGAMMA_H = 0x918 + SYS___LGAMMAF_H = 0x919 + SYS___LOG2L_H = 0x920 + SYS___LOG1P_H = 0x921 + SYS___LOG10_H = 0x922 + SYS___LOG10F_H = 0x923 + SYS___LOG10L_H = 0x924 + SYS___LROUND_H = 0x925 + SYS___LROUNDF_H = 0x926 + SYS___NEXTAFTER_H = 0x927 + SYS___POW_H = 0x928 + SYS___POWF_H = 0x929 + SYS___SINL_H = 0x930 + SYS___SINH_H = 0x931 + SYS___SINHF_H = 0x932 + SYS___SINHL_H = 0x933 + SYS___SQRT_H = 0x934 + SYS___SQRTF_H = 0x935 + SYS___SQRTL_H = 0x936 + SYS___TAN_H = 0x937 + SYS___TANF_H = 0x938 + SYS___TANL_H = 0x939 + SYS___TRUNCF_H = 0x940 + SYS___TRUNCL_H = 0x941 + SYS___COSH_H = 0x942 + SYS___LE_DEBUG_SET_RESUME_MCH = 0x943 + SYS_VFSCANF = 0x944 + SYS_VSCANF = 0x946 + SYS_VSSCANF = 0x948 + SYS_IMAXABS = 0x950 + SYS_IMAXDIV = 0x951 + SYS_STRTOIMAX = 0x952 + SYS_STRTOUMAX = 0x953 + SYS_WCSTOIMAX = 0x954 + SYS_WCSTOUMAX = 0x955 + SYS_ATOLL = 0x956 + SYS_STRTOF = 0x957 + SYS_STRTOLD = 0x958 + SYS_WCSTOF = 0x959 + SYS_INET6_RTH_GETADDR = 0x960 + SYS_INET6_OPT_INIT = 0x961 + SYS_INET6_OPT_APPEND = 0x962 + SYS_INET6_OPT_FINISH = 0x963 + SYS_INET6_OPT_SET_VAL = 0x964 + SYS_INET6_OPT_NEXT = 0x965 + SYS_INET6_OPT_FIND = 0x966 + SYS_INET6_OPT_GET_VAL = 0x967 + SYS___POW_I = 0x987 + SYS___POW_I_B = 0x988 + SYS___POW_I_H = 0x989 + SYS___CABS_H = 0x990 + SYS_CABSF = 0x991 + SYS___CABSF_B = 0x992 + SYS___CABSF_H = 0x993 + SYS_CABSL = 0x994 + SYS___CABSL_B = 0x995 + SYS___CABSL_H = 0x996 + SYS_CACOS = 0x997 + SYS___CACOS_B = 0x998 + SYS___CACOS_H = 0x999 +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go index 2c1f815e6f9..7a8161c1d1c 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go @@ -1,6 +1,7 @@ // cgo -godefs types_aix.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build ppc && aix // +build ppc,aix package unix @@ -219,6 +220,7 @@ const ( SizeofSockaddrUnix = 0x401 SizeofSockaddrDatalink = 0x80 SizeofLinger = 0x8 + SizeofIovec = 0x8 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofIPv6MTUInfo = 0x20 diff --git a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go index b4a069ecbdf..07ed733c51b 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go @@ -1,6 +1,7 @@ // cgo -godefs types_aix.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build ppc64 && aix // +build ppc64,aix package unix @@ -223,6 +224,7 @@ const ( SizeofSockaddrUnix = 0x401 SizeofSockaddrDatalink = 0x80 SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofIPv6MTUInfo = 0x20 diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go index 830fbb35c0a..54db4333555 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go @@ -1,6 +1,7 @@ // cgo -godefs types_darwin.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build 386 && darwin // +build 386,darwin package unix @@ -269,6 +270,7 @@ const ( SizeofSockaddrDatalink = 0x14 SizeofSockaddrCtl = 0x20 SizeofLinger = 0x8 + SizeofIovec = 0x8 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x1c diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go index e53a7c49ffe..eb73e52fb68 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go @@ -1,6 +1,7 @@ // cgo -godefs types_darwin.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && darwin // +build amd64,darwin package unix @@ -210,6 +211,13 @@ type RawSockaddrCtl struct { type _Socklen uint32 +type Xucred struct { + Version uint32 + Uid uint32 + Ngroups int16 + Groups [16]uint32 +} + type Linger struct { Onoff int32 Linger int32 @@ -273,7 +281,9 @@ const ( SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x14 SizeofSockaddrCtl = 0x20 + SizeofXucred = 0x4c SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x30 diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go index 98be973ef94..8606d654e56 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go @@ -1,6 +1,7 @@ // cgo -godefs types_darwin.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm && darwin // +build arm,darwin package unix @@ -269,6 +270,7 @@ const ( SizeofSockaddrDatalink = 0x14 SizeofSockaddrCtl = 0x20 SizeofLinger = 0x8 + SizeofIovec = 0x8 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x1c diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go index ddae5afe1ba..dcb51f8404d 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go @@ -1,6 +1,7 @@ // cgo -godefs types_darwin.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm64 && darwin // +build arm64,darwin package unix @@ -210,6 +211,13 @@ type RawSockaddrCtl struct { type _Socklen uint32 +type Xucred struct { + Version uint32 + Uid uint32 + Ngroups int16 + Groups [16]uint32 +} + type Linger struct { Onoff int32 Linger int32 @@ -273,7 +281,9 @@ const ( SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x14 SizeofSockaddrCtl = 0x20 + SizeofXucred = 0x4c SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x30 diff --git a/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go index c4772df23bf..1d049d7a122 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go @@ -1,6 +1,7 @@ // cgo -godefs types_dragonfly.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && dragonfly // +build amd64,dragonfly package unix @@ -234,6 +235,7 @@ const ( SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x36 SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x30 diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go index 2a3ec615f75..c51bc88ffdf 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go @@ -1,6 +1,7 @@ // cgo -godefs types_freebsd.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build 386 && freebsd // +build 386,freebsd package unix @@ -250,6 +251,14 @@ type RawSockaddrAny struct { type _Socklen uint32 +type Xucred struct { + Version uint32 + Uid uint32 + Ngroups int16 + Groups [16]uint32 + _ *byte +} + type Linger struct { Onoff int32 Linger int32 @@ -312,7 +321,9 @@ const ( SizeofSockaddrAny = 0x6c SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x36 + SizeofXucred = 0x50 SizeofLinger = 0x8 + SizeofIovec = 0x8 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go index e11e95499e8..395b6918711 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go @@ -1,6 +1,7 @@ // cgo -godefs types_freebsd.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && freebsd // +build amd64,freebsd package unix @@ -246,6 +247,14 @@ type RawSockaddrAny struct { type _Socklen uint32 +type Xucred struct { + Version uint32 + Uid uint32 + Ngroups int16 + Groups [16]uint32 + _ *byte +} + type Linger struct { Onoff int32 Linger int32 @@ -308,7 +317,9 @@ const ( SizeofSockaddrAny = 0x6c SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x36 + SizeofXucred = 0x58 SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go index b91c2ae0f01..d3f9d2541b5 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go @@ -1,6 +1,7 @@ // cgo -godefs -- -fsigned-char types_freebsd.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm && freebsd // +build arm,freebsd package unix @@ -248,6 +249,14 @@ type RawSockaddrAny struct { type _Socklen uint32 +type Xucred struct { + Version uint32 + Uid uint32 + Ngroups int16 + Groups [16]uint32 + _ *byte +} + type Linger struct { Onoff int32 Linger int32 @@ -310,7 +319,9 @@ const ( SizeofSockaddrAny = 0x6c SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x36 + SizeofXucred = 0x50 SizeofLinger = 0x8 + SizeofIovec = 0x8 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go index c6fe1d097d8..434d6e8e83c 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go @@ -1,6 +1,7 @@ // cgo -godefs -- -fsigned-char types_freebsd.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm64 && freebsd // +build arm64,freebsd package unix @@ -246,6 +247,14 @@ type RawSockaddrAny struct { type _Socklen uint32 +type Xucred struct { + Version uint32 + Uid uint32 + Ngroups int16 + Groups [16]uint32 + _ *byte +} + type Linger struct { Onoff int32 Linger int32 @@ -308,7 +317,9 @@ const ( SizeofSockaddrAny = 0x6c SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x36 + SizeofXucred = 0x58 SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 diff --git a/vendor/golang.org/x/sys/unix/ztypes_illumos_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_illumos_amd64.go new file mode 100644 index 00000000000..1137a5a1f4b --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_illumos_amd64.go @@ -0,0 +1,40 @@ +// cgo -godefs types_illumos.go | go run mkpost.go +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build amd64 && illumos +// +build amd64,illumos + +package unix + +const ( + TUNNEWPPA = 0x540001 + TUNSETPPA = 0x540002 + + I_STR = 0x5308 + I_POP = 0x5303 + I_PUSH = 0x5302 + I_PLINK = 0x5316 + I_PUNLINK = 0x5317 + + IF_UNITSEL = -0x7ffb8cca +) + +type strbuf struct { + Maxlen int32 + Len int32 + Buf *int8 +} + +type strioctl struct { + Cmd int32 + Timout int32 + Len int32 + Dp *int8 +} + +type lifreq struct { + Name [32]int8 + Lifru1 [4]byte + Type uint32 + Lifru [336]byte +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go index 504ef131fb8..c769e73cd6f 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -1,5 +1,6 @@ // Code generated by mkmerge.go; DO NOT EDIT. +//go:build linux // +build linux package unix @@ -83,7 +84,7 @@ type FileCloneRange struct { Dest_offset uint64 } -type FileDedupeRange struct { +type RawFileDedupeRange struct { Src_offset uint64 Src_length uint64 Dest_count uint16 @@ -91,6 +92,21 @@ type FileDedupeRange struct { Reserved2 uint32 } +type RawFileDedupeRangeInfo struct { + Dest_fd int64 + Dest_offset uint64 + Bytes_deduped uint64 + Status int32 + Reserved uint32 +} + +const ( + SizeofRawFileDedupeRange = 0x18 + SizeofRawFileDedupeRangeInfo = 0x20 + FILE_DEDUPE_RANGE_SAME = 0x0 + FILE_DEDUPE_RANGE_DIFFERS = 0x1 +) + type FscryptPolicy struct { Version uint8 Contents_encryption_mode uint8 @@ -288,7 +304,8 @@ type RawSockaddrVM struct { Reserved1 uint16 Port uint32 Cid uint32 - Zero [4]uint8 + Flags uint8 + Zero [3]uint8 } type RawSockaddrXDP struct { @@ -999,7 +1016,7 @@ const ( PERF_SAMPLE_PHYS_ADDR = 0x80000 PERF_SAMPLE_AUX = 0x100000 PERF_SAMPLE_CGROUP = 0x200000 - PERF_SAMPLE_MAX = 0x400000 + PERF_SAMPLE_MAX = 0x1000000 PERF_SAMPLE_BRANCH_USER_SHIFT = 0x0 PERF_SAMPLE_BRANCH_KERNEL_SHIFT = 0x1 PERF_SAMPLE_BRANCH_HV_SHIFT = 0x2 @@ -1381,6 +1398,11 @@ const ( IFLA_PROP_LIST = 0x34 IFLA_ALT_IFNAME = 0x35 IFLA_PERM_ADDRESS = 0x36 + IFLA_PROTO_DOWN_REASON = 0x37 + IFLA_PROTO_DOWN_REASON_UNSPEC = 0x0 + IFLA_PROTO_DOWN_REASON_MASK = 0x1 + IFLA_PROTO_DOWN_REASON_VALUE = 0x2 + IFLA_PROTO_DOWN_REASON_MAX = 0x2 IFLA_INET_UNSPEC = 0x0 IFLA_INET_CONF = 0x1 IFLA_INET6_UNSPEC = 0x0 @@ -1475,6 +1497,7 @@ const ( IFLA_BRPORT_ISOLATED = 0x21 IFLA_BRPORT_BACKUP_PORT = 0x22 IFLA_BRPORT_MRP_RING_OPEN = 0x23 + IFLA_BRPORT_MRP_IN_OPEN = 0x24 IFLA_INFO_UNSPEC = 0x0 IFLA_INFO_KIND = 0x1 IFLA_INFO_DATA = 0x2 @@ -1673,6 +1696,7 @@ const ( IFLA_HSR_SUPERVISION_ADDR = 0x4 IFLA_HSR_SEQ_NR = 0x5 IFLA_HSR_VERSION = 0x6 + IFLA_HSR_PROTOCOL = 0x7 IFLA_STATS_UNSPEC = 0x0 IFLA_STATS_LINK_64 = 0x1 IFLA_STATS_LINK_XSTATS = 0x2 @@ -2217,10 +2241,12 @@ const ( ) const ( - NETNSA_NONE = 0x0 - NETNSA_NSID = 0x1 - NETNSA_PID = 0x2 - NETNSA_FD = 0x3 + NETNSA_NONE = 0x0 + NETNSA_NSID = 0x1 + NETNSA_PID = 0x2 + NETNSA_FD = 0x3 + NETNSA_TARGET_NSID = 0x4 + NETNSA_CURRENT_NSID = 0x5 ) type XDPRingOffset struct { @@ -2370,281 +2396,309 @@ const ( ) const ( - BPF_REG_0 = 0x0 - BPF_REG_1 = 0x1 - BPF_REG_2 = 0x2 - BPF_REG_3 = 0x3 - BPF_REG_4 = 0x4 - BPF_REG_5 = 0x5 - BPF_REG_6 = 0x6 - BPF_REG_7 = 0x7 - BPF_REG_8 = 0x8 - BPF_REG_9 = 0x9 - BPF_REG_10 = 0xa - BPF_MAP_CREATE = 0x0 - BPF_MAP_LOOKUP_ELEM = 0x1 - BPF_MAP_UPDATE_ELEM = 0x2 - BPF_MAP_DELETE_ELEM = 0x3 - BPF_MAP_GET_NEXT_KEY = 0x4 - BPF_PROG_LOAD = 0x5 - BPF_OBJ_PIN = 0x6 - BPF_OBJ_GET = 0x7 - BPF_PROG_ATTACH = 0x8 - BPF_PROG_DETACH = 0x9 - BPF_PROG_TEST_RUN = 0xa - BPF_PROG_GET_NEXT_ID = 0xb - BPF_MAP_GET_NEXT_ID = 0xc - BPF_PROG_GET_FD_BY_ID = 0xd - BPF_MAP_GET_FD_BY_ID = 0xe - BPF_OBJ_GET_INFO_BY_FD = 0xf - BPF_PROG_QUERY = 0x10 - BPF_RAW_TRACEPOINT_OPEN = 0x11 - BPF_BTF_LOAD = 0x12 - BPF_BTF_GET_FD_BY_ID = 0x13 - BPF_TASK_FD_QUERY = 0x14 - BPF_MAP_LOOKUP_AND_DELETE_ELEM = 0x15 - BPF_MAP_FREEZE = 0x16 - BPF_BTF_GET_NEXT_ID = 0x17 - BPF_MAP_LOOKUP_BATCH = 0x18 - BPF_MAP_LOOKUP_AND_DELETE_BATCH = 0x19 - BPF_MAP_UPDATE_BATCH = 0x1a - BPF_MAP_DELETE_BATCH = 0x1b - BPF_LINK_CREATE = 0x1c - BPF_LINK_UPDATE = 0x1d - BPF_LINK_GET_FD_BY_ID = 0x1e - BPF_LINK_GET_NEXT_ID = 0x1f - BPF_ENABLE_STATS = 0x20 - BPF_ITER_CREATE = 0x21 - BPF_MAP_TYPE_UNSPEC = 0x0 - BPF_MAP_TYPE_HASH = 0x1 - BPF_MAP_TYPE_ARRAY = 0x2 - BPF_MAP_TYPE_PROG_ARRAY = 0x3 - BPF_MAP_TYPE_PERF_EVENT_ARRAY = 0x4 - BPF_MAP_TYPE_PERCPU_HASH = 0x5 - BPF_MAP_TYPE_PERCPU_ARRAY = 0x6 - BPF_MAP_TYPE_STACK_TRACE = 0x7 - BPF_MAP_TYPE_CGROUP_ARRAY = 0x8 - BPF_MAP_TYPE_LRU_HASH = 0x9 - BPF_MAP_TYPE_LRU_PERCPU_HASH = 0xa - BPF_MAP_TYPE_LPM_TRIE = 0xb - BPF_MAP_TYPE_ARRAY_OF_MAPS = 0xc - BPF_MAP_TYPE_HASH_OF_MAPS = 0xd - BPF_MAP_TYPE_DEVMAP = 0xe - BPF_MAP_TYPE_SOCKMAP = 0xf - BPF_MAP_TYPE_CPUMAP = 0x10 - BPF_MAP_TYPE_XSKMAP = 0x11 - BPF_MAP_TYPE_SOCKHASH = 0x12 - BPF_MAP_TYPE_CGROUP_STORAGE = 0x13 - BPF_MAP_TYPE_REUSEPORT_SOCKARRAY = 0x14 - BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = 0x15 - BPF_MAP_TYPE_QUEUE = 0x16 - BPF_MAP_TYPE_STACK = 0x17 - BPF_MAP_TYPE_SK_STORAGE = 0x18 - BPF_MAP_TYPE_DEVMAP_HASH = 0x19 - BPF_MAP_TYPE_STRUCT_OPS = 0x1a - BPF_MAP_TYPE_RINGBUF = 0x1b - BPF_PROG_TYPE_UNSPEC = 0x0 - BPF_PROG_TYPE_SOCKET_FILTER = 0x1 - BPF_PROG_TYPE_KPROBE = 0x2 - BPF_PROG_TYPE_SCHED_CLS = 0x3 - BPF_PROG_TYPE_SCHED_ACT = 0x4 - BPF_PROG_TYPE_TRACEPOINT = 0x5 - BPF_PROG_TYPE_XDP = 0x6 - BPF_PROG_TYPE_PERF_EVENT = 0x7 - BPF_PROG_TYPE_CGROUP_SKB = 0x8 - BPF_PROG_TYPE_CGROUP_SOCK = 0x9 - BPF_PROG_TYPE_LWT_IN = 0xa - BPF_PROG_TYPE_LWT_OUT = 0xb - BPF_PROG_TYPE_LWT_XMIT = 0xc - BPF_PROG_TYPE_SOCK_OPS = 0xd - BPF_PROG_TYPE_SK_SKB = 0xe - BPF_PROG_TYPE_CGROUP_DEVICE = 0xf - BPF_PROG_TYPE_SK_MSG = 0x10 - BPF_PROG_TYPE_RAW_TRACEPOINT = 0x11 - BPF_PROG_TYPE_CGROUP_SOCK_ADDR = 0x12 - BPF_PROG_TYPE_LWT_SEG6LOCAL = 0x13 - BPF_PROG_TYPE_LIRC_MODE2 = 0x14 - BPF_PROG_TYPE_SK_REUSEPORT = 0x15 - BPF_PROG_TYPE_FLOW_DISSECTOR = 0x16 - BPF_PROG_TYPE_CGROUP_SYSCTL = 0x17 - BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE = 0x18 - BPF_PROG_TYPE_CGROUP_SOCKOPT = 0x19 - BPF_PROG_TYPE_TRACING = 0x1a - BPF_PROG_TYPE_STRUCT_OPS = 0x1b - BPF_PROG_TYPE_EXT = 0x1c - BPF_PROG_TYPE_LSM = 0x1d - BPF_CGROUP_INET_INGRESS = 0x0 - BPF_CGROUP_INET_EGRESS = 0x1 - BPF_CGROUP_INET_SOCK_CREATE = 0x2 - BPF_CGROUP_SOCK_OPS = 0x3 - BPF_SK_SKB_STREAM_PARSER = 0x4 - BPF_SK_SKB_STREAM_VERDICT = 0x5 - BPF_CGROUP_DEVICE = 0x6 - BPF_SK_MSG_VERDICT = 0x7 - BPF_CGROUP_INET4_BIND = 0x8 - BPF_CGROUP_INET6_BIND = 0x9 - BPF_CGROUP_INET4_CONNECT = 0xa - BPF_CGROUP_INET6_CONNECT = 0xb - BPF_CGROUP_INET4_POST_BIND = 0xc - BPF_CGROUP_INET6_POST_BIND = 0xd - BPF_CGROUP_UDP4_SENDMSG = 0xe - BPF_CGROUP_UDP6_SENDMSG = 0xf - BPF_LIRC_MODE2 = 0x10 - BPF_FLOW_DISSECTOR = 0x11 - BPF_CGROUP_SYSCTL = 0x12 - BPF_CGROUP_UDP4_RECVMSG = 0x13 - BPF_CGROUP_UDP6_RECVMSG = 0x14 - BPF_CGROUP_GETSOCKOPT = 0x15 - BPF_CGROUP_SETSOCKOPT = 0x16 - BPF_TRACE_RAW_TP = 0x17 - BPF_TRACE_FENTRY = 0x18 - BPF_TRACE_FEXIT = 0x19 - BPF_MODIFY_RETURN = 0x1a - BPF_LSM_MAC = 0x1b - BPF_TRACE_ITER = 0x1c - BPF_CGROUP_INET4_GETPEERNAME = 0x1d - BPF_CGROUP_INET6_GETPEERNAME = 0x1e - BPF_CGROUP_INET4_GETSOCKNAME = 0x1f - BPF_CGROUP_INET6_GETSOCKNAME = 0x20 - BPF_XDP_DEVMAP = 0x21 - BPF_LINK_TYPE_UNSPEC = 0x0 - BPF_LINK_TYPE_RAW_TRACEPOINT = 0x1 - BPF_LINK_TYPE_TRACING = 0x2 - BPF_LINK_TYPE_CGROUP = 0x3 - BPF_LINK_TYPE_ITER = 0x4 - BPF_LINK_TYPE_NETNS = 0x5 - BPF_ANY = 0x0 - BPF_NOEXIST = 0x1 - BPF_EXIST = 0x2 - BPF_F_LOCK = 0x4 - BPF_F_NO_PREALLOC = 0x1 - BPF_F_NO_COMMON_LRU = 0x2 - BPF_F_NUMA_NODE = 0x4 - BPF_F_RDONLY = 0x8 - BPF_F_WRONLY = 0x10 - BPF_F_STACK_BUILD_ID = 0x20 - BPF_F_ZERO_SEED = 0x40 - BPF_F_RDONLY_PROG = 0x80 - BPF_F_WRONLY_PROG = 0x100 - BPF_F_CLONE = 0x200 - BPF_F_MMAPABLE = 0x400 - BPF_STATS_RUN_TIME = 0x0 - BPF_STACK_BUILD_ID_EMPTY = 0x0 - BPF_STACK_BUILD_ID_VALID = 0x1 - BPF_STACK_BUILD_ID_IP = 0x2 - BPF_F_RECOMPUTE_CSUM = 0x1 - BPF_F_INVALIDATE_HASH = 0x2 - BPF_F_HDR_FIELD_MASK = 0xf - BPF_F_PSEUDO_HDR = 0x10 - BPF_F_MARK_MANGLED_0 = 0x20 - BPF_F_MARK_ENFORCE = 0x40 - BPF_F_INGRESS = 0x1 - BPF_F_TUNINFO_IPV6 = 0x1 - BPF_F_SKIP_FIELD_MASK = 0xff - BPF_F_USER_STACK = 0x100 - BPF_F_FAST_STACK_CMP = 0x200 - BPF_F_REUSE_STACKID = 0x400 - BPF_F_USER_BUILD_ID = 0x800 - BPF_F_ZERO_CSUM_TX = 0x2 - BPF_F_DONT_FRAGMENT = 0x4 - BPF_F_SEQ_NUMBER = 0x8 - BPF_F_INDEX_MASK = 0xffffffff - BPF_F_CURRENT_CPU = 0xffffffff - BPF_F_CTXLEN_MASK = 0xfffff00000000 - BPF_F_CURRENT_NETNS = -0x1 - BPF_CSUM_LEVEL_QUERY = 0x0 - BPF_CSUM_LEVEL_INC = 0x1 - BPF_CSUM_LEVEL_DEC = 0x2 - BPF_CSUM_LEVEL_RESET = 0x3 - BPF_F_ADJ_ROOM_FIXED_GSO = 0x1 - BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 = 0x2 - BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 = 0x4 - BPF_F_ADJ_ROOM_ENCAP_L4_GRE = 0x8 - BPF_F_ADJ_ROOM_ENCAP_L4_UDP = 0x10 - BPF_F_ADJ_ROOM_NO_CSUM_RESET = 0x20 - BPF_ADJ_ROOM_ENCAP_L2_MASK = 0xff - BPF_ADJ_ROOM_ENCAP_L2_SHIFT = 0x38 - BPF_F_SYSCTL_BASE_NAME = 0x1 - BPF_SK_STORAGE_GET_F_CREATE = 0x1 - BPF_F_GET_BRANCH_RECORDS_SIZE = 0x1 - BPF_RB_NO_WAKEUP = 0x1 - BPF_RB_FORCE_WAKEUP = 0x2 - BPF_RB_AVAIL_DATA = 0x0 - BPF_RB_RING_SIZE = 0x1 - BPF_RB_CONS_POS = 0x2 - BPF_RB_PROD_POS = 0x3 - BPF_RINGBUF_BUSY_BIT = 0x80000000 - BPF_RINGBUF_DISCARD_BIT = 0x40000000 - BPF_RINGBUF_HDR_SZ = 0x8 - BPF_ADJ_ROOM_NET = 0x0 - BPF_ADJ_ROOM_MAC = 0x1 - BPF_HDR_START_MAC = 0x0 - BPF_HDR_START_NET = 0x1 - BPF_LWT_ENCAP_SEG6 = 0x0 - BPF_LWT_ENCAP_SEG6_INLINE = 0x1 - BPF_LWT_ENCAP_IP = 0x2 - BPF_OK = 0x0 - BPF_DROP = 0x2 - BPF_REDIRECT = 0x7 - BPF_LWT_REROUTE = 0x80 - BPF_SOCK_OPS_RTO_CB_FLAG = 0x1 - BPF_SOCK_OPS_RETRANS_CB_FLAG = 0x2 - BPF_SOCK_OPS_STATE_CB_FLAG = 0x4 - BPF_SOCK_OPS_RTT_CB_FLAG = 0x8 - BPF_SOCK_OPS_ALL_CB_FLAGS = 0xf - BPF_SOCK_OPS_VOID = 0x0 - BPF_SOCK_OPS_TIMEOUT_INIT = 0x1 - BPF_SOCK_OPS_RWND_INIT = 0x2 - BPF_SOCK_OPS_TCP_CONNECT_CB = 0x3 - BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB = 0x4 - BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB = 0x5 - BPF_SOCK_OPS_NEEDS_ECN = 0x6 - BPF_SOCK_OPS_BASE_RTT = 0x7 - BPF_SOCK_OPS_RTO_CB = 0x8 - BPF_SOCK_OPS_RETRANS_CB = 0x9 - BPF_SOCK_OPS_STATE_CB = 0xa - BPF_SOCK_OPS_TCP_LISTEN_CB = 0xb - BPF_SOCK_OPS_RTT_CB = 0xc - BPF_TCP_ESTABLISHED = 0x1 - BPF_TCP_SYN_SENT = 0x2 - BPF_TCP_SYN_RECV = 0x3 - BPF_TCP_FIN_WAIT1 = 0x4 - BPF_TCP_FIN_WAIT2 = 0x5 - BPF_TCP_TIME_WAIT = 0x6 - BPF_TCP_CLOSE = 0x7 - BPF_TCP_CLOSE_WAIT = 0x8 - BPF_TCP_LAST_ACK = 0x9 - BPF_TCP_LISTEN = 0xa - BPF_TCP_CLOSING = 0xb - BPF_TCP_NEW_SYN_RECV = 0xc - BPF_TCP_MAX_STATES = 0xd - TCP_BPF_IW = 0x3e9 - TCP_BPF_SNDCWND_CLAMP = 0x3ea - BPF_DEVCG_ACC_MKNOD = 0x1 - BPF_DEVCG_ACC_READ = 0x2 - BPF_DEVCG_ACC_WRITE = 0x4 - BPF_DEVCG_DEV_BLOCK = 0x1 - BPF_DEVCG_DEV_CHAR = 0x2 - BPF_FIB_LOOKUP_DIRECT = 0x1 - BPF_FIB_LOOKUP_OUTPUT = 0x2 - BPF_FIB_LKUP_RET_SUCCESS = 0x0 - BPF_FIB_LKUP_RET_BLACKHOLE = 0x1 - BPF_FIB_LKUP_RET_UNREACHABLE = 0x2 - BPF_FIB_LKUP_RET_PROHIBIT = 0x3 - BPF_FIB_LKUP_RET_NOT_FWDED = 0x4 - BPF_FIB_LKUP_RET_FWD_DISABLED = 0x5 - BPF_FIB_LKUP_RET_UNSUPP_LWT = 0x6 - BPF_FIB_LKUP_RET_NO_NEIGH = 0x7 - BPF_FIB_LKUP_RET_FRAG_NEEDED = 0x8 - BPF_FD_TYPE_RAW_TRACEPOINT = 0x0 - BPF_FD_TYPE_TRACEPOINT = 0x1 - BPF_FD_TYPE_KPROBE = 0x2 - BPF_FD_TYPE_KRETPROBE = 0x3 - BPF_FD_TYPE_UPROBE = 0x4 - BPF_FD_TYPE_URETPROBE = 0x5 - BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG = 0x1 - BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL = 0x2 - BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP = 0x4 + BPF_REG_0 = 0x0 + BPF_REG_1 = 0x1 + BPF_REG_2 = 0x2 + BPF_REG_3 = 0x3 + BPF_REG_4 = 0x4 + BPF_REG_5 = 0x5 + BPF_REG_6 = 0x6 + BPF_REG_7 = 0x7 + BPF_REG_8 = 0x8 + BPF_REG_9 = 0x9 + BPF_REG_10 = 0xa + BPF_MAP_CREATE = 0x0 + BPF_MAP_LOOKUP_ELEM = 0x1 + BPF_MAP_UPDATE_ELEM = 0x2 + BPF_MAP_DELETE_ELEM = 0x3 + BPF_MAP_GET_NEXT_KEY = 0x4 + BPF_PROG_LOAD = 0x5 + BPF_OBJ_PIN = 0x6 + BPF_OBJ_GET = 0x7 + BPF_PROG_ATTACH = 0x8 + BPF_PROG_DETACH = 0x9 + BPF_PROG_TEST_RUN = 0xa + BPF_PROG_GET_NEXT_ID = 0xb + BPF_MAP_GET_NEXT_ID = 0xc + BPF_PROG_GET_FD_BY_ID = 0xd + BPF_MAP_GET_FD_BY_ID = 0xe + BPF_OBJ_GET_INFO_BY_FD = 0xf + BPF_PROG_QUERY = 0x10 + BPF_RAW_TRACEPOINT_OPEN = 0x11 + BPF_BTF_LOAD = 0x12 + BPF_BTF_GET_FD_BY_ID = 0x13 + BPF_TASK_FD_QUERY = 0x14 + BPF_MAP_LOOKUP_AND_DELETE_ELEM = 0x15 + BPF_MAP_FREEZE = 0x16 + BPF_BTF_GET_NEXT_ID = 0x17 + BPF_MAP_LOOKUP_BATCH = 0x18 + BPF_MAP_LOOKUP_AND_DELETE_BATCH = 0x19 + BPF_MAP_UPDATE_BATCH = 0x1a + BPF_MAP_DELETE_BATCH = 0x1b + BPF_LINK_CREATE = 0x1c + BPF_LINK_UPDATE = 0x1d + BPF_LINK_GET_FD_BY_ID = 0x1e + BPF_LINK_GET_NEXT_ID = 0x1f + BPF_ENABLE_STATS = 0x20 + BPF_ITER_CREATE = 0x21 + BPF_LINK_DETACH = 0x22 + BPF_PROG_BIND_MAP = 0x23 + BPF_MAP_TYPE_UNSPEC = 0x0 + BPF_MAP_TYPE_HASH = 0x1 + BPF_MAP_TYPE_ARRAY = 0x2 + BPF_MAP_TYPE_PROG_ARRAY = 0x3 + BPF_MAP_TYPE_PERF_EVENT_ARRAY = 0x4 + BPF_MAP_TYPE_PERCPU_HASH = 0x5 + BPF_MAP_TYPE_PERCPU_ARRAY = 0x6 + BPF_MAP_TYPE_STACK_TRACE = 0x7 + BPF_MAP_TYPE_CGROUP_ARRAY = 0x8 + BPF_MAP_TYPE_LRU_HASH = 0x9 + BPF_MAP_TYPE_LRU_PERCPU_HASH = 0xa + BPF_MAP_TYPE_LPM_TRIE = 0xb + BPF_MAP_TYPE_ARRAY_OF_MAPS = 0xc + BPF_MAP_TYPE_HASH_OF_MAPS = 0xd + BPF_MAP_TYPE_DEVMAP = 0xe + BPF_MAP_TYPE_SOCKMAP = 0xf + BPF_MAP_TYPE_CPUMAP = 0x10 + BPF_MAP_TYPE_XSKMAP = 0x11 + BPF_MAP_TYPE_SOCKHASH = 0x12 + BPF_MAP_TYPE_CGROUP_STORAGE = 0x13 + BPF_MAP_TYPE_REUSEPORT_SOCKARRAY = 0x14 + BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = 0x15 + BPF_MAP_TYPE_QUEUE = 0x16 + BPF_MAP_TYPE_STACK = 0x17 + BPF_MAP_TYPE_SK_STORAGE = 0x18 + BPF_MAP_TYPE_DEVMAP_HASH = 0x19 + BPF_MAP_TYPE_STRUCT_OPS = 0x1a + BPF_MAP_TYPE_RINGBUF = 0x1b + BPF_MAP_TYPE_INODE_STORAGE = 0x1c + BPF_PROG_TYPE_UNSPEC = 0x0 + BPF_PROG_TYPE_SOCKET_FILTER = 0x1 + BPF_PROG_TYPE_KPROBE = 0x2 + BPF_PROG_TYPE_SCHED_CLS = 0x3 + BPF_PROG_TYPE_SCHED_ACT = 0x4 + BPF_PROG_TYPE_TRACEPOINT = 0x5 + BPF_PROG_TYPE_XDP = 0x6 + BPF_PROG_TYPE_PERF_EVENT = 0x7 + BPF_PROG_TYPE_CGROUP_SKB = 0x8 + BPF_PROG_TYPE_CGROUP_SOCK = 0x9 + BPF_PROG_TYPE_LWT_IN = 0xa + BPF_PROG_TYPE_LWT_OUT = 0xb + BPF_PROG_TYPE_LWT_XMIT = 0xc + BPF_PROG_TYPE_SOCK_OPS = 0xd + BPF_PROG_TYPE_SK_SKB = 0xe + BPF_PROG_TYPE_CGROUP_DEVICE = 0xf + BPF_PROG_TYPE_SK_MSG = 0x10 + BPF_PROG_TYPE_RAW_TRACEPOINT = 0x11 + BPF_PROG_TYPE_CGROUP_SOCK_ADDR = 0x12 + BPF_PROG_TYPE_LWT_SEG6LOCAL = 0x13 + BPF_PROG_TYPE_LIRC_MODE2 = 0x14 + BPF_PROG_TYPE_SK_REUSEPORT = 0x15 + BPF_PROG_TYPE_FLOW_DISSECTOR = 0x16 + BPF_PROG_TYPE_CGROUP_SYSCTL = 0x17 + BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE = 0x18 + BPF_PROG_TYPE_CGROUP_SOCKOPT = 0x19 + BPF_PROG_TYPE_TRACING = 0x1a + BPF_PROG_TYPE_STRUCT_OPS = 0x1b + BPF_PROG_TYPE_EXT = 0x1c + BPF_PROG_TYPE_LSM = 0x1d + BPF_PROG_TYPE_SK_LOOKUP = 0x1e + BPF_CGROUP_INET_INGRESS = 0x0 + BPF_CGROUP_INET_EGRESS = 0x1 + BPF_CGROUP_INET_SOCK_CREATE = 0x2 + BPF_CGROUP_SOCK_OPS = 0x3 + BPF_SK_SKB_STREAM_PARSER = 0x4 + BPF_SK_SKB_STREAM_VERDICT = 0x5 + BPF_CGROUP_DEVICE = 0x6 + BPF_SK_MSG_VERDICT = 0x7 + BPF_CGROUP_INET4_BIND = 0x8 + BPF_CGROUP_INET6_BIND = 0x9 + BPF_CGROUP_INET4_CONNECT = 0xa + BPF_CGROUP_INET6_CONNECT = 0xb + BPF_CGROUP_INET4_POST_BIND = 0xc + BPF_CGROUP_INET6_POST_BIND = 0xd + BPF_CGROUP_UDP4_SENDMSG = 0xe + BPF_CGROUP_UDP6_SENDMSG = 0xf + BPF_LIRC_MODE2 = 0x10 + BPF_FLOW_DISSECTOR = 0x11 + BPF_CGROUP_SYSCTL = 0x12 + BPF_CGROUP_UDP4_RECVMSG = 0x13 + BPF_CGROUP_UDP6_RECVMSG = 0x14 + BPF_CGROUP_GETSOCKOPT = 0x15 + BPF_CGROUP_SETSOCKOPT = 0x16 + BPF_TRACE_RAW_TP = 0x17 + BPF_TRACE_FENTRY = 0x18 + BPF_TRACE_FEXIT = 0x19 + BPF_MODIFY_RETURN = 0x1a + BPF_LSM_MAC = 0x1b + BPF_TRACE_ITER = 0x1c + BPF_CGROUP_INET4_GETPEERNAME = 0x1d + BPF_CGROUP_INET6_GETPEERNAME = 0x1e + BPF_CGROUP_INET4_GETSOCKNAME = 0x1f + BPF_CGROUP_INET6_GETSOCKNAME = 0x20 + BPF_XDP_DEVMAP = 0x21 + BPF_CGROUP_INET_SOCK_RELEASE = 0x22 + BPF_XDP_CPUMAP = 0x23 + BPF_SK_LOOKUP = 0x24 + BPF_XDP = 0x25 + BPF_LINK_TYPE_UNSPEC = 0x0 + BPF_LINK_TYPE_RAW_TRACEPOINT = 0x1 + BPF_LINK_TYPE_TRACING = 0x2 + BPF_LINK_TYPE_CGROUP = 0x3 + BPF_LINK_TYPE_ITER = 0x4 + BPF_LINK_TYPE_NETNS = 0x5 + BPF_LINK_TYPE_XDP = 0x6 + BPF_ANY = 0x0 + BPF_NOEXIST = 0x1 + BPF_EXIST = 0x2 + BPF_F_LOCK = 0x4 + BPF_F_NO_PREALLOC = 0x1 + BPF_F_NO_COMMON_LRU = 0x2 + BPF_F_NUMA_NODE = 0x4 + BPF_F_RDONLY = 0x8 + BPF_F_WRONLY = 0x10 + BPF_F_STACK_BUILD_ID = 0x20 + BPF_F_ZERO_SEED = 0x40 + BPF_F_RDONLY_PROG = 0x80 + BPF_F_WRONLY_PROG = 0x100 + BPF_F_CLONE = 0x200 + BPF_F_MMAPABLE = 0x400 + BPF_F_PRESERVE_ELEMS = 0x800 + BPF_F_INNER_MAP = 0x1000 + BPF_STATS_RUN_TIME = 0x0 + BPF_STACK_BUILD_ID_EMPTY = 0x0 + BPF_STACK_BUILD_ID_VALID = 0x1 + BPF_STACK_BUILD_ID_IP = 0x2 + BPF_F_RECOMPUTE_CSUM = 0x1 + BPF_F_INVALIDATE_HASH = 0x2 + BPF_F_HDR_FIELD_MASK = 0xf + BPF_F_PSEUDO_HDR = 0x10 + BPF_F_MARK_MANGLED_0 = 0x20 + BPF_F_MARK_ENFORCE = 0x40 + BPF_F_INGRESS = 0x1 + BPF_F_TUNINFO_IPV6 = 0x1 + BPF_F_SKIP_FIELD_MASK = 0xff + BPF_F_USER_STACK = 0x100 + BPF_F_FAST_STACK_CMP = 0x200 + BPF_F_REUSE_STACKID = 0x400 + BPF_F_USER_BUILD_ID = 0x800 + BPF_F_ZERO_CSUM_TX = 0x2 + BPF_F_DONT_FRAGMENT = 0x4 + BPF_F_SEQ_NUMBER = 0x8 + BPF_F_INDEX_MASK = 0xffffffff + BPF_F_CURRENT_CPU = 0xffffffff + BPF_F_CTXLEN_MASK = 0xfffff00000000 + BPF_F_CURRENT_NETNS = -0x1 + BPF_CSUM_LEVEL_QUERY = 0x0 + BPF_CSUM_LEVEL_INC = 0x1 + BPF_CSUM_LEVEL_DEC = 0x2 + BPF_CSUM_LEVEL_RESET = 0x3 + BPF_F_ADJ_ROOM_FIXED_GSO = 0x1 + BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 = 0x2 + BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 = 0x4 + BPF_F_ADJ_ROOM_ENCAP_L4_GRE = 0x8 + BPF_F_ADJ_ROOM_ENCAP_L4_UDP = 0x10 + BPF_F_ADJ_ROOM_NO_CSUM_RESET = 0x20 + BPF_ADJ_ROOM_ENCAP_L2_MASK = 0xff + BPF_ADJ_ROOM_ENCAP_L2_SHIFT = 0x38 + BPF_F_SYSCTL_BASE_NAME = 0x1 + BPF_LOCAL_STORAGE_GET_F_CREATE = 0x1 + BPF_SK_STORAGE_GET_F_CREATE = 0x1 + BPF_F_GET_BRANCH_RECORDS_SIZE = 0x1 + BPF_RB_NO_WAKEUP = 0x1 + BPF_RB_FORCE_WAKEUP = 0x2 + BPF_RB_AVAIL_DATA = 0x0 + BPF_RB_RING_SIZE = 0x1 + BPF_RB_CONS_POS = 0x2 + BPF_RB_PROD_POS = 0x3 + BPF_RINGBUF_BUSY_BIT = 0x80000000 + BPF_RINGBUF_DISCARD_BIT = 0x40000000 + BPF_RINGBUF_HDR_SZ = 0x8 + BPF_SK_LOOKUP_F_REPLACE = 0x1 + BPF_SK_LOOKUP_F_NO_REUSEPORT = 0x2 + BPF_ADJ_ROOM_NET = 0x0 + BPF_ADJ_ROOM_MAC = 0x1 + BPF_HDR_START_MAC = 0x0 + BPF_HDR_START_NET = 0x1 + BPF_LWT_ENCAP_SEG6 = 0x0 + BPF_LWT_ENCAP_SEG6_INLINE = 0x1 + BPF_LWT_ENCAP_IP = 0x2 + BPF_OK = 0x0 + BPF_DROP = 0x2 + BPF_REDIRECT = 0x7 + BPF_LWT_REROUTE = 0x80 + BPF_SOCK_OPS_RTO_CB_FLAG = 0x1 + BPF_SOCK_OPS_RETRANS_CB_FLAG = 0x2 + BPF_SOCK_OPS_STATE_CB_FLAG = 0x4 + BPF_SOCK_OPS_RTT_CB_FLAG = 0x8 + BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG = 0x10 + BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG = 0x20 + BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG = 0x40 + BPF_SOCK_OPS_ALL_CB_FLAGS = 0x7f + BPF_SOCK_OPS_VOID = 0x0 + BPF_SOCK_OPS_TIMEOUT_INIT = 0x1 + BPF_SOCK_OPS_RWND_INIT = 0x2 + BPF_SOCK_OPS_TCP_CONNECT_CB = 0x3 + BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB = 0x4 + BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB = 0x5 + BPF_SOCK_OPS_NEEDS_ECN = 0x6 + BPF_SOCK_OPS_BASE_RTT = 0x7 + BPF_SOCK_OPS_RTO_CB = 0x8 + BPF_SOCK_OPS_RETRANS_CB = 0x9 + BPF_SOCK_OPS_STATE_CB = 0xa + BPF_SOCK_OPS_TCP_LISTEN_CB = 0xb + BPF_SOCK_OPS_RTT_CB = 0xc + BPF_SOCK_OPS_PARSE_HDR_OPT_CB = 0xd + BPF_SOCK_OPS_HDR_OPT_LEN_CB = 0xe + BPF_SOCK_OPS_WRITE_HDR_OPT_CB = 0xf + BPF_TCP_ESTABLISHED = 0x1 + BPF_TCP_SYN_SENT = 0x2 + BPF_TCP_SYN_RECV = 0x3 + BPF_TCP_FIN_WAIT1 = 0x4 + BPF_TCP_FIN_WAIT2 = 0x5 + BPF_TCP_TIME_WAIT = 0x6 + BPF_TCP_CLOSE = 0x7 + BPF_TCP_CLOSE_WAIT = 0x8 + BPF_TCP_LAST_ACK = 0x9 + BPF_TCP_LISTEN = 0xa + BPF_TCP_CLOSING = 0xb + BPF_TCP_NEW_SYN_RECV = 0xc + BPF_TCP_MAX_STATES = 0xd + TCP_BPF_IW = 0x3e9 + TCP_BPF_SNDCWND_CLAMP = 0x3ea + TCP_BPF_DELACK_MAX = 0x3eb + TCP_BPF_RTO_MIN = 0x3ec + TCP_BPF_SYN = 0x3ed + TCP_BPF_SYN_IP = 0x3ee + TCP_BPF_SYN_MAC = 0x3ef + BPF_LOAD_HDR_OPT_TCP_SYN = 0x1 + BPF_WRITE_HDR_TCP_CURRENT_MSS = 0x1 + BPF_WRITE_HDR_TCP_SYNACK_COOKIE = 0x2 + BPF_DEVCG_ACC_MKNOD = 0x1 + BPF_DEVCG_ACC_READ = 0x2 + BPF_DEVCG_ACC_WRITE = 0x4 + BPF_DEVCG_DEV_BLOCK = 0x1 + BPF_DEVCG_DEV_CHAR = 0x2 + BPF_FIB_LOOKUP_DIRECT = 0x1 + BPF_FIB_LOOKUP_OUTPUT = 0x2 + BPF_FIB_LKUP_RET_SUCCESS = 0x0 + BPF_FIB_LKUP_RET_BLACKHOLE = 0x1 + BPF_FIB_LKUP_RET_UNREACHABLE = 0x2 + BPF_FIB_LKUP_RET_PROHIBIT = 0x3 + BPF_FIB_LKUP_RET_NOT_FWDED = 0x4 + BPF_FIB_LKUP_RET_FWD_DISABLED = 0x5 + BPF_FIB_LKUP_RET_UNSUPP_LWT = 0x6 + BPF_FIB_LKUP_RET_NO_NEIGH = 0x7 + BPF_FIB_LKUP_RET_FRAG_NEEDED = 0x8 + BPF_FD_TYPE_RAW_TRACEPOINT = 0x0 + BPF_FD_TYPE_TRACEPOINT = 0x1 + BPF_FD_TYPE_KPROBE = 0x2 + BPF_FD_TYPE_KRETPROBE = 0x3 + BPF_FD_TYPE_UPROBE = 0x4 + BPF_FD_TYPE_URETPROBE = 0x5 + BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG = 0x1 + BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL = 0x2 + BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP = 0x4 ) const ( @@ -2681,6 +2735,7 @@ const ( RTNLGRP_IPV4_MROUTE_R = 0x1e RTNLGRP_IPV6_MROUTE_R = 0x1f RTNLGRP_NEXTHOP = 0x20 + RTNLGRP_BRVLAN = 0x21 ) type CapUserHeader struct { @@ -2775,132 +2830,317 @@ const ( ) const ( - DEVLINK_CMD_UNSPEC = 0x0 - DEVLINK_CMD_GET = 0x1 - DEVLINK_CMD_SET = 0x2 - DEVLINK_CMD_NEW = 0x3 - DEVLINK_CMD_DEL = 0x4 - DEVLINK_CMD_PORT_GET = 0x5 - DEVLINK_CMD_PORT_SET = 0x6 - DEVLINK_CMD_PORT_NEW = 0x7 - DEVLINK_CMD_PORT_DEL = 0x8 - DEVLINK_CMD_PORT_SPLIT = 0x9 - DEVLINK_CMD_PORT_UNSPLIT = 0xa - DEVLINK_CMD_SB_GET = 0xb - DEVLINK_CMD_SB_SET = 0xc - DEVLINK_CMD_SB_NEW = 0xd - DEVLINK_CMD_SB_DEL = 0xe - DEVLINK_CMD_SB_POOL_GET = 0xf - DEVLINK_CMD_SB_POOL_SET = 0x10 - DEVLINK_CMD_SB_POOL_NEW = 0x11 - DEVLINK_CMD_SB_POOL_DEL = 0x12 - DEVLINK_CMD_SB_PORT_POOL_GET = 0x13 - DEVLINK_CMD_SB_PORT_POOL_SET = 0x14 - DEVLINK_CMD_SB_PORT_POOL_NEW = 0x15 - DEVLINK_CMD_SB_PORT_POOL_DEL = 0x16 - DEVLINK_CMD_SB_TC_POOL_BIND_GET = 0x17 - DEVLINK_CMD_SB_TC_POOL_BIND_SET = 0x18 - DEVLINK_CMD_SB_TC_POOL_BIND_NEW = 0x19 - DEVLINK_CMD_SB_TC_POOL_BIND_DEL = 0x1a - DEVLINK_CMD_SB_OCC_SNAPSHOT = 0x1b - DEVLINK_CMD_SB_OCC_MAX_CLEAR = 0x1c - DEVLINK_CMD_ESWITCH_GET = 0x1d - DEVLINK_CMD_ESWITCH_SET = 0x1e - DEVLINK_CMD_DPIPE_TABLE_GET = 0x1f - DEVLINK_CMD_DPIPE_ENTRIES_GET = 0x20 - DEVLINK_CMD_DPIPE_HEADERS_GET = 0x21 - DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET = 0x22 - DEVLINK_CMD_MAX = 0x48 - DEVLINK_PORT_TYPE_NOTSET = 0x0 - DEVLINK_PORT_TYPE_AUTO = 0x1 - DEVLINK_PORT_TYPE_ETH = 0x2 - DEVLINK_PORT_TYPE_IB = 0x3 - DEVLINK_SB_POOL_TYPE_INGRESS = 0x0 - DEVLINK_SB_POOL_TYPE_EGRESS = 0x1 - DEVLINK_SB_THRESHOLD_TYPE_STATIC = 0x0 - DEVLINK_SB_THRESHOLD_TYPE_DYNAMIC = 0x1 - DEVLINK_ESWITCH_MODE_LEGACY = 0x0 - DEVLINK_ESWITCH_MODE_SWITCHDEV = 0x1 - DEVLINK_ESWITCH_INLINE_MODE_NONE = 0x0 - DEVLINK_ESWITCH_INLINE_MODE_LINK = 0x1 - DEVLINK_ESWITCH_INLINE_MODE_NETWORK = 0x2 - DEVLINK_ESWITCH_INLINE_MODE_TRANSPORT = 0x3 - DEVLINK_ESWITCH_ENCAP_MODE_NONE = 0x0 - DEVLINK_ESWITCH_ENCAP_MODE_BASIC = 0x1 - DEVLINK_ATTR_UNSPEC = 0x0 - DEVLINK_ATTR_BUS_NAME = 0x1 - DEVLINK_ATTR_DEV_NAME = 0x2 - DEVLINK_ATTR_PORT_INDEX = 0x3 - DEVLINK_ATTR_PORT_TYPE = 0x4 - DEVLINK_ATTR_PORT_DESIRED_TYPE = 0x5 - DEVLINK_ATTR_PORT_NETDEV_IFINDEX = 0x6 - DEVLINK_ATTR_PORT_NETDEV_NAME = 0x7 - DEVLINK_ATTR_PORT_IBDEV_NAME = 0x8 - DEVLINK_ATTR_PORT_SPLIT_COUNT = 0x9 - DEVLINK_ATTR_PORT_SPLIT_GROUP = 0xa - DEVLINK_ATTR_SB_INDEX = 0xb - DEVLINK_ATTR_SB_SIZE = 0xc - DEVLINK_ATTR_SB_INGRESS_POOL_COUNT = 0xd - DEVLINK_ATTR_SB_EGRESS_POOL_COUNT = 0xe - DEVLINK_ATTR_SB_INGRESS_TC_COUNT = 0xf - DEVLINK_ATTR_SB_EGRESS_TC_COUNT = 0x10 - DEVLINK_ATTR_SB_POOL_INDEX = 0x11 - DEVLINK_ATTR_SB_POOL_TYPE = 0x12 - DEVLINK_ATTR_SB_POOL_SIZE = 0x13 - DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE = 0x14 - DEVLINK_ATTR_SB_THRESHOLD = 0x15 - DEVLINK_ATTR_SB_TC_INDEX = 0x16 - DEVLINK_ATTR_SB_OCC_CUR = 0x17 - DEVLINK_ATTR_SB_OCC_MAX = 0x18 - DEVLINK_ATTR_ESWITCH_MODE = 0x19 - DEVLINK_ATTR_ESWITCH_INLINE_MODE = 0x1a - DEVLINK_ATTR_DPIPE_TABLES = 0x1b - DEVLINK_ATTR_DPIPE_TABLE = 0x1c - DEVLINK_ATTR_DPIPE_TABLE_NAME = 0x1d - DEVLINK_ATTR_DPIPE_TABLE_SIZE = 0x1e - DEVLINK_ATTR_DPIPE_TABLE_MATCHES = 0x1f - DEVLINK_ATTR_DPIPE_TABLE_ACTIONS = 0x20 - DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED = 0x21 - DEVLINK_ATTR_DPIPE_ENTRIES = 0x22 - DEVLINK_ATTR_DPIPE_ENTRY = 0x23 - DEVLINK_ATTR_DPIPE_ENTRY_INDEX = 0x24 - DEVLINK_ATTR_DPIPE_ENTRY_MATCH_VALUES = 0x25 - DEVLINK_ATTR_DPIPE_ENTRY_ACTION_VALUES = 0x26 - DEVLINK_ATTR_DPIPE_ENTRY_COUNTER = 0x27 - DEVLINK_ATTR_DPIPE_MATCH = 0x28 - DEVLINK_ATTR_DPIPE_MATCH_VALUE = 0x29 - DEVLINK_ATTR_DPIPE_MATCH_TYPE = 0x2a - DEVLINK_ATTR_DPIPE_ACTION = 0x2b - DEVLINK_ATTR_DPIPE_ACTION_VALUE = 0x2c - DEVLINK_ATTR_DPIPE_ACTION_TYPE = 0x2d - DEVLINK_ATTR_DPIPE_VALUE = 0x2e - DEVLINK_ATTR_DPIPE_VALUE_MASK = 0x2f - DEVLINK_ATTR_DPIPE_VALUE_MAPPING = 0x30 - DEVLINK_ATTR_DPIPE_HEADERS = 0x31 - DEVLINK_ATTR_DPIPE_HEADER = 0x32 - DEVLINK_ATTR_DPIPE_HEADER_NAME = 0x33 - DEVLINK_ATTR_DPIPE_HEADER_ID = 0x34 - DEVLINK_ATTR_DPIPE_HEADER_FIELDS = 0x35 - DEVLINK_ATTR_DPIPE_HEADER_GLOBAL = 0x36 - DEVLINK_ATTR_DPIPE_HEADER_INDEX = 0x37 - DEVLINK_ATTR_DPIPE_FIELD = 0x38 - DEVLINK_ATTR_DPIPE_FIELD_NAME = 0x39 - DEVLINK_ATTR_DPIPE_FIELD_ID = 0x3a - DEVLINK_ATTR_DPIPE_FIELD_BITWIDTH = 0x3b - DEVLINK_ATTR_DPIPE_FIELD_MAPPING_TYPE = 0x3c - DEVLINK_ATTR_PAD = 0x3d - DEVLINK_ATTR_ESWITCH_ENCAP_MODE = 0x3e - DEVLINK_ATTR_MAX = 0x94 - DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE = 0x0 - DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX = 0x1 - DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT = 0x0 - DEVLINK_DPIPE_ACTION_TYPE_FIELD_MODIFY = 0x0 - DEVLINK_DPIPE_FIELD_ETHERNET_DST_MAC = 0x0 - DEVLINK_DPIPE_FIELD_IPV4_DST_IP = 0x0 - DEVLINK_DPIPE_FIELD_IPV6_DST_IP = 0x0 - DEVLINK_DPIPE_HEADER_ETHERNET = 0x0 - DEVLINK_DPIPE_HEADER_IPV4 = 0x1 - DEVLINK_DPIPE_HEADER_IPV6 = 0x2 + DEVLINK_CMD_UNSPEC = 0x0 + DEVLINK_CMD_GET = 0x1 + DEVLINK_CMD_SET = 0x2 + DEVLINK_CMD_NEW = 0x3 + DEVLINK_CMD_DEL = 0x4 + DEVLINK_CMD_PORT_GET = 0x5 + DEVLINK_CMD_PORT_SET = 0x6 + DEVLINK_CMD_PORT_NEW = 0x7 + DEVLINK_CMD_PORT_DEL = 0x8 + DEVLINK_CMD_PORT_SPLIT = 0x9 + DEVLINK_CMD_PORT_UNSPLIT = 0xa + DEVLINK_CMD_SB_GET = 0xb + DEVLINK_CMD_SB_SET = 0xc + DEVLINK_CMD_SB_NEW = 0xd + DEVLINK_CMD_SB_DEL = 0xe + DEVLINK_CMD_SB_POOL_GET = 0xf + DEVLINK_CMD_SB_POOL_SET = 0x10 + DEVLINK_CMD_SB_POOL_NEW = 0x11 + DEVLINK_CMD_SB_POOL_DEL = 0x12 + DEVLINK_CMD_SB_PORT_POOL_GET = 0x13 + DEVLINK_CMD_SB_PORT_POOL_SET = 0x14 + DEVLINK_CMD_SB_PORT_POOL_NEW = 0x15 + DEVLINK_CMD_SB_PORT_POOL_DEL = 0x16 + DEVLINK_CMD_SB_TC_POOL_BIND_GET = 0x17 + DEVLINK_CMD_SB_TC_POOL_BIND_SET = 0x18 + DEVLINK_CMD_SB_TC_POOL_BIND_NEW = 0x19 + DEVLINK_CMD_SB_TC_POOL_BIND_DEL = 0x1a + DEVLINK_CMD_SB_OCC_SNAPSHOT = 0x1b + DEVLINK_CMD_SB_OCC_MAX_CLEAR = 0x1c + DEVLINK_CMD_ESWITCH_GET = 0x1d + DEVLINK_CMD_ESWITCH_SET = 0x1e + DEVLINK_CMD_DPIPE_TABLE_GET = 0x1f + DEVLINK_CMD_DPIPE_ENTRIES_GET = 0x20 + DEVLINK_CMD_DPIPE_HEADERS_GET = 0x21 + DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET = 0x22 + DEVLINK_CMD_RESOURCE_SET = 0x23 + DEVLINK_CMD_RESOURCE_DUMP = 0x24 + DEVLINK_CMD_RELOAD = 0x25 + DEVLINK_CMD_PARAM_GET = 0x26 + DEVLINK_CMD_PARAM_SET = 0x27 + DEVLINK_CMD_PARAM_NEW = 0x28 + DEVLINK_CMD_PARAM_DEL = 0x29 + DEVLINK_CMD_REGION_GET = 0x2a + DEVLINK_CMD_REGION_SET = 0x2b + DEVLINK_CMD_REGION_NEW = 0x2c + DEVLINK_CMD_REGION_DEL = 0x2d + DEVLINK_CMD_REGION_READ = 0x2e + DEVLINK_CMD_PORT_PARAM_GET = 0x2f + DEVLINK_CMD_PORT_PARAM_SET = 0x30 + DEVLINK_CMD_PORT_PARAM_NEW = 0x31 + DEVLINK_CMD_PORT_PARAM_DEL = 0x32 + DEVLINK_CMD_INFO_GET = 0x33 + DEVLINK_CMD_HEALTH_REPORTER_GET = 0x34 + DEVLINK_CMD_HEALTH_REPORTER_SET = 0x35 + DEVLINK_CMD_HEALTH_REPORTER_RECOVER = 0x36 + DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE = 0x37 + DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET = 0x38 + DEVLINK_CMD_HEALTH_REPORTER_DUMP_CLEAR = 0x39 + DEVLINK_CMD_FLASH_UPDATE = 0x3a + DEVLINK_CMD_FLASH_UPDATE_END = 0x3b + DEVLINK_CMD_FLASH_UPDATE_STATUS = 0x3c + DEVLINK_CMD_TRAP_GET = 0x3d + DEVLINK_CMD_TRAP_SET = 0x3e + DEVLINK_CMD_TRAP_NEW = 0x3f + DEVLINK_CMD_TRAP_DEL = 0x40 + DEVLINK_CMD_TRAP_GROUP_GET = 0x41 + DEVLINK_CMD_TRAP_GROUP_SET = 0x42 + DEVLINK_CMD_TRAP_GROUP_NEW = 0x43 + DEVLINK_CMD_TRAP_GROUP_DEL = 0x44 + DEVLINK_CMD_TRAP_POLICER_GET = 0x45 + DEVLINK_CMD_TRAP_POLICER_SET = 0x46 + DEVLINK_CMD_TRAP_POLICER_NEW = 0x47 + DEVLINK_CMD_TRAP_POLICER_DEL = 0x48 + DEVLINK_CMD_HEALTH_REPORTER_TEST = 0x49 + DEVLINK_CMD_MAX = 0x49 + DEVLINK_PORT_TYPE_NOTSET = 0x0 + DEVLINK_PORT_TYPE_AUTO = 0x1 + DEVLINK_PORT_TYPE_ETH = 0x2 + DEVLINK_PORT_TYPE_IB = 0x3 + DEVLINK_SB_POOL_TYPE_INGRESS = 0x0 + DEVLINK_SB_POOL_TYPE_EGRESS = 0x1 + DEVLINK_SB_THRESHOLD_TYPE_STATIC = 0x0 + DEVLINK_SB_THRESHOLD_TYPE_DYNAMIC = 0x1 + DEVLINK_ESWITCH_MODE_LEGACY = 0x0 + DEVLINK_ESWITCH_MODE_SWITCHDEV = 0x1 + DEVLINK_ESWITCH_INLINE_MODE_NONE = 0x0 + DEVLINK_ESWITCH_INLINE_MODE_LINK = 0x1 + DEVLINK_ESWITCH_INLINE_MODE_NETWORK = 0x2 + DEVLINK_ESWITCH_INLINE_MODE_TRANSPORT = 0x3 + DEVLINK_ESWITCH_ENCAP_MODE_NONE = 0x0 + DEVLINK_ESWITCH_ENCAP_MODE_BASIC = 0x1 + DEVLINK_PORT_FLAVOUR_PHYSICAL = 0x0 + DEVLINK_PORT_FLAVOUR_CPU = 0x1 + DEVLINK_PORT_FLAVOUR_DSA = 0x2 + DEVLINK_PORT_FLAVOUR_PCI_PF = 0x3 + DEVLINK_PORT_FLAVOUR_PCI_VF = 0x4 + DEVLINK_PORT_FLAVOUR_VIRTUAL = 0x5 + DEVLINK_PORT_FLAVOUR_UNUSED = 0x6 + DEVLINK_PARAM_CMODE_RUNTIME = 0x0 + DEVLINK_PARAM_CMODE_DRIVERINIT = 0x1 + DEVLINK_PARAM_CMODE_PERMANENT = 0x2 + DEVLINK_PARAM_CMODE_MAX = 0x2 + DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_DRIVER = 0x0 + DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_FLASH = 0x1 + DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_DISK = 0x2 + DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_UNKNOWN = 0x3 + DEVLINK_PARAM_RESET_DEV_ON_DRV_PROBE_VALUE_UNKNOWN = 0x0 + DEVLINK_PARAM_RESET_DEV_ON_DRV_PROBE_VALUE_ALWAYS = 0x1 + DEVLINK_PARAM_RESET_DEV_ON_DRV_PROBE_VALUE_NEVER = 0x2 + DEVLINK_PARAM_RESET_DEV_ON_DRV_PROBE_VALUE_DISK = 0x3 + DEVLINK_ATTR_STATS_RX_PACKETS = 0x0 + DEVLINK_ATTR_STATS_RX_BYTES = 0x1 + DEVLINK_ATTR_STATS_RX_DROPPED = 0x2 + DEVLINK_ATTR_STATS_MAX = 0x2 + DEVLINK_FLASH_OVERWRITE_SETTINGS_BIT = 0x0 + DEVLINK_FLASH_OVERWRITE_IDENTIFIERS_BIT = 0x1 + DEVLINK_FLASH_OVERWRITE_MAX_BIT = 0x1 + DEVLINK_TRAP_ACTION_DROP = 0x0 + DEVLINK_TRAP_ACTION_TRAP = 0x1 + DEVLINK_TRAP_ACTION_MIRROR = 0x2 + DEVLINK_TRAP_TYPE_DROP = 0x0 + DEVLINK_TRAP_TYPE_EXCEPTION = 0x1 + DEVLINK_TRAP_TYPE_CONTROL = 0x2 + DEVLINK_ATTR_TRAP_METADATA_TYPE_IN_PORT = 0x0 + DEVLINK_ATTR_TRAP_METADATA_TYPE_FA_COOKIE = 0x1 + DEVLINK_RELOAD_ACTION_UNSPEC = 0x0 + DEVLINK_RELOAD_ACTION_DRIVER_REINIT = 0x1 + DEVLINK_RELOAD_ACTION_FW_ACTIVATE = 0x2 + DEVLINK_RELOAD_ACTION_MAX = 0x2 + DEVLINK_RELOAD_LIMIT_UNSPEC = 0x0 + DEVLINK_RELOAD_LIMIT_NO_RESET = 0x1 + DEVLINK_RELOAD_LIMIT_MAX = 0x1 + DEVLINK_ATTR_UNSPEC = 0x0 + DEVLINK_ATTR_BUS_NAME = 0x1 + DEVLINK_ATTR_DEV_NAME = 0x2 + DEVLINK_ATTR_PORT_INDEX = 0x3 + DEVLINK_ATTR_PORT_TYPE = 0x4 + DEVLINK_ATTR_PORT_DESIRED_TYPE = 0x5 + DEVLINK_ATTR_PORT_NETDEV_IFINDEX = 0x6 + DEVLINK_ATTR_PORT_NETDEV_NAME = 0x7 + DEVLINK_ATTR_PORT_IBDEV_NAME = 0x8 + DEVLINK_ATTR_PORT_SPLIT_COUNT = 0x9 + DEVLINK_ATTR_PORT_SPLIT_GROUP = 0xa + DEVLINK_ATTR_SB_INDEX = 0xb + DEVLINK_ATTR_SB_SIZE = 0xc + DEVLINK_ATTR_SB_INGRESS_POOL_COUNT = 0xd + DEVLINK_ATTR_SB_EGRESS_POOL_COUNT = 0xe + DEVLINK_ATTR_SB_INGRESS_TC_COUNT = 0xf + DEVLINK_ATTR_SB_EGRESS_TC_COUNT = 0x10 + DEVLINK_ATTR_SB_POOL_INDEX = 0x11 + DEVLINK_ATTR_SB_POOL_TYPE = 0x12 + DEVLINK_ATTR_SB_POOL_SIZE = 0x13 + DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE = 0x14 + DEVLINK_ATTR_SB_THRESHOLD = 0x15 + DEVLINK_ATTR_SB_TC_INDEX = 0x16 + DEVLINK_ATTR_SB_OCC_CUR = 0x17 + DEVLINK_ATTR_SB_OCC_MAX = 0x18 + DEVLINK_ATTR_ESWITCH_MODE = 0x19 + DEVLINK_ATTR_ESWITCH_INLINE_MODE = 0x1a + DEVLINK_ATTR_DPIPE_TABLES = 0x1b + DEVLINK_ATTR_DPIPE_TABLE = 0x1c + DEVLINK_ATTR_DPIPE_TABLE_NAME = 0x1d + DEVLINK_ATTR_DPIPE_TABLE_SIZE = 0x1e + DEVLINK_ATTR_DPIPE_TABLE_MATCHES = 0x1f + DEVLINK_ATTR_DPIPE_TABLE_ACTIONS = 0x20 + DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED = 0x21 + DEVLINK_ATTR_DPIPE_ENTRIES = 0x22 + DEVLINK_ATTR_DPIPE_ENTRY = 0x23 + DEVLINK_ATTR_DPIPE_ENTRY_INDEX = 0x24 + DEVLINK_ATTR_DPIPE_ENTRY_MATCH_VALUES = 0x25 + DEVLINK_ATTR_DPIPE_ENTRY_ACTION_VALUES = 0x26 + DEVLINK_ATTR_DPIPE_ENTRY_COUNTER = 0x27 + DEVLINK_ATTR_DPIPE_MATCH = 0x28 + DEVLINK_ATTR_DPIPE_MATCH_VALUE = 0x29 + DEVLINK_ATTR_DPIPE_MATCH_TYPE = 0x2a + DEVLINK_ATTR_DPIPE_ACTION = 0x2b + DEVLINK_ATTR_DPIPE_ACTION_VALUE = 0x2c + DEVLINK_ATTR_DPIPE_ACTION_TYPE = 0x2d + DEVLINK_ATTR_DPIPE_VALUE = 0x2e + DEVLINK_ATTR_DPIPE_VALUE_MASK = 0x2f + DEVLINK_ATTR_DPIPE_VALUE_MAPPING = 0x30 + DEVLINK_ATTR_DPIPE_HEADERS = 0x31 + DEVLINK_ATTR_DPIPE_HEADER = 0x32 + DEVLINK_ATTR_DPIPE_HEADER_NAME = 0x33 + DEVLINK_ATTR_DPIPE_HEADER_ID = 0x34 + DEVLINK_ATTR_DPIPE_HEADER_FIELDS = 0x35 + DEVLINK_ATTR_DPIPE_HEADER_GLOBAL = 0x36 + DEVLINK_ATTR_DPIPE_HEADER_INDEX = 0x37 + DEVLINK_ATTR_DPIPE_FIELD = 0x38 + DEVLINK_ATTR_DPIPE_FIELD_NAME = 0x39 + DEVLINK_ATTR_DPIPE_FIELD_ID = 0x3a + DEVLINK_ATTR_DPIPE_FIELD_BITWIDTH = 0x3b + DEVLINK_ATTR_DPIPE_FIELD_MAPPING_TYPE = 0x3c + DEVLINK_ATTR_PAD = 0x3d + DEVLINK_ATTR_ESWITCH_ENCAP_MODE = 0x3e + DEVLINK_ATTR_RESOURCE_LIST = 0x3f + DEVLINK_ATTR_RESOURCE = 0x40 + DEVLINK_ATTR_RESOURCE_NAME = 0x41 + DEVLINK_ATTR_RESOURCE_ID = 0x42 + DEVLINK_ATTR_RESOURCE_SIZE = 0x43 + DEVLINK_ATTR_RESOURCE_SIZE_NEW = 0x44 + DEVLINK_ATTR_RESOURCE_SIZE_VALID = 0x45 + DEVLINK_ATTR_RESOURCE_SIZE_MIN = 0x46 + DEVLINK_ATTR_RESOURCE_SIZE_MAX = 0x47 + DEVLINK_ATTR_RESOURCE_SIZE_GRAN = 0x48 + DEVLINK_ATTR_RESOURCE_UNIT = 0x49 + DEVLINK_ATTR_RESOURCE_OCC = 0x4a + DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID = 0x4b + DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS = 0x4c + DEVLINK_ATTR_PORT_FLAVOUR = 0x4d + DEVLINK_ATTR_PORT_NUMBER = 0x4e + DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER = 0x4f + DEVLINK_ATTR_PARAM = 0x50 + DEVLINK_ATTR_PARAM_NAME = 0x51 + DEVLINK_ATTR_PARAM_GENERIC = 0x52 + DEVLINK_ATTR_PARAM_TYPE = 0x53 + DEVLINK_ATTR_PARAM_VALUES_LIST = 0x54 + DEVLINK_ATTR_PARAM_VALUE = 0x55 + DEVLINK_ATTR_PARAM_VALUE_DATA = 0x56 + DEVLINK_ATTR_PARAM_VALUE_CMODE = 0x57 + DEVLINK_ATTR_REGION_NAME = 0x58 + DEVLINK_ATTR_REGION_SIZE = 0x59 + DEVLINK_ATTR_REGION_SNAPSHOTS = 0x5a + DEVLINK_ATTR_REGION_SNAPSHOT = 0x5b + DEVLINK_ATTR_REGION_SNAPSHOT_ID = 0x5c + DEVLINK_ATTR_REGION_CHUNKS = 0x5d + DEVLINK_ATTR_REGION_CHUNK = 0x5e + DEVLINK_ATTR_REGION_CHUNK_DATA = 0x5f + DEVLINK_ATTR_REGION_CHUNK_ADDR = 0x60 + DEVLINK_ATTR_REGION_CHUNK_LEN = 0x61 + DEVLINK_ATTR_INFO_DRIVER_NAME = 0x62 + DEVLINK_ATTR_INFO_SERIAL_NUMBER = 0x63 + DEVLINK_ATTR_INFO_VERSION_FIXED = 0x64 + DEVLINK_ATTR_INFO_VERSION_RUNNING = 0x65 + DEVLINK_ATTR_INFO_VERSION_STORED = 0x66 + DEVLINK_ATTR_INFO_VERSION_NAME = 0x67 + DEVLINK_ATTR_INFO_VERSION_VALUE = 0x68 + DEVLINK_ATTR_SB_POOL_CELL_SIZE = 0x69 + DEVLINK_ATTR_FMSG = 0x6a + DEVLINK_ATTR_FMSG_OBJ_NEST_START = 0x6b + DEVLINK_ATTR_FMSG_PAIR_NEST_START = 0x6c + DEVLINK_ATTR_FMSG_ARR_NEST_START = 0x6d + DEVLINK_ATTR_FMSG_NEST_END = 0x6e + DEVLINK_ATTR_FMSG_OBJ_NAME = 0x6f + DEVLINK_ATTR_FMSG_OBJ_VALUE_TYPE = 0x70 + DEVLINK_ATTR_FMSG_OBJ_VALUE_DATA = 0x71 + DEVLINK_ATTR_HEALTH_REPORTER = 0x72 + DEVLINK_ATTR_HEALTH_REPORTER_NAME = 0x73 + DEVLINK_ATTR_HEALTH_REPORTER_STATE = 0x74 + DEVLINK_ATTR_HEALTH_REPORTER_ERR_COUNT = 0x75 + DEVLINK_ATTR_HEALTH_REPORTER_RECOVER_COUNT = 0x76 + DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS = 0x77 + DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD = 0x78 + DEVLINK_ATTR_HEALTH_REPORTER_AUTO_RECOVER = 0x79 + DEVLINK_ATTR_FLASH_UPDATE_FILE_NAME = 0x7a + DEVLINK_ATTR_FLASH_UPDATE_COMPONENT = 0x7b + DEVLINK_ATTR_FLASH_UPDATE_STATUS_MSG = 0x7c + DEVLINK_ATTR_FLASH_UPDATE_STATUS_DONE = 0x7d + DEVLINK_ATTR_FLASH_UPDATE_STATUS_TOTAL = 0x7e + DEVLINK_ATTR_PORT_PCI_PF_NUMBER = 0x7f + DEVLINK_ATTR_PORT_PCI_VF_NUMBER = 0x80 + DEVLINK_ATTR_STATS = 0x81 + DEVLINK_ATTR_TRAP_NAME = 0x82 + DEVLINK_ATTR_TRAP_ACTION = 0x83 + DEVLINK_ATTR_TRAP_TYPE = 0x84 + DEVLINK_ATTR_TRAP_GENERIC = 0x85 + DEVLINK_ATTR_TRAP_METADATA = 0x86 + DEVLINK_ATTR_TRAP_GROUP_NAME = 0x87 + DEVLINK_ATTR_RELOAD_FAILED = 0x88 + DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS_NS = 0x89 + DEVLINK_ATTR_NETNS_FD = 0x8a + DEVLINK_ATTR_NETNS_PID = 0x8b + DEVLINK_ATTR_NETNS_ID = 0x8c + DEVLINK_ATTR_HEALTH_REPORTER_AUTO_DUMP = 0x8d + DEVLINK_ATTR_TRAP_POLICER_ID = 0x8e + DEVLINK_ATTR_TRAP_POLICER_RATE = 0x8f + DEVLINK_ATTR_TRAP_POLICER_BURST = 0x90 + DEVLINK_ATTR_PORT_FUNCTION = 0x91 + DEVLINK_ATTR_INFO_BOARD_SERIAL_NUMBER = 0x92 + DEVLINK_ATTR_PORT_LANES = 0x93 + DEVLINK_ATTR_PORT_SPLITTABLE = 0x94 + DEVLINK_ATTR_PORT_EXTERNAL = 0x95 + DEVLINK_ATTR_PORT_CONTROLLER_NUMBER = 0x96 + DEVLINK_ATTR_FLASH_UPDATE_STATUS_TIMEOUT = 0x97 + DEVLINK_ATTR_FLASH_UPDATE_OVERWRITE_MASK = 0x98 + DEVLINK_ATTR_RELOAD_ACTION = 0x99 + DEVLINK_ATTR_RELOAD_ACTIONS_PERFORMED = 0x9a + DEVLINK_ATTR_RELOAD_LIMITS = 0x9b + DEVLINK_ATTR_DEV_STATS = 0x9c + DEVLINK_ATTR_RELOAD_STATS = 0x9d + DEVLINK_ATTR_RELOAD_STATS_ENTRY = 0x9e + DEVLINK_ATTR_RELOAD_STATS_LIMIT = 0x9f + DEVLINK_ATTR_RELOAD_STATS_VALUE = 0xa0 + DEVLINK_ATTR_REMOTE_RELOAD_STATS = 0xa1 + DEVLINK_ATTR_RELOAD_ACTION_INFO = 0xa2 + DEVLINK_ATTR_RELOAD_ACTION_STATS = 0xa3 + DEVLINK_ATTR_MAX = 0xa3 + DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE = 0x0 + DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX = 0x1 + DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT = 0x0 + DEVLINK_DPIPE_ACTION_TYPE_FIELD_MODIFY = 0x0 + DEVLINK_DPIPE_FIELD_ETHERNET_DST_MAC = 0x0 + DEVLINK_DPIPE_FIELD_IPV4_DST_IP = 0x0 + DEVLINK_DPIPE_FIELD_IPV6_DST_IP = 0x0 + DEVLINK_DPIPE_HEADER_ETHERNET = 0x0 + DEVLINK_DPIPE_HEADER_IPV4 = 0x1 + DEVLINK_DPIPE_HEADER_IPV6 = 0x2 + DEVLINK_RESOURCE_UNIT_ENTRY = 0x0 + DEVLINK_PORT_FUNCTION_ATTR_UNSPEC = 0x0 + DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR = 0x1 + DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x1 ) type FsverityDigest struct { @@ -2999,3 +3239,484 @@ const ( MPLS_IPTUNNEL_TTL = 0x2 MPLS_IPTUNNEL_MAX = 0x2 ) + +const ( + ETHTOOL_ID_UNSPEC = 0x0 + ETHTOOL_RX_COPYBREAK = 0x1 + ETHTOOL_TX_COPYBREAK = 0x2 + ETHTOOL_PFC_PREVENTION_TOUT = 0x3 + ETHTOOL_TUNABLE_UNSPEC = 0x0 + ETHTOOL_TUNABLE_U8 = 0x1 + ETHTOOL_TUNABLE_U16 = 0x2 + ETHTOOL_TUNABLE_U32 = 0x3 + ETHTOOL_TUNABLE_U64 = 0x4 + ETHTOOL_TUNABLE_STRING = 0x5 + ETHTOOL_TUNABLE_S8 = 0x6 + ETHTOOL_TUNABLE_S16 = 0x7 + ETHTOOL_TUNABLE_S32 = 0x8 + ETHTOOL_TUNABLE_S64 = 0x9 + ETHTOOL_PHY_ID_UNSPEC = 0x0 + ETHTOOL_PHY_DOWNSHIFT = 0x1 + ETHTOOL_PHY_FAST_LINK_DOWN = 0x2 + ETHTOOL_PHY_EDPD = 0x3 + ETHTOOL_LINK_EXT_STATE_AUTONEG = 0x0 + ETHTOOL_LINK_EXT_STATE_LINK_TRAINING_FAILURE = 0x1 + ETHTOOL_LINK_EXT_STATE_LINK_LOGICAL_MISMATCH = 0x2 + ETHTOOL_LINK_EXT_STATE_BAD_SIGNAL_INTEGRITY = 0x3 + ETHTOOL_LINK_EXT_STATE_NO_CABLE = 0x4 + ETHTOOL_LINK_EXT_STATE_CABLE_ISSUE = 0x5 + ETHTOOL_LINK_EXT_STATE_EEPROM_ISSUE = 0x6 + ETHTOOL_LINK_EXT_STATE_CALIBRATION_FAILURE = 0x7 + ETHTOOL_LINK_EXT_STATE_POWER_BUDGET_EXCEEDED = 0x8 + ETHTOOL_LINK_EXT_STATE_OVERHEAT = 0x9 + ETHTOOL_LINK_EXT_SUBSTATE_AN_NO_PARTNER_DETECTED = 0x1 + ETHTOOL_LINK_EXT_SUBSTATE_AN_ACK_NOT_RECEIVED = 0x2 + ETHTOOL_LINK_EXT_SUBSTATE_AN_NEXT_PAGE_EXCHANGE_FAILED = 0x3 + ETHTOOL_LINK_EXT_SUBSTATE_AN_NO_PARTNER_DETECTED_FORCE_MODE = 0x4 + ETHTOOL_LINK_EXT_SUBSTATE_AN_FEC_MISMATCH_DURING_OVERRIDE = 0x5 + ETHTOOL_LINK_EXT_SUBSTATE_AN_NO_HCD = 0x6 + ETHTOOL_LINK_EXT_SUBSTATE_LT_KR_FRAME_LOCK_NOT_ACQUIRED = 0x1 + ETHTOOL_LINK_EXT_SUBSTATE_LT_KR_LINK_INHIBIT_TIMEOUT = 0x2 + ETHTOOL_LINK_EXT_SUBSTATE_LT_KR_LINK_PARTNER_DID_NOT_SET_RECEIVER_READY = 0x3 + ETHTOOL_LINK_EXT_SUBSTATE_LT_REMOTE_FAULT = 0x4 + ETHTOOL_LINK_EXT_SUBSTATE_LLM_PCS_DID_NOT_ACQUIRE_BLOCK_LOCK = 0x1 + ETHTOOL_LINK_EXT_SUBSTATE_LLM_PCS_DID_NOT_ACQUIRE_AM_LOCK = 0x2 + ETHTOOL_LINK_EXT_SUBSTATE_LLM_PCS_DID_NOT_GET_ALIGN_STATUS = 0x3 + ETHTOOL_LINK_EXT_SUBSTATE_LLM_FC_FEC_IS_NOT_LOCKED = 0x4 + ETHTOOL_LINK_EXT_SUBSTATE_LLM_RS_FEC_IS_NOT_LOCKED = 0x5 + ETHTOOL_LINK_EXT_SUBSTATE_BSI_LARGE_NUMBER_OF_PHYSICAL_ERRORS = 0x1 + ETHTOOL_LINK_EXT_SUBSTATE_BSI_UNSUPPORTED_RATE = 0x2 + ETHTOOL_LINK_EXT_SUBSTATE_CI_UNSUPPORTED_CABLE = 0x1 + ETHTOOL_LINK_EXT_SUBSTATE_CI_CABLE_TEST_FAILURE = 0x2 + ETHTOOL_FLASH_ALL_REGIONS = 0x0 + ETHTOOL_F_UNSUPPORTED__BIT = 0x0 + ETHTOOL_F_WISH__BIT = 0x1 + ETHTOOL_F_COMPAT__BIT = 0x2 + ETHTOOL_FEC_NONE_BIT = 0x0 + ETHTOOL_FEC_AUTO_BIT = 0x1 + ETHTOOL_FEC_OFF_BIT = 0x2 + ETHTOOL_FEC_RS_BIT = 0x3 + ETHTOOL_FEC_BASER_BIT = 0x4 + ETHTOOL_FEC_LLRS_BIT = 0x5 + ETHTOOL_LINK_MODE_10baseT_Half_BIT = 0x0 + ETHTOOL_LINK_MODE_10baseT_Full_BIT = 0x1 + ETHTOOL_LINK_MODE_100baseT_Half_BIT = 0x2 + ETHTOOL_LINK_MODE_100baseT_Full_BIT = 0x3 + ETHTOOL_LINK_MODE_1000baseT_Half_BIT = 0x4 + ETHTOOL_LINK_MODE_1000baseT_Full_BIT = 0x5 + ETHTOOL_LINK_MODE_Autoneg_BIT = 0x6 + ETHTOOL_LINK_MODE_TP_BIT = 0x7 + ETHTOOL_LINK_MODE_AUI_BIT = 0x8 + ETHTOOL_LINK_MODE_MII_BIT = 0x9 + ETHTOOL_LINK_MODE_FIBRE_BIT = 0xa + ETHTOOL_LINK_MODE_BNC_BIT = 0xb + ETHTOOL_LINK_MODE_10000baseT_Full_BIT = 0xc + ETHTOOL_LINK_MODE_Pause_BIT = 0xd + ETHTOOL_LINK_MODE_Asym_Pause_BIT = 0xe + ETHTOOL_LINK_MODE_2500baseX_Full_BIT = 0xf + ETHTOOL_LINK_MODE_Backplane_BIT = 0x10 + ETHTOOL_LINK_MODE_1000baseKX_Full_BIT = 0x11 + ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT = 0x12 + ETHTOOL_LINK_MODE_10000baseKR_Full_BIT = 0x13 + ETHTOOL_LINK_MODE_10000baseR_FEC_BIT = 0x14 + ETHTOOL_LINK_MODE_20000baseMLD2_Full_BIT = 0x15 + ETHTOOL_LINK_MODE_20000baseKR2_Full_BIT = 0x16 + ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT = 0x17 + ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT = 0x18 + ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT = 0x19 + ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT = 0x1a + ETHTOOL_LINK_MODE_56000baseKR4_Full_BIT = 0x1b + ETHTOOL_LINK_MODE_56000baseCR4_Full_BIT = 0x1c + ETHTOOL_LINK_MODE_56000baseSR4_Full_BIT = 0x1d + ETHTOOL_LINK_MODE_56000baseLR4_Full_BIT = 0x1e + ETHTOOL_LINK_MODE_25000baseCR_Full_BIT = 0x1f + ETHTOOL_LINK_MODE_25000baseKR_Full_BIT = 0x20 + ETHTOOL_LINK_MODE_25000baseSR_Full_BIT = 0x21 + ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT = 0x22 + ETHTOOL_LINK_MODE_50000baseKR2_Full_BIT = 0x23 + ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT = 0x24 + ETHTOOL_LINK_MODE_100000baseSR4_Full_BIT = 0x25 + ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT = 0x26 + ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT = 0x27 + ETHTOOL_LINK_MODE_50000baseSR2_Full_BIT = 0x28 + ETHTOOL_LINK_MODE_1000baseX_Full_BIT = 0x29 + ETHTOOL_LINK_MODE_10000baseCR_Full_BIT = 0x2a + ETHTOOL_LINK_MODE_10000baseSR_Full_BIT = 0x2b + ETHTOOL_LINK_MODE_10000baseLR_Full_BIT = 0x2c + ETHTOOL_LINK_MODE_10000baseLRM_Full_BIT = 0x2d + ETHTOOL_LINK_MODE_10000baseER_Full_BIT = 0x2e + ETHTOOL_LINK_MODE_2500baseT_Full_BIT = 0x2f + ETHTOOL_LINK_MODE_5000baseT_Full_BIT = 0x30 + ETHTOOL_LINK_MODE_FEC_NONE_BIT = 0x31 + ETHTOOL_LINK_MODE_FEC_RS_BIT = 0x32 + ETHTOOL_LINK_MODE_FEC_BASER_BIT = 0x33 + ETHTOOL_LINK_MODE_50000baseKR_Full_BIT = 0x34 + ETHTOOL_LINK_MODE_50000baseSR_Full_BIT = 0x35 + ETHTOOL_LINK_MODE_50000baseCR_Full_BIT = 0x36 + ETHTOOL_LINK_MODE_50000baseLR_ER_FR_Full_BIT = 0x37 + ETHTOOL_LINK_MODE_50000baseDR_Full_BIT = 0x38 + ETHTOOL_LINK_MODE_100000baseKR2_Full_BIT = 0x39 + ETHTOOL_LINK_MODE_100000baseSR2_Full_BIT = 0x3a + ETHTOOL_LINK_MODE_100000baseCR2_Full_BIT = 0x3b + ETHTOOL_LINK_MODE_100000baseLR2_ER2_FR2_Full_BIT = 0x3c + ETHTOOL_LINK_MODE_100000baseDR2_Full_BIT = 0x3d + ETHTOOL_LINK_MODE_200000baseKR4_Full_BIT = 0x3e + ETHTOOL_LINK_MODE_200000baseSR4_Full_BIT = 0x3f + ETHTOOL_LINK_MODE_200000baseLR4_ER4_FR4_Full_BIT = 0x40 + ETHTOOL_LINK_MODE_200000baseDR4_Full_BIT = 0x41 + ETHTOOL_LINK_MODE_200000baseCR4_Full_BIT = 0x42 + ETHTOOL_LINK_MODE_100baseT1_Full_BIT = 0x43 + ETHTOOL_LINK_MODE_1000baseT1_Full_BIT = 0x44 + ETHTOOL_LINK_MODE_400000baseKR8_Full_BIT = 0x45 + ETHTOOL_LINK_MODE_400000baseSR8_Full_BIT = 0x46 + ETHTOOL_LINK_MODE_400000baseLR8_ER8_FR8_Full_BIT = 0x47 + ETHTOOL_LINK_MODE_400000baseDR8_Full_BIT = 0x48 + ETHTOOL_LINK_MODE_400000baseCR8_Full_BIT = 0x49 + ETHTOOL_LINK_MODE_FEC_LLRS_BIT = 0x4a + ETHTOOL_LINK_MODE_100000baseKR_Full_BIT = 0x4b + ETHTOOL_LINK_MODE_100000baseSR_Full_BIT = 0x4c + ETHTOOL_LINK_MODE_100000baseLR_ER_FR_Full_BIT = 0x4d + ETHTOOL_LINK_MODE_100000baseCR_Full_BIT = 0x4e + ETHTOOL_LINK_MODE_100000baseDR_Full_BIT = 0x4f + ETHTOOL_LINK_MODE_200000baseKR2_Full_BIT = 0x50 + ETHTOOL_LINK_MODE_200000baseSR2_Full_BIT = 0x51 + ETHTOOL_LINK_MODE_200000baseLR2_ER2_FR2_Full_BIT = 0x52 + ETHTOOL_LINK_MODE_200000baseDR2_Full_BIT = 0x53 + ETHTOOL_LINK_MODE_200000baseCR2_Full_BIT = 0x54 + ETHTOOL_LINK_MODE_400000baseKR4_Full_BIT = 0x55 + ETHTOOL_LINK_MODE_400000baseSR4_Full_BIT = 0x56 + ETHTOOL_LINK_MODE_400000baseLR4_ER4_FR4_Full_BIT = 0x57 + ETHTOOL_LINK_MODE_400000baseDR4_Full_BIT = 0x58 + ETHTOOL_LINK_MODE_400000baseCR4_Full_BIT = 0x59 + ETHTOOL_LINK_MODE_100baseFX_Half_BIT = 0x5a + ETHTOOL_LINK_MODE_100baseFX_Full_BIT = 0x5b + + ETHTOOL_MSG_USER_NONE = 0x0 + ETHTOOL_MSG_STRSET_GET = 0x1 + ETHTOOL_MSG_LINKINFO_GET = 0x2 + ETHTOOL_MSG_LINKINFO_SET = 0x3 + ETHTOOL_MSG_LINKMODES_GET = 0x4 + ETHTOOL_MSG_LINKMODES_SET = 0x5 + ETHTOOL_MSG_LINKSTATE_GET = 0x6 + ETHTOOL_MSG_DEBUG_GET = 0x7 + ETHTOOL_MSG_DEBUG_SET = 0x8 + ETHTOOL_MSG_WOL_GET = 0x9 + ETHTOOL_MSG_WOL_SET = 0xa + ETHTOOL_MSG_FEATURES_GET = 0xb + ETHTOOL_MSG_FEATURES_SET = 0xc + ETHTOOL_MSG_PRIVFLAGS_GET = 0xd + ETHTOOL_MSG_PRIVFLAGS_SET = 0xe + ETHTOOL_MSG_RINGS_GET = 0xf + ETHTOOL_MSG_RINGS_SET = 0x10 + ETHTOOL_MSG_CHANNELS_GET = 0x11 + ETHTOOL_MSG_CHANNELS_SET = 0x12 + ETHTOOL_MSG_COALESCE_GET = 0x13 + ETHTOOL_MSG_COALESCE_SET = 0x14 + ETHTOOL_MSG_PAUSE_GET = 0x15 + ETHTOOL_MSG_PAUSE_SET = 0x16 + ETHTOOL_MSG_EEE_GET = 0x17 + ETHTOOL_MSG_EEE_SET = 0x18 + ETHTOOL_MSG_TSINFO_GET = 0x19 + ETHTOOL_MSG_CABLE_TEST_ACT = 0x1a + ETHTOOL_MSG_CABLE_TEST_TDR_ACT = 0x1b + ETHTOOL_MSG_TUNNEL_INFO_GET = 0x1c + ETHTOOL_MSG_USER_MAX = 0x1c + ETHTOOL_MSG_KERNEL_NONE = 0x0 + ETHTOOL_MSG_STRSET_GET_REPLY = 0x1 + ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2 + ETHTOOL_MSG_LINKINFO_NTF = 0x3 + ETHTOOL_MSG_LINKMODES_GET_REPLY = 0x4 + ETHTOOL_MSG_LINKMODES_NTF = 0x5 + ETHTOOL_MSG_LINKSTATE_GET_REPLY = 0x6 + ETHTOOL_MSG_DEBUG_GET_REPLY = 0x7 + ETHTOOL_MSG_DEBUG_NTF = 0x8 + ETHTOOL_MSG_WOL_GET_REPLY = 0x9 + ETHTOOL_MSG_WOL_NTF = 0xa + ETHTOOL_MSG_FEATURES_GET_REPLY = 0xb + ETHTOOL_MSG_FEATURES_SET_REPLY = 0xc + ETHTOOL_MSG_FEATURES_NTF = 0xd + ETHTOOL_MSG_PRIVFLAGS_GET_REPLY = 0xe + ETHTOOL_MSG_PRIVFLAGS_NTF = 0xf + ETHTOOL_MSG_RINGS_GET_REPLY = 0x10 + ETHTOOL_MSG_RINGS_NTF = 0x11 + ETHTOOL_MSG_CHANNELS_GET_REPLY = 0x12 + ETHTOOL_MSG_CHANNELS_NTF = 0x13 + ETHTOOL_MSG_COALESCE_GET_REPLY = 0x14 + ETHTOOL_MSG_COALESCE_NTF = 0x15 + ETHTOOL_MSG_PAUSE_GET_REPLY = 0x16 + ETHTOOL_MSG_PAUSE_NTF = 0x17 + ETHTOOL_MSG_EEE_GET_REPLY = 0x18 + ETHTOOL_MSG_EEE_NTF = 0x19 + ETHTOOL_MSG_TSINFO_GET_REPLY = 0x1a + ETHTOOL_MSG_CABLE_TEST_NTF = 0x1b + ETHTOOL_MSG_CABLE_TEST_TDR_NTF = 0x1c + ETHTOOL_MSG_TUNNEL_INFO_GET_REPLY = 0x1d + ETHTOOL_MSG_KERNEL_MAX = 0x1d + ETHTOOL_A_HEADER_UNSPEC = 0x0 + ETHTOOL_A_HEADER_DEV_INDEX = 0x1 + ETHTOOL_A_HEADER_DEV_NAME = 0x2 + ETHTOOL_A_HEADER_FLAGS = 0x3 + ETHTOOL_A_HEADER_MAX = 0x3 + ETHTOOL_A_BITSET_BIT_UNSPEC = 0x0 + ETHTOOL_A_BITSET_BIT_INDEX = 0x1 + ETHTOOL_A_BITSET_BIT_NAME = 0x2 + ETHTOOL_A_BITSET_BIT_VALUE = 0x3 + ETHTOOL_A_BITSET_BIT_MAX = 0x3 + ETHTOOL_A_BITSET_BITS_UNSPEC = 0x0 + ETHTOOL_A_BITSET_BITS_BIT = 0x1 + ETHTOOL_A_BITSET_BITS_MAX = 0x1 + ETHTOOL_A_BITSET_UNSPEC = 0x0 + ETHTOOL_A_BITSET_NOMASK = 0x1 + ETHTOOL_A_BITSET_SIZE = 0x2 + ETHTOOL_A_BITSET_BITS = 0x3 + ETHTOOL_A_BITSET_VALUE = 0x4 + ETHTOOL_A_BITSET_MASK = 0x5 + ETHTOOL_A_BITSET_MAX = 0x5 + ETHTOOL_A_STRING_UNSPEC = 0x0 + ETHTOOL_A_STRING_INDEX = 0x1 + ETHTOOL_A_STRING_VALUE = 0x2 + ETHTOOL_A_STRING_MAX = 0x2 + ETHTOOL_A_STRINGS_UNSPEC = 0x0 + ETHTOOL_A_STRINGS_STRING = 0x1 + ETHTOOL_A_STRINGS_MAX = 0x1 + ETHTOOL_A_STRINGSET_UNSPEC = 0x0 + ETHTOOL_A_STRINGSET_ID = 0x1 + ETHTOOL_A_STRINGSET_COUNT = 0x2 + ETHTOOL_A_STRINGSET_STRINGS = 0x3 + ETHTOOL_A_STRINGSET_MAX = 0x3 + ETHTOOL_A_STRINGSETS_UNSPEC = 0x0 + ETHTOOL_A_STRINGSETS_STRINGSET = 0x1 + ETHTOOL_A_STRINGSETS_MAX = 0x1 + ETHTOOL_A_STRSET_UNSPEC = 0x0 + ETHTOOL_A_STRSET_HEADER = 0x1 + ETHTOOL_A_STRSET_STRINGSETS = 0x2 + ETHTOOL_A_STRSET_COUNTS_ONLY = 0x3 + ETHTOOL_A_STRSET_MAX = 0x3 + ETHTOOL_A_LINKINFO_UNSPEC = 0x0 + ETHTOOL_A_LINKINFO_HEADER = 0x1 + ETHTOOL_A_LINKINFO_PORT = 0x2 + ETHTOOL_A_LINKINFO_PHYADDR = 0x3 + ETHTOOL_A_LINKINFO_TP_MDIX = 0x4 + ETHTOOL_A_LINKINFO_TP_MDIX_CTRL = 0x5 + ETHTOOL_A_LINKINFO_TRANSCEIVER = 0x6 + ETHTOOL_A_LINKINFO_MAX = 0x6 + ETHTOOL_A_LINKMODES_UNSPEC = 0x0 + ETHTOOL_A_LINKMODES_HEADER = 0x1 + ETHTOOL_A_LINKMODES_AUTONEG = 0x2 + ETHTOOL_A_LINKMODES_OURS = 0x3 + ETHTOOL_A_LINKMODES_PEER = 0x4 + ETHTOOL_A_LINKMODES_SPEED = 0x5 + ETHTOOL_A_LINKMODES_DUPLEX = 0x6 + ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG = 0x7 + ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE = 0x8 + ETHTOOL_A_LINKMODES_MAX = 0x8 + ETHTOOL_A_LINKSTATE_UNSPEC = 0x0 + ETHTOOL_A_LINKSTATE_HEADER = 0x1 + ETHTOOL_A_LINKSTATE_LINK = 0x2 + ETHTOOL_A_LINKSTATE_SQI = 0x3 + ETHTOOL_A_LINKSTATE_SQI_MAX = 0x4 + ETHTOOL_A_LINKSTATE_EXT_STATE = 0x5 + ETHTOOL_A_LINKSTATE_EXT_SUBSTATE = 0x6 + ETHTOOL_A_LINKSTATE_MAX = 0x6 + ETHTOOL_A_DEBUG_UNSPEC = 0x0 + ETHTOOL_A_DEBUG_HEADER = 0x1 + ETHTOOL_A_DEBUG_MSGMASK = 0x2 + ETHTOOL_A_DEBUG_MAX = 0x2 + ETHTOOL_A_WOL_UNSPEC = 0x0 + ETHTOOL_A_WOL_HEADER = 0x1 + ETHTOOL_A_WOL_MODES = 0x2 + ETHTOOL_A_WOL_SOPASS = 0x3 + ETHTOOL_A_WOL_MAX = 0x3 + ETHTOOL_A_FEATURES_UNSPEC = 0x0 + ETHTOOL_A_FEATURES_HEADER = 0x1 + ETHTOOL_A_FEATURES_HW = 0x2 + ETHTOOL_A_FEATURES_WANTED = 0x3 + ETHTOOL_A_FEATURES_ACTIVE = 0x4 + ETHTOOL_A_FEATURES_NOCHANGE = 0x5 + ETHTOOL_A_FEATURES_MAX = 0x5 + ETHTOOL_A_PRIVFLAGS_UNSPEC = 0x0 + ETHTOOL_A_PRIVFLAGS_HEADER = 0x1 + ETHTOOL_A_PRIVFLAGS_FLAGS = 0x2 + ETHTOOL_A_PRIVFLAGS_MAX = 0x2 + ETHTOOL_A_RINGS_UNSPEC = 0x0 + ETHTOOL_A_RINGS_HEADER = 0x1 + ETHTOOL_A_RINGS_RX_MAX = 0x2 + ETHTOOL_A_RINGS_RX_MINI_MAX = 0x3 + ETHTOOL_A_RINGS_RX_JUMBO_MAX = 0x4 + ETHTOOL_A_RINGS_TX_MAX = 0x5 + ETHTOOL_A_RINGS_RX = 0x6 + ETHTOOL_A_RINGS_RX_MINI = 0x7 + ETHTOOL_A_RINGS_RX_JUMBO = 0x8 + ETHTOOL_A_RINGS_TX = 0x9 + ETHTOOL_A_RINGS_MAX = 0x9 + ETHTOOL_A_CHANNELS_UNSPEC = 0x0 + ETHTOOL_A_CHANNELS_HEADER = 0x1 + ETHTOOL_A_CHANNELS_RX_MAX = 0x2 + ETHTOOL_A_CHANNELS_TX_MAX = 0x3 + ETHTOOL_A_CHANNELS_OTHER_MAX = 0x4 + ETHTOOL_A_CHANNELS_COMBINED_MAX = 0x5 + ETHTOOL_A_CHANNELS_RX_COUNT = 0x6 + ETHTOOL_A_CHANNELS_TX_COUNT = 0x7 + ETHTOOL_A_CHANNELS_OTHER_COUNT = 0x8 + ETHTOOL_A_CHANNELS_COMBINED_COUNT = 0x9 + ETHTOOL_A_CHANNELS_MAX = 0x9 + ETHTOOL_A_COALESCE_UNSPEC = 0x0 + ETHTOOL_A_COALESCE_HEADER = 0x1 + ETHTOOL_A_COALESCE_RX_USECS = 0x2 + ETHTOOL_A_COALESCE_RX_MAX_FRAMES = 0x3 + ETHTOOL_A_COALESCE_RX_USECS_IRQ = 0x4 + ETHTOOL_A_COALESCE_RX_MAX_FRAMES_IRQ = 0x5 + ETHTOOL_A_COALESCE_TX_USECS = 0x6 + ETHTOOL_A_COALESCE_TX_MAX_FRAMES = 0x7 + ETHTOOL_A_COALESCE_TX_USECS_IRQ = 0x8 + ETHTOOL_A_COALESCE_TX_MAX_FRAMES_IRQ = 0x9 + ETHTOOL_A_COALESCE_STATS_BLOCK_USECS = 0xa + ETHTOOL_A_COALESCE_USE_ADAPTIVE_RX = 0xb + ETHTOOL_A_COALESCE_USE_ADAPTIVE_TX = 0xc + ETHTOOL_A_COALESCE_PKT_RATE_LOW = 0xd + ETHTOOL_A_COALESCE_RX_USECS_LOW = 0xe + ETHTOOL_A_COALESCE_RX_MAX_FRAMES_LOW = 0xf + ETHTOOL_A_COALESCE_TX_USECS_LOW = 0x10 + ETHTOOL_A_COALESCE_TX_MAX_FRAMES_LOW = 0x11 + ETHTOOL_A_COALESCE_PKT_RATE_HIGH = 0x12 + ETHTOOL_A_COALESCE_RX_USECS_HIGH = 0x13 + ETHTOOL_A_COALESCE_RX_MAX_FRAMES_HIGH = 0x14 + ETHTOOL_A_COALESCE_TX_USECS_HIGH = 0x15 + ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH = 0x16 + ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL = 0x17 + ETHTOOL_A_COALESCE_MAX = 0x17 + ETHTOOL_A_PAUSE_UNSPEC = 0x0 + ETHTOOL_A_PAUSE_HEADER = 0x1 + ETHTOOL_A_PAUSE_AUTONEG = 0x2 + ETHTOOL_A_PAUSE_RX = 0x3 + ETHTOOL_A_PAUSE_TX = 0x4 + ETHTOOL_A_PAUSE_STATS = 0x5 + ETHTOOL_A_PAUSE_MAX = 0x5 + ETHTOOL_A_PAUSE_STAT_UNSPEC = 0x0 + ETHTOOL_A_PAUSE_STAT_PAD = 0x1 + ETHTOOL_A_PAUSE_STAT_TX_FRAMES = 0x2 + ETHTOOL_A_PAUSE_STAT_RX_FRAMES = 0x3 + ETHTOOL_A_PAUSE_STAT_MAX = 0x3 + ETHTOOL_A_EEE_UNSPEC = 0x0 + ETHTOOL_A_EEE_HEADER = 0x1 + ETHTOOL_A_EEE_MODES_OURS = 0x2 + ETHTOOL_A_EEE_MODES_PEER = 0x3 + ETHTOOL_A_EEE_ACTIVE = 0x4 + ETHTOOL_A_EEE_ENABLED = 0x5 + ETHTOOL_A_EEE_TX_LPI_ENABLED = 0x6 + ETHTOOL_A_EEE_TX_LPI_TIMER = 0x7 + ETHTOOL_A_EEE_MAX = 0x7 + ETHTOOL_A_TSINFO_UNSPEC = 0x0 + ETHTOOL_A_TSINFO_HEADER = 0x1 + ETHTOOL_A_TSINFO_TIMESTAMPING = 0x2 + ETHTOOL_A_TSINFO_TX_TYPES = 0x3 + ETHTOOL_A_TSINFO_RX_FILTERS = 0x4 + ETHTOOL_A_TSINFO_PHC_INDEX = 0x5 + ETHTOOL_A_TSINFO_MAX = 0x5 + ETHTOOL_A_CABLE_TEST_UNSPEC = 0x0 + ETHTOOL_A_CABLE_TEST_HEADER = 0x1 + ETHTOOL_A_CABLE_TEST_MAX = 0x1 + ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC = 0x0 + ETHTOOL_A_CABLE_RESULT_CODE_OK = 0x1 + ETHTOOL_A_CABLE_RESULT_CODE_OPEN = 0x2 + ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT = 0x3 + ETHTOOL_A_CABLE_RESULT_CODE_CROSS_SHORT = 0x4 + ETHTOOL_A_CABLE_PAIR_A = 0x0 + ETHTOOL_A_CABLE_PAIR_B = 0x1 + ETHTOOL_A_CABLE_PAIR_C = 0x2 + ETHTOOL_A_CABLE_PAIR_D = 0x3 + ETHTOOL_A_CABLE_RESULT_UNSPEC = 0x0 + ETHTOOL_A_CABLE_RESULT_PAIR = 0x1 + ETHTOOL_A_CABLE_RESULT_CODE = 0x2 + ETHTOOL_A_CABLE_RESULT_MAX = 0x2 + ETHTOOL_A_CABLE_FAULT_LENGTH_UNSPEC = 0x0 + ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR = 0x1 + ETHTOOL_A_CABLE_FAULT_LENGTH_CM = 0x2 + ETHTOOL_A_CABLE_FAULT_LENGTH_MAX = 0x2 + ETHTOOL_A_CABLE_TEST_NTF_STATUS_UNSPEC = 0x0 + ETHTOOL_A_CABLE_TEST_NTF_STATUS_STARTED = 0x1 + ETHTOOL_A_CABLE_TEST_NTF_STATUS_COMPLETED = 0x2 + ETHTOOL_A_CABLE_NEST_UNSPEC = 0x0 + ETHTOOL_A_CABLE_NEST_RESULT = 0x1 + ETHTOOL_A_CABLE_NEST_FAULT_LENGTH = 0x2 + ETHTOOL_A_CABLE_NEST_MAX = 0x2 + ETHTOOL_A_CABLE_TEST_NTF_UNSPEC = 0x0 + ETHTOOL_A_CABLE_TEST_NTF_HEADER = 0x1 + ETHTOOL_A_CABLE_TEST_NTF_STATUS = 0x2 + ETHTOOL_A_CABLE_TEST_NTF_NEST = 0x3 + ETHTOOL_A_CABLE_TEST_NTF_MAX = 0x3 + ETHTOOL_A_CABLE_TEST_TDR_CFG_UNSPEC = 0x0 + ETHTOOL_A_CABLE_TEST_TDR_CFG_FIRST = 0x1 + ETHTOOL_A_CABLE_TEST_TDR_CFG_LAST = 0x2 + ETHTOOL_A_CABLE_TEST_TDR_CFG_STEP = 0x3 + ETHTOOL_A_CABLE_TEST_TDR_CFG_PAIR = 0x4 + ETHTOOL_A_CABLE_TEST_TDR_CFG_MAX = 0x4 + ETHTOOL_A_CABLE_TEST_TDR_UNSPEC = 0x0 + ETHTOOL_A_CABLE_TEST_TDR_HEADER = 0x1 + ETHTOOL_A_CABLE_TEST_TDR_CFG = 0x2 + ETHTOOL_A_CABLE_TEST_TDR_MAX = 0x2 + ETHTOOL_A_CABLE_AMPLITUDE_UNSPEC = 0x0 + ETHTOOL_A_CABLE_AMPLITUDE_PAIR = 0x1 + ETHTOOL_A_CABLE_AMPLITUDE_mV = 0x2 + ETHTOOL_A_CABLE_AMPLITUDE_MAX = 0x2 + ETHTOOL_A_CABLE_PULSE_UNSPEC = 0x0 + ETHTOOL_A_CABLE_PULSE_mV = 0x1 + ETHTOOL_A_CABLE_PULSE_MAX = 0x1 + ETHTOOL_A_CABLE_STEP_UNSPEC = 0x0 + ETHTOOL_A_CABLE_STEP_FIRST_DISTANCE = 0x1 + ETHTOOL_A_CABLE_STEP_LAST_DISTANCE = 0x2 + ETHTOOL_A_CABLE_STEP_STEP_DISTANCE = 0x3 + ETHTOOL_A_CABLE_STEP_MAX = 0x3 + ETHTOOL_A_CABLE_TDR_NEST_UNSPEC = 0x0 + ETHTOOL_A_CABLE_TDR_NEST_STEP = 0x1 + ETHTOOL_A_CABLE_TDR_NEST_AMPLITUDE = 0x2 + ETHTOOL_A_CABLE_TDR_NEST_PULSE = 0x3 + ETHTOOL_A_CABLE_TDR_NEST_MAX = 0x3 + ETHTOOL_A_CABLE_TEST_TDR_NTF_UNSPEC = 0x0 + ETHTOOL_A_CABLE_TEST_TDR_NTF_HEADER = 0x1 + ETHTOOL_A_CABLE_TEST_TDR_NTF_STATUS = 0x2 + ETHTOOL_A_CABLE_TEST_TDR_NTF_NEST = 0x3 + ETHTOOL_A_CABLE_TEST_TDR_NTF_MAX = 0x3 + ETHTOOL_UDP_TUNNEL_TYPE_VXLAN = 0x0 + ETHTOOL_UDP_TUNNEL_TYPE_GENEVE = 0x1 + ETHTOOL_UDP_TUNNEL_TYPE_VXLAN_GPE = 0x2 + ETHTOOL_A_TUNNEL_UDP_ENTRY_UNSPEC = 0x0 + ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT = 0x1 + ETHTOOL_A_TUNNEL_UDP_ENTRY_TYPE = 0x2 + ETHTOOL_A_TUNNEL_UDP_ENTRY_MAX = 0x2 + ETHTOOL_A_TUNNEL_UDP_TABLE_UNSPEC = 0x0 + ETHTOOL_A_TUNNEL_UDP_TABLE_SIZE = 0x1 + ETHTOOL_A_TUNNEL_UDP_TABLE_TYPES = 0x2 + ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY = 0x3 + ETHTOOL_A_TUNNEL_UDP_TABLE_MAX = 0x3 + ETHTOOL_A_TUNNEL_UDP_UNSPEC = 0x0 + ETHTOOL_A_TUNNEL_UDP_TABLE = 0x1 + ETHTOOL_A_TUNNEL_UDP_MAX = 0x1 + ETHTOOL_A_TUNNEL_INFO_UNSPEC = 0x0 + ETHTOOL_A_TUNNEL_INFO_HEADER = 0x1 + ETHTOOL_A_TUNNEL_INFO_UDP_PORTS = 0x2 + ETHTOOL_A_TUNNEL_INFO_MAX = 0x2 +) + +type ( + HIDRawReportDescriptor struct { + Size uint32 + Value [4096]uint8 + } + HIDRawDevInfo struct { + Bustype uint32 + Vendor int16 + Product int16 + } +) + +const ( + CLOSE_RANGE_UNSHARE = 0x2 + CLOSE_RANGE_CLOEXEC = 0x4 +) + +const ( + NLMSGERR_ATTR_MSG = 0x1 + NLMSGERR_ATTR_OFFS = 0x2 + NLMSGERR_ATTR_COOKIE = 0x3 +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go index d54618aa61f..4d4d283de5b 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go @@ -1,6 +1,7 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include -m32 linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include -m32 /build/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build 386 && linux // +build 386,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go index 741d25be957..8a2eed5ec4e 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go @@ -1,6 +1,7 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include -m64 linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include -m64 /build/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && linux // +build amd64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go index e8d982c3df7..94b34add643 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -1,6 +1,7 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm && linux // +build arm,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go index 311cf2155d5..2143de4d599 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go @@ -1,6 +1,7 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char /build/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm64 && linux // +build arm64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go index 1312bdf77fe..a40216eee60 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go @@ -1,6 +1,7 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build mips && linux // +build mips,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go index 2a993481950..e834b069fd5 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go @@ -1,6 +1,7 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build mips64 && linux // +build mips64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go index f964307b293..e31083b0489 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go @@ -1,6 +1,7 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build mips64le && linux // +build mips64le,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go index ca0fab27020..42811f7fb55 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go @@ -1,6 +1,7 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build mipsle && linux // +build mipsle,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go index 257e0042473..2a3afbaef9f 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go @@ -1,6 +1,7 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build ppc64 && linux // +build ppc64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go index 980dd31736a..c0de30a658a 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go @@ -1,6 +1,7 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build ppc64le && linux // +build ppc64le,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go index d9fdab20b83..74faf2e91fd 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go @@ -1,6 +1,7 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build riscv64 && linux // +build riscv64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go index c25de8c679c..9a8f0c2c6a3 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go @@ -1,6 +1,7 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char /build/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build s390x && linux // +build s390x,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go index 97fca65340e..72cdda75bde 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go @@ -1,6 +1,7 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build sparc64 && linux // +build sparc64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go index a89100c08ae..b10e73abf95 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go @@ -1,6 +1,7 @@ // cgo -godefs types_netbsd.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build 386 && netbsd // +build 386,netbsd package unix @@ -248,6 +249,7 @@ const ( SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x14 SizeofLinger = 0x8 + SizeofIovec = 0x8 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x1c diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go index 289184e0b3a..28ed6d55ae3 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go @@ -1,6 +1,7 @@ // cgo -godefs types_netbsd.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && netbsd // +build amd64,netbsd package unix @@ -255,6 +256,7 @@ const ( SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x14 SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x30 diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go index 428c450e4ce..4ba196ebe56 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go @@ -1,6 +1,7 @@ // cgo -godefs types_netbsd.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm && netbsd // +build arm,netbsd package unix @@ -253,6 +254,7 @@ const ( SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x14 SizeofLinger = 0x8 + SizeofIovec = 0x8 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x1c diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm64.go index 6f1f2842cc3..dd642bd9c87 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm64.go @@ -1,6 +1,7 @@ // cgo -godefs types_netbsd.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm64 && netbsd // +build arm64,netbsd package unix @@ -255,6 +256,7 @@ const ( SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x14 SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x30 diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go index 61ea0019a29..1fdb0e5fa5f 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go @@ -1,6 +1,7 @@ // cgo -godefs types_openbsd.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build 386 && openbsd // +build 386,openbsd package unix @@ -231,6 +232,7 @@ const ( SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x20 SizeofLinger = 0x8 + SizeofIovec = 0x8 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x1c diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go index 87a493f68fd..e2fc93c7c06 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go @@ -1,6 +1,7 @@ // cgo -godefs types_openbsd.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && openbsd // +build amd64,openbsd package unix @@ -235,6 +236,7 @@ const ( SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x20 SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x30 diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go index d80836efaba..8d34b5a2fc0 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go @@ -1,6 +1,7 @@ // cgo -godefs -- -fsigned-char types_openbsd.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm && openbsd // +build arm,openbsd package unix @@ -235,6 +236,7 @@ const ( SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x20 SizeofLinger = 0x8 + SizeofIovec = 0x8 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x1c diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go index 4e158746f11..ea8f1a0d9ba 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go @@ -1,6 +1,7 @@ // cgo -godefs -- -fsigned-char types_openbsd.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build arm64 && openbsd // +build arm64,openbsd package unix @@ -231,6 +232,7 @@ const ( SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x20 SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x30 diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go index 992a1f8c018..ec6e8bc3f13 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go @@ -1,6 +1,7 @@ // cgo -godefs -- -fsigned-char types_openbsd.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build mips64 && openbsd // +build mips64,openbsd package unix @@ -231,6 +232,7 @@ const ( SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x20 SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x30 diff --git a/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go index db817f3ba82..85effef9c19 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go @@ -1,6 +1,7 @@ // cgo -godefs types_solaris.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build amd64 && solaris // +build amd64,solaris package unix @@ -234,6 +235,7 @@ const ( SizeofSockaddrUnix = 0x6e SizeofSockaddrDatalink = 0xfc SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x30 diff --git a/vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go b/vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go new file mode 100644 index 00000000000..8bffde78e58 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go @@ -0,0 +1,402 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build zos && s390x +// +build zos,s390x + +// Hand edited based on ztypes_linux_s390x.go +// TODO: auto-generate. + +package unix + +const ( + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 + PathMax = 0x1000 +) + +const ( + SizeofSockaddrAny = 128 + SizeofCmsghdr = 12 + SizeofIPMreq = 8 + SizeofIPv6Mreq = 20 + SizeofICMPv6Filter = 32 + SizeofIPv6MTUInfo = 32 + SizeofLinger = 8 + SizeofSockaddrInet4 = 16 + SizeofSockaddrInet6 = 28 + SizeofTCPInfo = 0x68 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type timeval_zos struct { //correct (with padding and all) + Sec int64 + _ [4]byte // pad + Usec int32 +} + +type Tms struct { //clock_t is 4-byte unsigned int in zos + Utime uint32 + Stime uint32 + Cutime uint32 + Cstime uint32 +} + +type Time_t int64 + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + +type Utsname struct { + Sysname [65]byte + Nodename [65]byte + Release [65]byte + Version [65]byte + Machine [65]byte + Domainname [65]byte +} + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [108]int8 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]uint8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + _ [112]uint8 // pad +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Iov *Iovec + Control *byte + Flags int32 + Namelen int32 + Iovlen int32 + Controllen int32 +} + +type Cmsghdr struct { + Len int32 + Level int32 + Type int32 +} + +type Inet4Pktinfo struct { + Addr [4]byte /* in_addr */ + Ifindex uint32 +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Data [8]uint32 +} + +type TCPInfo struct { + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 +} + +type _Gid_t uint32 + +type rusage_zos struct { + Utime timeval_zos + Stime timeval_zos +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +// { int, short, short } in poll.h +type PollFd struct { + Fd int32 + Events int16 + Revents int16 +} + +type Stat_t struct { //Linux Definition + Dev uint64 + Ino uint64 + Nlink uint64 + Mode uint32 + Uid uint32 + Gid uint32 + _ int32 + Rdev uint64 + Size int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + Blksize int64 + Blocks int64 + _ [3]int64 +} + +type Stat_LE_t struct { + _ [4]byte // eye catcher + Length uint16 + Version uint16 + Mode int32 + Ino uint32 + Dev uint32 + Nlink int32 + Uid int32 + Gid int32 + Size int64 + Atim31 [4]byte + Mtim31 [4]byte + Ctim31 [4]byte + Rdev uint32 + Auditoraudit uint32 + Useraudit uint32 + Blksize int32 + Creatim31 [4]byte + AuditID [16]byte + _ [4]byte // rsrvd1 + File_tag struct { + Ccsid uint16 + Txtflag uint16 // aggregating Txflag:1 deferred:1 rsvflags:14 + } + CharsetID [8]byte + Blocks int64 + Genvalue uint32 + Reftim31 [4]byte + Fid [8]byte + Filefmt byte + Fspflag2 byte + _ [2]byte // rsrvd2 + Ctimemsec int32 + Seclabel [8]byte + _ [4]byte // rsrvd3 + _ [4]byte // rsrvd4 + Atim Time_t + Mtim Time_t + Ctim Time_t + Creatim Time_t + Reftim Time_t + _ [24]byte // rsrvd5 +} + +type Statvfs_t struct { + ID [4]byte + Len int32 + Bsize uint64 + Blocks uint64 + Usedspace uint64 + Bavail uint64 + Flag uint64 + Maxfilesize int64 + _ [16]byte + Frsize uint64 + Bfree uint64 + Files uint32 + Ffree uint32 + Favail uint32 + Namemax31 uint32 + Invarsec uint32 + _ [4]byte + Fsid uint64 + Namemax uint64 +} + +type Statfs_t struct { + Type uint32 + Bsize uint64 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint32 + Ffree uint32 + Fsid uint64 + Namelen uint64 + Frsize uint64 + Flags uint64 +} + +type Dirent struct { + Reclen uint16 + Namlen uint16 + Ino uint32 + Extra uintptr + Name [256]byte +} + +// This struct is packed on z/OS so it can't be used directly. +type Flock_t struct { + Type int16 + Whence int16 + Start int64 + Len int64 + Pid int32 +} + +type Termios struct { + Cflag uint32 + Iflag uint32 + Lflag uint32 + Oflag uint32 + Cc [11]uint8 +} + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} + +type W_Mnth struct { + Hid [4]byte + Size int32 + Cur1 int32 //32bit pointer + Cur2 int32 //^ + Devno uint32 + _ [4]byte +} + +type W_Mntent struct { + Fstype uint32 + Mode uint32 + Dev uint32 + Parentdev uint32 + Rootino uint32 + Status byte + Ddname [9]byte + Fstname [9]byte + Fsname [45]byte + Pathlen uint32 + Mountpoint [1024]byte + Jobname [8]byte + PID int32 + Parmoffset int32 + Parmlen int16 + Owner [8]byte + Quiesceowner [8]byte + _ [38]byte +} diff --git a/vendor/golang.org/x/sys/windows/dll_windows.go b/vendor/golang.org/x/sys/windows/dll_windows.go index 9cd147b7e3f..115341fba66 100644 --- a/vendor/golang.org/x/sys/windows/dll_windows.go +++ b/vendor/golang.org/x/sys/windows/dll_windows.go @@ -391,7 +391,6 @@ func loadLibraryEx(name string, system bool) (*DLL, error) { var flags uintptr if system { if canDoSearchSystem32() { - const LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800 flags = LOAD_LIBRARY_SEARCH_SYSTEM32 } else if isBaseName(name) { // WindowsXP or unpatched Windows machine diff --git a/vendor/golang.org/x/sys/windows/exec_windows.go b/vendor/golang.org/x/sys/windows/exec_windows.go index 3606c3a8b36..9eb1fb633a4 100644 --- a/vendor/golang.org/x/sys/windows/exec_windows.go +++ b/vendor/golang.org/x/sys/windows/exec_windows.go @@ -6,6 +6,11 @@ package windows +import ( + errorspkg "errors" + "unsafe" +) + // EscapeArg rewrites command line argument s as prescribed // in http://msdn.microsoft.com/en-us/library/ms880421. // This function returns "" (2 double quotes) if s is empty. @@ -95,3 +100,33 @@ func FullPath(name string) (path string, err error) { } } } + +// NewProcThreadAttributeList allocates a new ProcThreadAttributeList, with the requested maximum number of attributes. +func NewProcThreadAttributeList(maxAttrCount uint32) (*ProcThreadAttributeList, error) { + var size uintptr + err := initializeProcThreadAttributeList(nil, maxAttrCount, 0, &size) + if err != ERROR_INSUFFICIENT_BUFFER { + if err == nil { + return nil, errorspkg.New("unable to query buffer size from InitializeProcThreadAttributeList") + } + return nil, err + } + const psize = unsafe.Sizeof(uintptr(0)) + // size is guaranteed to be ≥1 by InitializeProcThreadAttributeList. + al := (*ProcThreadAttributeList)(unsafe.Pointer(&make([]unsafe.Pointer, (size+psize-1)/psize)[0])) + err = initializeProcThreadAttributeList(al, maxAttrCount, 0, &size) + if err != nil { + return nil, err + } + return al, err +} + +// Update modifies the ProcThreadAttributeList using UpdateProcThreadAttribute. +func (al *ProcThreadAttributeList) Update(attribute uintptr, flags uint32, value unsafe.Pointer, size uintptr, prevValue unsafe.Pointer, returnedSize *uintptr) error { + return updateProcThreadAttribute(al, flags, attribute, value, size, prevValue, returnedSize) +} + +// Delete frees ProcThreadAttributeList's resources. +func (al *ProcThreadAttributeList) Delete() { + deleteProcThreadAttributeList(al) +} diff --git a/vendor/golang.org/x/sys/windows/mkerrors.bash b/vendor/golang.org/x/sys/windows/mkerrors.bash index 2163843a11d..58e0188fb71 100644 --- a/vendor/golang.org/x/sys/windows/mkerrors.bash +++ b/vendor/golang.org/x/sys/windows/mkerrors.bash @@ -9,6 +9,8 @@ shopt -s nullglob winerror="$(printf '%s\n' "/mnt/c/Program Files (x86)/Windows Kits/"/*/Include/*/shared/winerror.h | sort -Vr | head -n 1)" [[ -n $winerror ]] || { echo "Unable to find winerror.h" >&2; exit 1; } +ntstatus="$(printf '%s\n' "/mnt/c/Program Files (x86)/Windows Kits/"/*/Include/*/shared/ntstatus.h | sort -Vr | head -n 1)" +[[ -n $ntstatus ]] || { echo "Unable to find ntstatus.h" >&2; exit 1; } declare -A errors @@ -59,5 +61,10 @@ declare -A errors echo "$key $vtype = $value" done < "$winerror" + while read -r line; do + [[ $line =~ ^#define\ (STATUS_[^\s]+)\ +\(\(NTSTATUS\)((0x)?[0-9a-fA-F]+)L?\) ]] || continue + echo "${BASH_REMATCH[1]} NTStatus = ${BASH_REMATCH[2]}" + done < "$ntstatus" + echo ")" } | gofmt > "zerrors_windows.go" diff --git a/vendor/golang.org/x/sys/windows/security_windows.go b/vendor/golang.org/x/sys/windows/security_windows.go index 14906485f3a..0e428ecbbde 100644 --- a/vendor/golang.org/x/sys/windows/security_windows.go +++ b/vendor/golang.org/x/sys/windows/security_windows.go @@ -624,6 +624,7 @@ func (tml *Tokenmandatorylabel) Size() uint32 { // Authorization Functions //sys checkTokenMembership(tokenHandle Token, sidToCheck *SID, isMember *int32) (err error) = advapi32.CheckTokenMembership +//sys isTokenRestricted(tokenHandle Token) (ret bool, err error) [!failretval] = advapi32.IsTokenRestricted //sys OpenProcessToken(process Handle, access uint32, token *Token) (err error) = advapi32.OpenProcessToken //sys OpenThreadToken(thread Handle, access uint32, openAsSelf bool, token *Token) (err error) = advapi32.OpenThreadToken //sys ImpersonateSelf(impersonationlevel uint32) (err error) = advapi32.ImpersonateSelf @@ -837,6 +838,16 @@ func (t Token) IsMember(sid *SID) (bool, error) { return b != 0, nil } +// IsRestricted reports whether the access token t is a restricted token. +func (t Token) IsRestricted() (isRestricted bool, err error) { + isRestricted, err = isTokenRestricted(t) + if !isRestricted && err == syscall.EINVAL { + // If err is EINVAL, this returned ERROR_SUCCESS indicating a non-restricted token. + err = nil + } + return +} + const ( WTS_CONSOLE_CONNECT = 0x1 WTS_CONSOLE_DISCONNECT = 0x2 @@ -897,6 +908,19 @@ type SECURITY_DESCRIPTOR struct { dacl *ACL } +type SECURITY_QUALITY_OF_SERVICE struct { + Length uint32 + ImpersonationLevel uint32 + ContextTrackingMode byte + EffectiveOnly byte +} + +// Constants for the ContextTrackingMode field of SECURITY_QUALITY_OF_SERVICE. +const ( + SECURITY_STATIC_TRACKING = 0 + SECURITY_DYNAMIC_TRACKING = 1 +) + type SecurityAttributes struct { Length uint32 SecurityDescriptor *SECURITY_DESCRIPTOR diff --git a/vendor/golang.org/x/sys/windows/service.go b/vendor/golang.org/x/sys/windows/service.go index f54ff90aacd..b269850d066 100644 --- a/vendor/golang.org/x/sys/windows/service.go +++ b/vendor/golang.org/x/sys/windows/service.go @@ -128,6 +128,10 @@ const ( SERVICE_NOTIFY_CREATED = 0x00000080 SERVICE_NOTIFY_DELETED = 0x00000100 SERVICE_NOTIFY_DELETE_PENDING = 0x00000200 + + SC_EVENT_DATABASE_CHANGE = 0 + SC_EVENT_PROPERTY_CHANGE = 1 + SC_EVENT_STATUS_CHANGE = 2 ) type SERVICE_STATUS struct { @@ -229,3 +233,5 @@ type QUERY_SERVICE_LOCK_STATUS struct { //sys EnumServicesStatusEx(mgr Handle, infoLevel uint32, serviceType uint32, serviceState uint32, services *byte, bufSize uint32, bytesNeeded *uint32, servicesReturned *uint32, resumeHandle *uint32, groupName *uint16) (err error) = advapi32.EnumServicesStatusExW //sys QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceStatusEx //sys NotifyServiceStatusChange(service Handle, notifyMask uint32, notifier *SERVICE_NOTIFY) (ret error) = advapi32.NotifyServiceStatusChangeW +//sys SubscribeServiceChangeNotifications(service Handle, eventType uint32, callback uintptr, callbackCtx uintptr, subscription *uintptr) (ret error) = sechost.SubscribeServiceChangeNotifications? +//sys UnsubscribeServiceChangeNotifications(subscription uintptr) = sechost.UnsubscribeServiceChangeNotifications? diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go index 86a46f7713a..bb6aaf89e47 100644 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -8,6 +8,8 @@ package windows import ( errorspkg "errors" + "fmt" + "runtime" "sync" "syscall" "time" @@ -18,9 +20,11 @@ import ( ) type Handle uintptr +type HWND uintptr const ( InvalidHandle = ^Handle(0) + InvalidHWND = ^HWND(0) // Flags for DefineDosDevice. DDD_EXACT_MATCH_ON_REMOVE = 0x00000004 @@ -63,9 +67,8 @@ const ( LOCKFILE_FAIL_IMMEDIATELY = 0x00000001 LOCKFILE_EXCLUSIVE_LOCK = 0x00000002 - // Return values of SleepEx and other APC functions - STATUS_USER_APC = 0x000000C0 - WAIT_IO_COMPLETION = STATUS_USER_APC + // Return value of SleepEx and other APC functions + WAIT_IO_COMPLETION = 0x000000C0 ) // StringToUTF16 is deprecated. Use UTF16FromString instead. @@ -170,12 +173,19 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys GetProcAddress(module Handle, procname string) (proc uintptr, err error) //sys GetModuleFileName(module Handle, filename *uint16, size uint32) (n uint32, err error) = kernel32.GetModuleFileNameW //sys GetModuleHandleEx(flags uint32, moduleName *uint16, module *Handle) (err error) = kernel32.GetModuleHandleExW +//sys SetDefaultDllDirectories(directoryFlags uint32) (err error) +//sys SetDllDirectory(path string) (err error) = kernel32.SetDllDirectoryW //sys GetVersion() (ver uint32, err error) //sys FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) = FormatMessageW //sys ExitProcess(exitcode uint32) //sys IsWow64Process(handle Handle, isWow64 *bool) (err error) = IsWow64Process //sys IsWow64Process2(handle Handle, processMachine *uint16, nativeMachine *uint16) (err error) = IsWow64Process2? //sys CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile Handle) (handle Handle, err error) [failretval==InvalidHandle] = CreateFileW +//sys CreateNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *SecurityAttributes) (handle Handle, err error) [failretval==InvalidHandle] = CreateNamedPipeW +//sys ConnectNamedPipe(pipe Handle, overlapped *Overlapped) (err error) +//sys GetNamedPipeInfo(pipe Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error) +//sys GetNamedPipeHandleState(pipe Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) = GetNamedPipeHandleStateW +//sys SetNamedPipeHandleState(pipe Handle, state *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32) (err error) = SetNamedPipeHandleState //sys ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) //sys WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) //sys GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) @@ -204,14 +214,21 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys GetSystemTimeAsFileTime(time *Filetime) //sys GetSystemTimePreciseAsFileTime(time *Filetime) //sys GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) [failretval==0xffffffff] -//sys CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) -//sys GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) -//sys PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) +//sys CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uintptr, threadcnt uint32) (handle Handle, err error) +//sys GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uintptr, overlapped **Overlapped, timeout uint32) (err error) +//sys PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uintptr, overlapped *Overlapped) (err error) //sys CancelIo(s Handle) (err error) //sys CancelIoEx(s Handle, o *Overlapped) (err error) //sys CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) = CreateProcessW +//sys initializeProcThreadAttributeList(attrlist *ProcThreadAttributeList, attrcount uint32, flags uint32, size *uintptr) (err error) = InitializeProcThreadAttributeList +//sys deleteProcThreadAttributeList(attrlist *ProcThreadAttributeList) = DeleteProcThreadAttributeList +//sys updateProcThreadAttribute(attrlist *ProcThreadAttributeList, flags uint32, attr uintptr, value unsafe.Pointer, size uintptr, prevvalue unsafe.Pointer, returnedsize *uintptr) (err error) = UpdateProcThreadAttribute //sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) //sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW +//sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId +//sys GetShellWindow() (shellWindow HWND) = user32.GetShellWindow +//sys MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW +//sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx //sys shGetKnownFolderPath(id *KNOWNFOLDERID, flags uint32, token Token, path **uint16) (ret error) = shell32.SHGetKnownFolderPath //sys TerminateProcess(handle Handle, exitcode uint32) (err error) //sys GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) @@ -240,13 +257,14 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys GetCommandLine() (cmd *uint16) = kernel32.GetCommandLineW //sys CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) [failretval==nil] = shell32.CommandLineToArgvW //sys LocalFree(hmem Handle) (handle Handle, err error) [failretval!=0] +//sys LocalAlloc(flags uint32, length uint32) (ptr uintptr, err error) //sys SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) //sys FlushFileBuffers(handle Handle) (err error) //sys GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) = kernel32.GetFullPathNameW //sys GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) = kernel32.GetLongPathNameW //sys GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) = kernel32.GetShortPathNameW //sys GetFinalPathNameByHandle(file Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) = kernel32.GetFinalPathNameByHandleW -//sys CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) = kernel32.CreateFileMappingW +//sys CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) [failretval == 0 || e1 == ERROR_ALREADY_EXISTS] = kernel32.CreateFileMappingW //sys MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) //sys UnmapViewOfFile(addr uintptr) (err error) //sys FlushViewOfFile(addr uintptr, length uintptr) (err error) @@ -257,22 +275,38 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) = kernel32.VirtualProtect //sys TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) = mswsock.TransmitFile //sys ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) = kernel32.ReadDirectoryChangesW +//sys FindFirstChangeNotification(path string, watchSubtree bool, notifyFilter uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.FindFirstChangeNotificationW +//sys FindNextChangeNotification(handle Handle) (err error) +//sys FindCloseChangeNotification(handle Handle) (err error) //sys CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) = crypt32.CertOpenSystemStoreW -//sys CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) [failretval==InvalidHandle] = crypt32.CertOpenStore +//sys CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) = crypt32.CertOpenStore //sys CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) [failretval==nil] = crypt32.CertEnumCertificatesInStore -//sys CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) = crypt32.CertAddCertificateContextToStore +//sys CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) = crypt32.CertAddCertificateContextToStore //sys CertCloseStore(store Handle, flags uint32) (err error) = crypt32.CertCloseStore //sys CertDeleteCertificateFromStore(certContext *CertContext) (err error) = crypt32.CertDeleteCertificateFromStore -//sys CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) = crypt32.CertGetCertificateChain -//sys CertFreeCertificateChain(ctx *CertChainContext) = crypt32.CertFreeCertificateChain -//sys CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) [failretval==nil] = crypt32.CertCreateCertificateContext -//sys CertFreeCertificateContext(ctx *CertContext) (err error) = crypt32.CertFreeCertificateContext -//sys CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) = crypt32.CertVerifyCertificateChainPolicy +//sys CertDuplicateCertificateContext(certContext *CertContext) (dupContext *CertContext) = crypt32.CertDuplicateCertificateContext +//sys PFXImportCertStore(pfx *CryptDataBlob, password *uint16, flags uint32) (store Handle, err error) = crypt32.PFXImportCertStore +//sys CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) = crypt32.CertGetCertificateChain +//sys CertFreeCertificateChain(ctx *CertChainContext) = crypt32.CertFreeCertificateChain +//sys CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) [failretval==nil] = crypt32.CertCreateCertificateContext +//sys CertFreeCertificateContext(ctx *CertContext) (err error) = crypt32.CertFreeCertificateContext +//sys CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) = crypt32.CertVerifyCertificateChainPolicy +//sys CertGetNameString(certContext *CertContext, nameType uint32, flags uint32, typePara unsafe.Pointer, name *uint16, size uint32) (chars uint32) = crypt32.CertGetNameStringW +//sys CertFindExtension(objId *byte, countExtensions uint32, extensions *CertExtension) (ret *CertExtension) = crypt32.CertFindExtension +//sys CertFindCertificateInStore(store Handle, certEncodingType uint32, findFlags uint32, findType uint32, findPara unsafe.Pointer, prevCertContext *CertContext) (cert *CertContext, err error) [failretval==nil] = crypt32.CertFindCertificateInStore +//sys CertFindChainInStore(store Handle, certEncodingType uint32, findFlags uint32, findType uint32, findPara unsafe.Pointer, prevChainContext *CertChainContext) (certchain *CertChainContext, err error) [failretval==nil] = crypt32.CertFindChainInStore +//sys CryptAcquireCertificatePrivateKey(cert *CertContext, flags uint32, parameters unsafe.Pointer, cryptProvOrNCryptKey *Handle, keySpec *uint32, callerFreeProvOrNCryptKey *bool) (err error) = crypt32.CryptAcquireCertificatePrivateKey +//sys CryptQueryObject(objectType uint32, object unsafe.Pointer, expectedContentTypeFlags uint32, expectedFormatTypeFlags uint32, flags uint32, msgAndCertEncodingType *uint32, contentType *uint32, formatType *uint32, certStore *Handle, msg *Handle, context *unsafe.Pointer) (err error) = crypt32.CryptQueryObject +//sys CryptDecodeObject(encodingType uint32, structType *byte, encodedBytes *byte, lenEncodedBytes uint32, flags uint32, decoded unsafe.Pointer, decodedLen *uint32) (err error) = crypt32.CryptDecodeObject +//sys CryptProtectData(dataIn *DataBlob, name *uint16, optionalEntropy *DataBlob, reserved uintptr, promptStruct *CryptProtectPromptStruct, flags uint32, dataOut *DataBlob) (err error) = crypt32.CryptProtectData +//sys CryptUnprotectData(dataIn *DataBlob, name **uint16, optionalEntropy *DataBlob, reserved uintptr, promptStruct *CryptProtectPromptStruct, flags uint32, dataOut *DataBlob) (err error) = crypt32.CryptUnprotectData +//sys WinVerifyTrustEx(hwnd HWND, actionId *GUID, data *WinTrustData) (ret error) = wintrust.WinVerifyTrustEx //sys RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) = advapi32.RegOpenKeyExW //sys RegCloseKey(key Handle) (regerrno error) = advapi32.RegCloseKey //sys RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *uint32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteTime *Filetime) (regerrno error) = advapi32.RegQueryInfoKeyW //sys RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) = advapi32.RegEnumKeyExW //sys RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) = advapi32.RegQueryValueExW +//sys RegNotifyChangeKeyValue(key Handle, watchSubtree bool, notifyFilter uint32, event Handle, asynchronous bool) (regerrno error) = advapi32.RegNotifyChangeKeyValue //sys GetCurrentProcessId() (pid uint32) = kernel32.GetCurrentProcessId //sys ProcessIdToSessionId(pid uint32, sessionid *uint32) (err error) = kernel32.ProcessIdToSessionId //sys GetConsoleMode(console Handle, mode *uint32) (err error) = kernel32.GetConsoleMode @@ -291,14 +325,14 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) [failretval&0xff==0] = CreateSymbolicLinkW //sys CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) [failretval&0xff==0] = CreateHardLinkW //sys GetCurrentThreadId() (id uint32) -//sys CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) = kernel32.CreateEventW -//sys CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) = kernel32.CreateEventExW +//sys CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) [failretval == 0 || e1 == ERROR_ALREADY_EXISTS] = kernel32.CreateEventW +//sys CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) [failretval == 0 || e1 == ERROR_ALREADY_EXISTS] = kernel32.CreateEventExW //sys OpenEvent(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) = kernel32.OpenEventW //sys SetEvent(event Handle) (err error) = kernel32.SetEvent //sys ResetEvent(event Handle) (err error) = kernel32.ResetEvent //sys PulseEvent(event Handle) (err error) = kernel32.PulseEvent -//sys CreateMutex(mutexAttrs *SecurityAttributes, initialOwner bool, name *uint16) (handle Handle, err error) = kernel32.CreateMutexW -//sys CreateMutexEx(mutexAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) = kernel32.CreateMutexExW +//sys CreateMutex(mutexAttrs *SecurityAttributes, initialOwner bool, name *uint16) (handle Handle, err error) [failretval == 0 || e1 == ERROR_ALREADY_EXISTS] = kernel32.CreateMutexW +//sys CreateMutexEx(mutexAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) [failretval == 0 || e1 == ERROR_ALREADY_EXISTS] = kernel32.CreateMutexExW //sys OpenMutex(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) = kernel32.OpenMutexW //sys ReleaseMutex(mutex Handle) (err error) = kernel32.ReleaseMutex //sys SleepEx(milliseconds uint32, alertable bool) (ret uint32) = kernel32.SleepEx @@ -313,10 +347,13 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error) //sys GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error) //sys GetProcessId(process Handle) (id uint32, err error) +//sys QueryFullProcessImageName(proc Handle, flags uint32, exeName *uint16, size *uint32) (err error) = kernel32.QueryFullProcessImageNameW //sys OpenThread(desiredAccess uint32, inheritHandle bool, threadId uint32) (handle Handle, err error) //sys SetProcessPriorityBoost(process Handle, disable bool) (err error) = kernel32.SetProcessPriorityBoost //sys GetProcessWorkingSetSizeEx(hProcess Handle, lpMinimumWorkingSetSize *uintptr, lpMaximumWorkingSetSize *uintptr, flags *uint32) //sys SetProcessWorkingSetSizeEx(hProcess Handle, dwMinimumWorkingSetSize uintptr, dwMaximumWorkingSetSize uintptr, flags uint32) (err error) +//sys GetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) +//sys SetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) // Volume Management Functions //sys DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) = DefineDosDeviceW @@ -339,8 +376,6 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) [failretval==0] = QueryDosDeviceW //sys SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) = SetVolumeLabelW //sys SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) = SetVolumeMountPointW -//sys MessageBox(hwnd Handle, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW -//sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx //sys InitiateSystemShutdownEx(machineName *uint16, message *uint16, timeout uint32, forceAppsClosed bool, rebootAfterShutdown bool, reason uint32) (err error) = advapi32.InitiateSystemShutdownExW //sys SetProcessShutdownParameters(level uint32, flags uint32) (err error) = kernel32.SetProcessShutdownParameters //sys GetProcessShutdownParameters(level *uint32, flags *uint32) (err error) = kernel32.GetProcessShutdownParameters @@ -348,16 +383,36 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys stringFromGUID2(rguid *GUID, lpsz *uint16, cchMax int32) (chars int32) = ole32.StringFromGUID2 //sys coCreateGuid(pguid *GUID) (ret error) = ole32.CoCreateGuid //sys CoTaskMemFree(address unsafe.Pointer) = ole32.CoTaskMemFree -//sys rtlGetVersion(info *OsVersionInfoEx) (ret error) = ntdll.RtlGetVersion -//sys rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) = ntdll.RtlGetNtVersionNumbers +//sys CoInitializeEx(reserved uintptr, coInit uint32) (ret error) = ole32.CoInitializeEx +//sys CoUninitialize() = ole32.CoUninitialize +//sys CoGetObject(name *uint16, bindOpts *BIND_OPTS3, guid *GUID, functionTable **uintptr) (ret error) = ole32.CoGetObject //sys getProcessPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetProcessPreferredUILanguages //sys getThreadPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetThreadPreferredUILanguages //sys getUserPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetUserPreferredUILanguages //sys getSystemPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetSystemPreferredUILanguages +//sys findResource(module Handle, name uintptr, resType uintptr) (resInfo Handle, err error) = kernel32.FindResourceW +//sys SizeofResource(module Handle, resInfo Handle) (size uint32, err error) = kernel32.SizeofResource +//sys LoadResource(module Handle, resInfo Handle) (resData Handle, err error) = kernel32.LoadResource +//sys LockResource(resData Handle) (addr uintptr, err error) = kernel32.LockResource // Process Status API (PSAPI) //sys EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) = psapi.EnumProcesses +// NT Native APIs +//sys rtlNtStatusToDosErrorNoTeb(ntstatus NTStatus) (ret syscall.Errno) = ntdll.RtlNtStatusToDosErrorNoTeb +//sys rtlGetVersion(info *OsVersionInfoEx) (ntstatus error) = ntdll.RtlGetVersion +//sys rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) = ntdll.RtlGetNtVersionNumbers +//sys RtlGetCurrentPeb() (peb *PEB) = ntdll.RtlGetCurrentPeb +//sys RtlInitUnicodeString(destinationString *NTUnicodeString, sourceString *uint16) = ntdll.RtlInitUnicodeString +//sys RtlInitString(destinationString *NTString, sourceString *byte) = ntdll.RtlInitString +//sys NtCreateFile(handle *Handle, access uint32, oa *OBJECT_ATTRIBUTES, iosb *IO_STATUS_BLOCK, allocationSize *int64, attributes uint32, share uint32, disposition uint32, options uint32, eabuffer uintptr, ealength uint32) (ntstatus error) = ntdll.NtCreateFile +//sys NtCreateNamedPipeFile(pipe *Handle, access uint32, oa *OBJECT_ATTRIBUTES, iosb *IO_STATUS_BLOCK, share uint32, disposition uint32, options uint32, typ uint32, readMode uint32, completionMode uint32, maxInstances uint32, inboundQuota uint32, outputQuota uint32, timeout *int64) (ntstatus error) = ntdll.NtCreateNamedPipeFile +//sys RtlDosPathNameToNtPathName(dosName *uint16, ntName *NTUnicodeString, ntFileNamePart *uint16, relativeName *RTL_RELATIVE_NAME) (ntstatus error) = ntdll.RtlDosPathNameToNtPathName_U_WithStatus +//sys RtlDosPathNameToRelativeNtPathName(dosName *uint16, ntName *NTUnicodeString, ntFileNamePart *uint16, relativeName *RTL_RELATIVE_NAME) (ntstatus error) = ntdll.RtlDosPathNameToRelativeNtPathName_U_WithStatus +//sys RtlDefaultNpAcl(acl **ACL) (ntstatus error) = ntdll.RtlDefaultNpAcl +//sys NtQueryInformationProcess(proc Handle, procInfoClass int32, procInfo unsafe.Pointer, procInfoLen uint32, retLen *uint32) (ntstatus error) = ntdll.NtQueryInformationProcess +//sys NtSetInformationProcess(proc Handle, procInfoClass int32, procInfo unsafe.Pointer, procInfoLen uint32) (ntstatus error) = ntdll.NtSetInformationProcess + // syscall interface implementation for other packages // GetCurrentProcess returns the handle for the current process. @@ -751,6 +806,7 @@ const socket_error = uintptr(^uint32(0)) //sys WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) [failretval==socket_error] = ws2_32.WSASend //sys WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) [failretval==socket_error] = ws2_32.WSARecvFrom //sys WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) [failretval==socket_error] = ws2_32.WSASendTo +//sys WSASocket(af int32, typ int32, protocol int32, protoInfo *WSAProtocolInfo, group uint32, flags uint32) (handle Handle, err error) [failretval==InvalidHandle] = ws2_32.WSASocketW //sys GetHostByName(name string) (h *Hostent, err error) [failretval==nil] = ws2_32.gethostbyname //sys GetServByName(name string, proto string) (s *Servent, err error) [failretval==nil] = ws2_32.getservbyname //sys Ntohs(netshort uint16) (u uint16) = ws2_32.ntohs @@ -764,6 +820,7 @@ const socket_error = uintptr(^uint32(0)) //sys GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) = iphlpapi.GetAdaptersInfo //sys SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) = kernel32.SetFileCompletionNotificationModes //sys WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) [failretval==-1] = ws2_32.WSAEnumProtocolsW +//sys WSAGetOverlappedResult(h Handle, o *Overlapped, bytes *uint32, wait bool, flags *uint32) (err error) = ws2_32.WSAGetOverlappedResult //sys GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) = iphlpapi.GetAdaptersAddresses //sys GetACP() (acp uint32) = kernel32.GetACP //sys MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) = kernel32.MultiByteToWideChar @@ -1486,3 +1543,129 @@ func getUILanguages(flags uint32, f func(flags uint32, numLanguages *uint32, buf func SetConsoleCursorPosition(console Handle, position Coord) error { return setConsoleCursorPosition(console, *((*uint32)(unsafe.Pointer(&position)))) } + +func (s NTStatus) Errno() syscall.Errno { + return rtlNtStatusToDosErrorNoTeb(s) +} + +func langID(pri, sub uint16) uint32 { return uint32(sub)<<10 | uint32(pri) } + +func (s NTStatus) Error() string { + b := make([]uint16, 300) + n, err := FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_FROM_HMODULE|FORMAT_MESSAGE_ARGUMENT_ARRAY, modntdll.Handle(), uint32(s), langID(LANG_ENGLISH, SUBLANG_ENGLISH_US), b, nil) + if err != nil { + return fmt.Sprintf("NTSTATUS 0x%08x", uint32(s)) + } + // trim terminating \r and \n + for ; n > 0 && (b[n-1] == '\n' || b[n-1] == '\r'); n-- { + } + return string(utf16.Decode(b[:n])) +} + +// NewNTUnicodeString returns a new NTUnicodeString structure for use with native +// NT APIs that work over the NTUnicodeString type. Note that most Windows APIs +// do not use NTUnicodeString, and instead UTF16PtrFromString should be used for +// the more common *uint16 string type. +func NewNTUnicodeString(s string) (*NTUnicodeString, error) { + var u NTUnicodeString + s16, err := UTF16PtrFromString(s) + if err != nil { + return nil, err + } + RtlInitUnicodeString(&u, s16) + return &u, nil +} + +// Slice returns a uint16 slice that aliases the data in the NTUnicodeString. +func (s *NTUnicodeString) Slice() []uint16 { + var slice []uint16 + hdr := (*unsafeheader.Slice)(unsafe.Pointer(&slice)) + hdr.Data = unsafe.Pointer(s.Buffer) + hdr.Len = int(s.Length) + hdr.Cap = int(s.MaximumLength) + return slice +} + +func (s *NTUnicodeString) String() string { + return UTF16ToString(s.Slice()) +} + +// NewNTString returns a new NTString structure for use with native +// NT APIs that work over the NTString type. Note that most Windows APIs +// do not use NTString, and instead UTF16PtrFromString should be used for +// the more common *uint16 string type. +func NewNTString(s string) (*NTString, error) { + var nts NTString + s8, err := BytePtrFromString(s) + if err != nil { + return nil, err + } + RtlInitString(&nts, s8) + return &nts, nil +} + +// Slice returns a byte slice that aliases the data in the NTString. +func (s *NTString) Slice() []byte { + var slice []byte + hdr := (*unsafeheader.Slice)(unsafe.Pointer(&slice)) + hdr.Data = unsafe.Pointer(s.Buffer) + hdr.Len = int(s.Length) + hdr.Cap = int(s.MaximumLength) + return slice +} + +func (s *NTString) String() string { + return ByteSliceToString(s.Slice()) +} + +// FindResource resolves a resource of the given name and resource type. +func FindResource(module Handle, name, resType ResourceIDOrString) (Handle, error) { + var namePtr, resTypePtr uintptr + var name16, resType16 *uint16 + var err error + resolvePtr := func(i interface{}, keep **uint16) (uintptr, error) { + switch v := i.(type) { + case string: + *keep, err = UTF16PtrFromString(v) + if err != nil { + return 0, err + } + return uintptr(unsafe.Pointer(*keep)), nil + case ResourceID: + return uintptr(v), nil + } + return 0, errorspkg.New("parameter must be a ResourceID or a string") + } + namePtr, err = resolvePtr(name, &name16) + if err != nil { + return 0, err + } + resTypePtr, err = resolvePtr(resType, &resType16) + if err != nil { + return 0, err + } + resInfo, err := findResource(module, namePtr, resTypePtr) + runtime.KeepAlive(name16) + runtime.KeepAlive(resType16) + return resInfo, err +} + +func LoadResourceData(module, resInfo Handle) (data []byte, err error) { + size, err := SizeofResource(module, resInfo) + if err != nil { + return + } + resData, err := LoadResource(module, resInfo) + if err != nil { + return + } + ptr, err := LockResource(resData) + if err != nil { + return + } + h := (*unsafeheader.Slice)(unsafe.Pointer(&data)) + h.Data = unsafe.Pointer(ptr) + h.Len = int(size) + h.Cap = int(size) + return +} diff --git a/vendor/golang.org/x/sys/windows/types_windows.go b/vendor/golang.org/x/sys/windows/types_windows.go index e7ae37f8848..23fe18ecef2 100644 --- a/vendor/golang.org/x/sys/windows/types_windows.go +++ b/vendor/golang.org/x/sys/windows/types_windows.go @@ -10,6 +10,10 @@ import ( "unsafe" ) +// NTStatus corresponds with NTSTATUS, error values returned by ntdll.dll and +// other native functions. +type NTStatus uint32 + const ( // Invented values to support what package os expects. O_RDONLY = 0x00000 @@ -215,6 +219,18 @@ const ( INHERIT_PARENT_AFFINITY = 0x00010000 ) +const ( + // attributes for ProcThreadAttributeList + PROC_THREAD_ATTRIBUTE_PARENT_PROCESS = 0x00020000 + PROC_THREAD_ATTRIBUTE_HANDLE_LIST = 0x00020002 + PROC_THREAD_ATTRIBUTE_GROUP_AFFINITY = 0x00030003 + PROC_THREAD_ATTRIBUTE_PREFERRED_NODE = 0x00020004 + PROC_THREAD_ATTRIBUTE_IDEAL_PROCESSOR = 0x00030005 + PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY = 0x00020007 + PROC_THREAD_ATTRIBUTE_UMS_THREAD = 0x00030006 + PROC_THREAD_ATTRIBUTE_PROTECTION_LEVEL = 0x0002000b +) + const ( // flags for CreateToolhelp32Snapshot TH32CS_SNAPHEAPLIST = 0x01 @@ -227,7 +243,7 @@ const ( ) const ( - // filters for ReadDirectoryChangesW + // filters for ReadDirectoryChangesW and FindFirstChangeNotificationW FILE_NOTIFY_CHANGE_FILE_NAME = 0x001 FILE_NOTIFY_CHANGE_DIR_NAME = 0x002 FILE_NOTIFY_CHANGE_ATTRIBUTES = 0x004 @@ -249,24 +265,27 @@ const ( const ( // wincrypt.h - PROV_RSA_FULL = 1 - PROV_RSA_SIG = 2 - PROV_DSS = 3 - PROV_FORTEZZA = 4 - PROV_MS_EXCHANGE = 5 - PROV_SSL = 6 - PROV_RSA_SCHANNEL = 12 - PROV_DSS_DH = 13 - PROV_EC_ECDSA_SIG = 14 - PROV_EC_ECNRA_SIG = 15 - PROV_EC_ECDSA_FULL = 16 - PROV_EC_ECNRA_FULL = 17 - PROV_DH_SCHANNEL = 18 - PROV_SPYRUS_LYNKS = 20 - PROV_RNG = 21 - PROV_INTEL_SEC = 22 - PROV_REPLACE_OWF = 23 - PROV_RSA_AES = 24 + /* certenrolld_begin -- PROV_RSA_*/ + PROV_RSA_FULL = 1 + PROV_RSA_SIG = 2 + PROV_DSS = 3 + PROV_FORTEZZA = 4 + PROV_MS_EXCHANGE = 5 + PROV_SSL = 6 + PROV_RSA_SCHANNEL = 12 + PROV_DSS_DH = 13 + PROV_EC_ECDSA_SIG = 14 + PROV_EC_ECNRA_SIG = 15 + PROV_EC_ECDSA_FULL = 16 + PROV_EC_ECNRA_FULL = 17 + PROV_DH_SCHANNEL = 18 + PROV_SPYRUS_LYNKS = 20 + PROV_RNG = 21 + PROV_INTEL_SEC = 22 + PROV_REPLACE_OWF = 23 + PROV_RSA_AES = 24 + + /* dwFlags definitions for CryptAcquireContext */ CRYPT_VERIFYCONTEXT = 0xF0000000 CRYPT_NEWKEYSET = 0x00000008 CRYPT_DELETEKEYSET = 0x00000010 @@ -274,6 +293,34 @@ const ( CRYPT_SILENT = 0x00000040 CRYPT_DEFAULT_CONTAINER_OPTIONAL = 0x00000080 + /* Flags for PFXImportCertStore */ + CRYPT_EXPORTABLE = 0x00000001 + CRYPT_USER_PROTECTED = 0x00000002 + CRYPT_USER_KEYSET = 0x00001000 + PKCS12_PREFER_CNG_KSP = 0x00000100 + PKCS12_ALWAYS_CNG_KSP = 0x00000200 + PKCS12_ALLOW_OVERWRITE_KEY = 0x00004000 + PKCS12_NO_PERSIST_KEY = 0x00008000 + PKCS12_INCLUDE_EXTENDED_PROPERTIES = 0x00000010 + + /* Flags for CryptAcquireCertificatePrivateKey */ + CRYPT_ACQUIRE_CACHE_FLAG = 0x00000001 + CRYPT_ACQUIRE_USE_PROV_INFO_FLAG = 0x00000002 + CRYPT_ACQUIRE_COMPARE_KEY_FLAG = 0x00000004 + CRYPT_ACQUIRE_NO_HEALING = 0x00000008 + CRYPT_ACQUIRE_SILENT_FLAG = 0x00000040 + CRYPT_ACQUIRE_WINDOW_HANDLE_FLAG = 0x00000080 + CRYPT_ACQUIRE_NCRYPT_KEY_FLAGS_MASK = 0x00070000 + CRYPT_ACQUIRE_ALLOW_NCRYPT_KEY_FLAG = 0x00010000 + CRYPT_ACQUIRE_PREFER_NCRYPT_KEY_FLAG = 0x00020000 + CRYPT_ACQUIRE_ONLY_NCRYPT_KEY_FLAG = 0x00040000 + + /* pdwKeySpec for CryptAcquireCertificatePrivateKey */ + AT_KEYEXCHANGE = 1 + AT_SIGNATURE = 2 + CERT_NCRYPT_KEY_SPEC = 0xFFFFFFFF + + /* Default usage match type is AND with value zero */ USAGE_MATCH_TYPE_AND = 0 USAGE_MATCH_TYPE_OR = 1 @@ -398,6 +445,89 @@ const ( CERT_TRUST_IS_CA_TRUSTED = 0x00004000 CERT_TRUST_IS_COMPLEX_CHAIN = 0x00010000 + /* Certificate Information Flags */ + CERT_INFO_VERSION_FLAG = 1 + CERT_INFO_SERIAL_NUMBER_FLAG = 2 + CERT_INFO_SIGNATURE_ALGORITHM_FLAG = 3 + CERT_INFO_ISSUER_FLAG = 4 + CERT_INFO_NOT_BEFORE_FLAG = 5 + CERT_INFO_NOT_AFTER_FLAG = 6 + CERT_INFO_SUBJECT_FLAG = 7 + CERT_INFO_SUBJECT_PUBLIC_KEY_INFO_FLAG = 8 + CERT_INFO_ISSUER_UNIQUE_ID_FLAG = 9 + CERT_INFO_SUBJECT_UNIQUE_ID_FLAG = 10 + CERT_INFO_EXTENSION_FLAG = 11 + + /* dwFindType for CertFindCertificateInStore */ + CERT_COMPARE_MASK = 0xFFFF + CERT_COMPARE_SHIFT = 16 + CERT_COMPARE_ANY = 0 + CERT_COMPARE_SHA1_HASH = 1 + CERT_COMPARE_NAME = 2 + CERT_COMPARE_ATTR = 3 + CERT_COMPARE_MD5_HASH = 4 + CERT_COMPARE_PROPERTY = 5 + CERT_COMPARE_PUBLIC_KEY = 6 + CERT_COMPARE_HASH = CERT_COMPARE_SHA1_HASH + CERT_COMPARE_NAME_STR_A = 7 + CERT_COMPARE_NAME_STR_W = 8 + CERT_COMPARE_KEY_SPEC = 9 + CERT_COMPARE_ENHKEY_USAGE = 10 + CERT_COMPARE_CTL_USAGE = CERT_COMPARE_ENHKEY_USAGE + CERT_COMPARE_SUBJECT_CERT = 11 + CERT_COMPARE_ISSUER_OF = 12 + CERT_COMPARE_EXISTING = 13 + CERT_COMPARE_SIGNATURE_HASH = 14 + CERT_COMPARE_KEY_IDENTIFIER = 15 + CERT_COMPARE_CERT_ID = 16 + CERT_COMPARE_CROSS_CERT_DIST_POINTS = 17 + CERT_COMPARE_PUBKEY_MD5_HASH = 18 + CERT_COMPARE_SUBJECT_INFO_ACCESS = 19 + CERT_COMPARE_HASH_STR = 20 + CERT_COMPARE_HAS_PRIVATE_KEY = 21 + CERT_FIND_ANY = (CERT_COMPARE_ANY << CERT_COMPARE_SHIFT) + CERT_FIND_SHA1_HASH = (CERT_COMPARE_SHA1_HASH << CERT_COMPARE_SHIFT) + CERT_FIND_MD5_HASH = (CERT_COMPARE_MD5_HASH << CERT_COMPARE_SHIFT) + CERT_FIND_SIGNATURE_HASH = (CERT_COMPARE_SIGNATURE_HASH << CERT_COMPARE_SHIFT) + CERT_FIND_KEY_IDENTIFIER = (CERT_COMPARE_KEY_IDENTIFIER << CERT_COMPARE_SHIFT) + CERT_FIND_HASH = CERT_FIND_SHA1_HASH + CERT_FIND_PROPERTY = (CERT_COMPARE_PROPERTY << CERT_COMPARE_SHIFT) + CERT_FIND_PUBLIC_KEY = (CERT_COMPARE_PUBLIC_KEY << CERT_COMPARE_SHIFT) + CERT_FIND_SUBJECT_NAME = (CERT_COMPARE_NAME<