diff --git a/README.md b/README.md index 1301123..795a9d9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # privacy +[![Go Report Card](https://goreportcard.com/badge/github.com/provideplatform/privacy)](https://goreportcard.com/report/github.com/provideplatform/privacy) + Microservice providing a circuit registry and compilation, trusted setup, verification and proving capabilities for zero-knowledge circuits. ## Supported Circuit Providers @@ -7,4 +9,7 @@ Microservice providing a circuit registry and compilation, trusted setup, verifi The following zkSNARK toolboxes are supported: - Gnark -- ZoKrates + +## Documentation + +See the privacy documentation [here](https://docs.provide.services/privacy). diff --git a/ceremony/ceremony.go b/ceremony/ceremony.go new file mode 100644 index 0000000..d6619bd --- /dev/null +++ b/ceremony/ceremony.go @@ -0,0 +1,199 @@ +package ceremony + +import ( + "bytes" + "encoding/hex" + "encoding/json" + "fmt" + "sort" + + "github.com/jinzhu/gorm" + provide "github.com/provideplatform/provide-go/api" + "github.com/provideplatform/provide-go/api/vault" + + dbconf "github.com/kthomas/go-db-config" + natsutil "github.com/kthomas/go-natsutil" + uuid "github.com/kthomas/go.uuid" + "github.com/provideplatform/privacy/common" +) + +const defaultWordSize = 32 + +// const ceremonyStatusComplete = "complete" +// const ceremonyStatusCreated = "created" +// const ceremonyStatusFailed = "failed" +// const ceremonyStatusInit = "init" +const ceremonyStatusPending = "pending" + +// CeremonyConfig +type CeremonyConfig struct { + Block *uint64 `json:"block"` // number of block being used for entropy + ExpectedEntropy int `json:"expected_entropy"` // expected number of bytes of entropy from all parties and any random beacon as required + WordSize int `json:"word_size"` +} + +// Ceremony model +type Ceremony struct { + provide.Model + + Config CeremonyConfig `json:"config"` + Parties []string `json:"parties"` + Status *string `json:"status"` + entropy []byte `json:"-"` + ownEntropy []byte `json:"-"` +} + +// AddParty creates a ceremony +func (c *Ceremony) AddParty(index int, other *Ceremony) error { + // TODO: receive entropy from other parties + if c.Config.WordSize != other.Config.WordSize { + return fmt.Errorf("other word size %d does not match expected word size %d", other.Config.WordSize, c.Config.WordSize) + } + + if len(other.ownEntropy) == 0 || bytes.Equal(other.ownEntropy, make([]byte, other.Config.WordSize)) { + return fmt.Errorf("other party ceremony has uninitialized entropy value") + } + + copy(c.entropy[index*c.Config.WordSize:], other.ownEntropy) + return nil +} + +// CeremonyFactory creates a new Ceremony object +func CeremonyFactory(parties []string, config *CeremonyConfig) *Ceremony { + ceremony := &Ceremony{ + Parties: parties, + Config: *config, + } + + sort.Strings(ceremony.Parties) + + if ceremony.Config.WordSize <= 0 { + ceremony.Config.WordSize = defaultWordSize + } + + if ceremony.Config.ExpectedEntropy <= 0 { + ceremony.Config.ExpectedEntropy = ceremony.Config.WordSize * (len(parties) + 1) + } + + ceremony.entropy = make([]byte, ceremony.Config.ExpectedEntropy) + + return ceremony +} + +// CompareEntropy compares entropy value to that of other Ceremony +func (c *Ceremony) CompareEntropy(other *Ceremony) bool { + return bytes.Equal(c.entropy, other.entropy) +} + +func (c *Ceremony) Create(variables interface{}) bool { + if !c.validate() { + return false + } + + db := dbconf.DatabaseConnection() + + if db.NewRecord(c) { + result := db.Create(&c) + rowsAffected := result.RowsAffected + errors := result.GetErrors() + if len(errors) > 0 { + for _, err := range errors { + c.Errors = append(c.Errors, &provide.Error{ + Message: common.StringOrNil(err.Error()), + }) + } + } + if !db.NewRecord(c) { + success := rowsAffected > 0 + if success { + payload, _ := json.Marshal(map[string]interface{}{ + "ceremony_id": c.ID.String(), + }) + natsutil.NatsStreamingPublish(natsCeremonyPendingSubject, payload) + c.updateStatus(db, ceremonyStatusPending, nil) + } + + return success + } + } + + return false +} + +// enrich the ceremony +func (c *Ceremony) enrich() error { + return nil +} + +// GenerateEntropy generates entropy at party index +func (c *Ceremony) GenerateEntropy() error { + entropy, err := common.RandomBytes(c.Config.WordSize) + if err != nil { + return fmt.Errorf("unable to generate entropy for mpc ceremony; %s", err.Error()) + } + + c.ownEntropy = entropy + + return nil +} + +// GetEntropyFromBeacon gets the requested entropy by block number +func (c *Ceremony) GetEntropyFromBeacon(block uint64) error { + + // TODO: get beacon entropy by block number, this will be same for all parties + entropy := []byte("test block entropy blahblahblah.") + + // insert block entropy at end + copy(c.entropy[len(c.entropy)-c.Config.WordSize:], entropy) + return nil +} + +// StoreEntropy stores entropy in vault +func (c *Ceremony) StoreEntropy(token, vaultID, name, description, secretType *string) (*uuid.UUID, error) { + // TODO: make sure entropy value has no uninitialized/all-zero words + + secret, err := vault.CreateSecret( + *token, + *vaultID, + hex.EncodeToString(c.entropy), + *name, + *description, + *secretType, + ) + if err != nil { + return nil, fmt.Errorf("failed to store entropy for ceremony %s in vault %s; %s", c.ID.String(), *vaultID, err.Error()) + } + return &secret.ID, nil +} + +// SubmitEntropy broadcasts entropy to other parties +func (c *Ceremony) SubmitEntropy() error { + // TODO: broadcast entropy to other parties + return nil +} + +// updateStatus updates the circuit status and optional description +func (c *Ceremony) updateStatus(db *gorm.DB, status string, description *string) error { + // FIXME-- use distributed lock here + c.Status = common.StringOrNil(status) + // c.Description = description + if !db.NewRecord(&c) { + result := db.Save(&c) + errors := result.GetErrors() + if len(errors) > 0 { + for _, err := range errors { + c.Errors = append(c.Errors, &provide.Error{ + Message: common.StringOrNil(err.Error()), + }) + } + return errors[0] + } + } + return nil +} + +func (c *Ceremony) validate() bool { + c.Errors = make([]*provide.Error, 0) + + return len(c.Errors) == 0 +} diff --git a/ceremony/consumer.go b/ceremony/consumer.go new file mode 100644 index 0000000..d249bda --- /dev/null +++ b/ceremony/consumer.go @@ -0,0 +1,244 @@ +package ceremony + +import ( + "encoding/json" + "fmt" + "sync" + "time" + + // vault "github.com/provideplatform/provide-go/api/vault" + + dbconf "github.com/kthomas/go-db-config" + natsutil "github.com/kthomas/go-natsutil" + uuid "github.com/kthomas/go.uuid" + "github.com/nats-io/nats.go" + "github.com/provideplatform/privacy/common" +) + +const defaultNatsStream = "privacy" + +const natsCeremonyPendingSubject = "privacy.ceremony.pending" +const ceremonyPendingAckWait = time.Second * 5 +const ceremonyPendingTimeout = int64(time.Minute * 1) +const ceremonyPendingMaxInFlight = 512 +const ceremonyPendingMaxDeliveries = 5 + +const natsCeremonyCompleteSubject = "privacy.ceremony.complete" +const ceremonyCompleteAckWait = time.Hour * 1 +const ceremonyCompleteTimeout = int64(time.Hour * 1) +const ceremonyCompleteMaxInFlight = 512 +const ceremonyCompleteMaxDeliveries = 5 + +const natsGenerateCeremonyEntropySubject = "privacy.ceremony.entropy.generate" +const ceremonyGenerateEntropyAckWait = time.Hour * 1 +const ceremonyGenerateEntropyTimeout = int64(time.Hour * 6) +const ceremonyGenerateEntropyMaxInFlight = 1024 + +func init() { + if !common.ConsumeNATSStreamingSubscriptions { + common.Log.Debug("ceremony package consumer configured to skip NATS streaming subscription setup") + return + } + + natsutil.EstablishSharedNatsConnection(nil) + natsutil.NatsCreateStream(defaultNatsStream, []string{ + fmt.Sprintf("%s.>", defaultNatsStream), + }) + + var waitGroup sync.WaitGroup + + createNatsCeremonyPendingSubscriptions(&waitGroup) +} + +func createNatsCeremonyPendingSubscriptions(wg *sync.WaitGroup) { + for i := uint64(0); i < natsutil.GetNatsConsumerConcurrency(); i++ { + natsutil.RequireNatsJetstreamSubscription(wg, + ceremonyPendingAckWait, + natsCeremonyPendingSubject, + natsCeremonyPendingSubject, + natsCeremonyPendingSubject, + consumeCeremonyPendingMsg, + ceremonyPendingAckWait, + ceremonyPendingMaxInFlight, + ceremonyPendingMaxDeliveries, + nil, + ) + } +} + +func createNatsCeremonyCompleteSubscriptions(wg *sync.WaitGroup) { + for i := uint64(0); i < natsutil.GetNatsConsumerConcurrency(); i++ { + natsutil.RequireNatsJetstreamSubscription(wg, + ceremonyPendingAckWait, + natsCeremonyCompleteSubject, + natsCeremonyCompleteSubject, + natsCeremonyCompleteSubject, + consumeCeremonyCompleteMsg, + ceremonyCompleteAckWait, + ceremonyCompleteMaxInFlight, + ceremonyCompleteMaxDeliveries, + nil, + ) + } +} + +func createNatsGenerateCeremonyEntropySubscriptions(wg *sync.WaitGroup) { + for i := uint64(0); i < natsutil.GetNatsConsumerConcurrency(); i++ { + natsutil.RequireNatsJetstreamSubscription(wg, + ceremonyGenerateEntropyAckWait, + natsGenerateCeremonyEntropySubject, + natsGenerateCeremonyEntropySubject, + natsGenerateCeremonyEntropySubject, + consumeCeremonyGenerateEntropyMsg, + ceremonyPendingAckWait, + ceremonyPendingMaxInFlight, + ceremonyPendingMaxDeliveries, + nil, + ) + } +} + +func consumeCeremonyPendingMsg(msg *nats.Msg) { + defer func() { + if r := recover(); r != nil { + common.Log.Warningf("recovered during pending ceremony state transition; %s", r) + msg.Nak() + } + }() + + common.Log.Debugf("consuming %d-byte NATS pending ceremony message on subject: %s", len(msg.Data), msg.Subject) + + params := map[string]interface{}{} + err := json.Unmarshal(msg.Data, ¶ms) + if err != nil { + common.Log.Warningf("failed to unmarshal pending ceremony message; %s", err.Error()) + msg.Nak() + return + } + + ceremonyID, ceremonyIDOk := params["ceremony_id"].(string) + if !ceremonyIDOk { + common.Log.Warning("failed to unmarshal ceremony_id during pending message message handler") + msg.Nak() + return + } + + db := dbconf.DatabaseConnection() + + ceremony := &Ceremony{} + db.Where("id = ?", ceremonyID).Find(&ceremony) + + if ceremony == nil || ceremony.ID == uuid.Nil { + common.Log.Warningf("failed to resolve ceremony during async pending message handler; ceremony id: %s", ceremonyID) + msg.Nak() + return + } + + err = ceremony.enrich() + if err != nil { + common.Log.Warningf("failed to enrich ceremony; %s", err.Error()) + } + + for _, party := range ceremony.Parties { + common.Log.Debugf("TODO-- dispatch point-to-point message to party: %s", string(party)) + } + + // FIXME... AttemptNack() if anything goes wrong in here... + msg.Ack() +} + +func consumeCeremonyCompleteMsg(msg *nats.Msg) { + defer func() { + if r := recover(); r != nil { + common.Log.Warningf("recovered during complete ceremony state transition; %s", r) + msg.Nak() + } + }() + + common.Log.Debugf("consuming %d-byte NATS complete ceremony message on subject: %s", len(msg.Data), msg.Subject) + + params := map[string]interface{}{} + err := json.Unmarshal(msg.Data, ¶ms) + if err != nil { + common.Log.Warningf("failed to unmarshal complete ceremony message; %s", err.Error()) + msg.Nak() + return + } + + ceremonyID, ceremonyIDOk := params["ceremony_id"].(string) + if !ceremonyIDOk { + common.Log.Warning("failed to unmarshal ceremony_id during complete message message handler") + msg.Nak() + return + } + + db := dbconf.DatabaseConnection() + + ceremony := &Ceremony{} + db.Where("id = ?", ceremonyID).Find(&ceremony) + + if ceremony == nil || ceremony.ID == uuid.Nil { + common.Log.Warningf("failed to resolve ceremony during async complete message handler; ceremony id: %s", ceremonyID) + msg.Nak() + return + } + + err = ceremony.enrich() + if err != nil { + common.Log.Warningf("failed to enrich ceremony; %s", err.Error()) + } + + common.Log.Debugf("TODO... sort %d parties alphanumerically and do something with the calculated entropy", len(ceremony.Parties)) + + // FIXME... AttemptNack() if anything goes wrong in here... + msg.Ack() +} + +func consumeCeremonyGenerateEntropyMsg(msg *nats.Msg) { + defer func() { + if r := recover(); r != nil { + common.Log.Warningf("recovered during ceremony entropy message transition; %s", r) + msg.Nak() + } + }() + + common.Log.Debugf("consuming %d-byte NATS ceremony entropy message on subject: %s", len(msg.Data), msg.Subject) + + params := map[string]interface{}{} + err := json.Unmarshal(msg.Data, ¶ms) + if err != nil { + common.Log.Warningf("failed to unmarshal ceremony entropy message; %s", err.Error()) + msg.Nak() + return + } + + ceremonyID, ceremonyIDOk := params["ceremony_id"].(string) + if !ceremonyIDOk { + common.Log.Warning("failed to unmarshal ceremony_id during entropy message handler") + msg.Nak() + return + } + + db := dbconf.DatabaseConnection() + + ceremony := &Ceremony{} + db.Where("id = ?", ceremonyID).Find(&ceremony) + + if ceremony == nil || ceremony.ID == uuid.Nil { + common.Log.Warningf("failed to resolve ceremony during async ceremony entropy handler; ceremony id: %s", ceremonyID) + msg.Nak() + return + } + + var entropy []byte + if err != nil { + common.Log.Warningf("failed to generate entropy for ceremony %s; %s", ceremony.ID, err.Error()) + } + + for _, party := range ceremony.Parties { + common.Log.Debugf("TODO-- dispatch point-to-point message to party %s to share our calculated %d-byte entropy", string(party), len(entropy)) + } + + // FIXME... AttemptNack() if anything goes wrong in here... + msg.Ack() +} diff --git a/circuit/circuit.go b/circuit/circuit.go index 55e6412..e4f1573 100644 --- a/circuit/circuit.go +++ b/circuit/circuit.go @@ -11,6 +11,9 @@ import ( "sync" "github.com/consensys/gnark-crypto/ecc" + "github.com/consensys/gnark-crypto/kzg" + "github.com/consensys/gnark/backend/plonk" + "github.com/consensys/gnark/frontend" "github.com/jinzhu/gorm" dbconf "github.com/kthomas/go-db-config" natsutil "github.com/kthomas/go-natsutil" @@ -23,6 +26,12 @@ import ( provide "github.com/provideplatform/provide-go/api" vault "github.com/provideplatform/provide-go/api/vault" util "github.com/provideplatform/provide-go/common/util" + + kzgbls12377 "github.com/consensys/gnark-crypto/ecc/bls12-377/fr/kzg" + kzgbls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381/fr/kzg" + kzgbls24315 "github.com/consensys/gnark-crypto/ecc/bls24-315/fr/kzg" + kzgbn254 "github.com/consensys/gnark-crypto/ecc/bn254/fr/kzg" + kzgbw6761 "github.com/consensys/gnark-crypto/ecc/bw6-761/fr/kzg" ) const circuitProvingSchemeGroth16 = "groth16" @@ -68,6 +77,9 @@ type Circuit struct { // SRS (structured reference string) is protocol-specific and may be nil depending on the proving scheme StructuredReferenceStringID *uuid.UUID `gorm:"column:srs_id" json:"srs_id,omitempty"` + // entropy is used for secure, deterministic setup of Plonk circuits + entropyID *uuid.UUID + // encrypted notes storage NoteStoreID *uuid.UUID `sql:"type:uuid" json:"note_store_id"` noteStore *storage.Store @@ -78,6 +90,7 @@ type Circuit struct { // ephemeral fields srs []byte + entropy []byte provingKey []byte verifyingKey []byte @@ -164,7 +177,21 @@ func (c *Circuit) Create(variables interface{}) bool { } } + common.Log.Debug("checking if srs is required") if c.srsRequired() { + common.Log.Debug("srs is required") + if c.srs == nil && c.entropyID != nil { + common.Log.Debug("need to generate srs") + err := c.generateSRS() + if err != nil { + common.Log.Errorf("failed to setup %s circuit with identifier %s; unable to generate SRS; %s", *c.ProvingScheme, *c.Identifier, err.Error()) + c.Errors = append(c.Errors, &provide.Error{ + Message: common.StringOrNil(fmt.Sprintf("failed to setup %s circuit with identifier %s; unable to generate SRS; %s", *c.ProvingScheme, *c.Identifier, err.Error())), + }) + return false + } + } + if c.srs == nil || len(c.srs) == 0 { c.Errors = append(c.Errors, &provide.Error{ Message: common.StringOrNil(fmt.Sprintf("failed to setup %s circuit with identifier %s; required SRS was not present", *c.ProvingScheme, *c.Identifier)), @@ -178,6 +205,8 @@ func (c *Circuit) Create(variables interface{}) bool { }) return false } + } else { + common.Log.Debug("srs is not required") } if c.setupRequired() { @@ -186,7 +215,7 @@ func (c *Circuit) Create(variables interface{}) bool { payload, _ := json.Marshal(map[string]interface{}{ "circuit_id": c.ID.String(), }) - natsutil.NatsStreamingPublish(natsCreatedCircuitSetupSubject, payload) + natsutil.NatsJetstreamPublish(natsCreatedCircuitSetupSubject, payload) } else if isImport { c.updateStatus(db, circuitStatusProvisioned, nil) } @@ -199,6 +228,28 @@ func (c *Circuit) Create(variables interface{}) bool { return false } +// getEntropy fetches entropy value from the configured vault instance +func (c *Circuit) getEntropy() error { + if (c.entropy == nil || len(c.entropy) == 0) && c.entropyID != nil { + secret, err := vault.FetchSecret( + util.DefaultVaultAccessJWT, + c.VaultID.String(), + c.entropyID.String(), + map[string]interface{}{}, + ) + if err != nil { + return err + } + c.entropy, err = hex.DecodeString(*secret.Value) + if err != nil { + common.Log.Warningf("failed to decode entropy secret from hex; %s", err.Error()) + return err + } + } + + return nil +} + // NoteStoreHeight returns the underlying note store height func (c *Circuit) NoteStoreHeight() (*int, error) { if c.noteStore == nil && c.NoteStoreID != nil { @@ -584,6 +635,76 @@ func (c *Circuit) exportVerifier() error { return nil } +// generateSRS enriches the ephemeral in-memory circuit SRS value; +// this method is deterministic per entropy +func (c *Circuit) generateSRS() error { + common.Log.Debug("attempting to generate srs") + if *c.ProvingScheme != circuitProvingSchemePlonk { + return fmt.Errorf("failed to read r1cs for circuit %s; invalid proving scheme %s", c.ID, *c.ProvingScheme) + } + + curveID := common.GnarkCurveIDFactory(c.Curve) + if curveID == ecc.UNKNOWN { + return fmt.Errorf("failed to read r1cs for circuit %s; invalid curve id %s", c.ID, *c.Curve) + } + + r1cs := plonk.NewCS(curveID) + + _, err := r1cs.ReadFrom(bytes.NewReader(c.Binary)) + if err != nil { + return fmt.Errorf("failed to read r1cs for circuit %s; %s", c.ID, err.Error()) + } + + srs, err := c.getKZGScheme(r1cs) + if err != nil { + return fmt.Errorf("failed to get srs for circuit %s; %s", c.ID, err.Error()) + } + + buf := new(bytes.Buffer) + _, err = srs.WriteTo(buf) + if err != nil { + return fmt.Errorf("failed to write srs for circuit %s; %s", c.ID, err.Error()) + } + + c.srs = buf.Bytes() + + return nil +} + +// getKZGScheme resolves the Kate-Zaverucha-Goldberg (KZG) constant-sized polynomial +// commitment scheme for the given ccs, using the ephemeral in-memory circuit alpha +func (c *Circuit) getKZGScheme(ccs frontend.CompiledConstraintSystem) (kzg.SRS, error) { + err := c.getEntropy() + if err != nil { + return nil, fmt.Errorf("failed to resolve KZG commitment scheme for circuit with identifier %s; %s", c.ID, err.Error()) + } + + alpha := new(big.Int).SetBytes(c.entropy) + nbConstraints := ccs.GetNbConstraints() + internal, secret, public := ccs.GetNbVariables() + nbVariables := internal + secret + public + kzgSize := uint64(nbVariables) + if nbConstraints > nbVariables { + kzgSize = uint64(nbConstraints) + } + kzgSize = ecc.NextPowerOfTwo(kzgSize) + 3 + + switch ccs.CurveID() { + case ecc.BN254: + return kzgbn254.NewSRS(kzgSize, alpha) + case ecc.BLS12_381: + return kzgbls12381.NewSRS(kzgSize, alpha) + case ecc.BLS12_377: + return kzgbls12377.NewSRS(kzgSize, alpha) + case ecc.BW6_761: + return kzgbw6761.NewSRS(kzgSize, alpha) + case ecc.BLS24_315: + return kzgbls24315.NewSRS(kzgSize, alpha) + default: + return nil, fmt.Errorf("failed to resolve KZG commitment scheme for circuit with identifier %s; unsupported curve type: %s", c.ID, ccs.CurveID().String()) + } +} + // importArtifacts attempts to import the circuit from existing artifacts func (c *Circuit) importArtifacts(db *gorm.DB) bool { if c.Artifacts == nil { @@ -993,7 +1114,7 @@ func (c *Circuit) updateState(proof string, witness map[string]interface{}) erro return err } - err = c.dispatchNotification(natsCircuitNotificationNoteDeposit) + _, err = c.dispatchNotification(natsCircuitNotificationNoteDeposit) if err != nil { common.Log.Warningf("failed to dispatch %s notification for circuit %s; %s", natsCircuitNotificationNoteDeposit, c.ID, err.Error()) } @@ -1039,7 +1160,7 @@ func (c *Circuit) updateState(proof string, witness map[string]interface{}) erro return err } - err = c.dispatchNotification(natsCircuitNotificationNoteNullified) + _, err = c.dispatchNotification(natsCircuitNotificationNoteNullified) if err != nil { common.Log.Warningf("failed to dispatch %s notification for circuit %s; %s", natsCircuitNotificationNoteNullified, c.ID, err.Error()) } @@ -1056,7 +1177,7 @@ func (c *Circuit) exit() error { var err error // TODO: check to ensure an exit is possible... - err = c.dispatchNotification(natsCircuitNotificationExit) + _, err = c.dispatchNotification(natsCircuitNotificationExit) if err != nil { common.Log.Warningf("failed to dispatch %s notification for circuit %s; %s", natsCircuitNotificationExit, c.ID, err.Error()) } diff --git a/circuit/consumer.go b/circuit/consumer.go index e978258..c162552 100644 --- a/circuit/consumer.go +++ b/circuit/consumer.go @@ -6,22 +6,21 @@ import ( "sync" "time" - // vault "github.com/provideplatform/provide-go/api/vault" - dbconf "github.com/kthomas/go-db-config" natsutil "github.com/kthomas/go-natsutil" uuid "github.com/kthomas/go.uuid" - stan "github.com/nats-io/stan.go" + "github.com/nats-io/nats.go" "github.com/provideplatform/privacy/common" ) +const defaultNatsStream = "privacy" + const natsCircuitSetupCompleteSubject = "privacy.circuit.setup.complete" const natsCircuitSetupFailedSubject = "privacy.circuit.setup.failed" const natsCreatedCircuitSetupSubject = "privacy.circuit.setup.pending" const natsCreatedCircuitSetupMaxInFlight = 32 const createCircuitAckWait = time.Hour * 1 -const createCircuitTimeout = int64(time.Hour * 1) func init() { if !common.ConsumeNATSStreamingSubscriptions { @@ -29,7 +28,10 @@ func init() { return } - natsutil.EstablishSharedNatsStreamingConnection(nil) + natsutil.EstablishSharedNatsConnection(nil) + natsutil.NatsCreateStream(defaultNatsStream, []string{ + fmt.Sprintf("%s.>", defaultNatsStream), + }) var waitGroup sync.WaitGroup @@ -38,7 +40,7 @@ func init() { func createNatsCircuitSetupSubscriptions(wg *sync.WaitGroup) { for i := uint64(0); i < natsutil.GetNatsConsumerConcurrency(); i++ { - natsutil.RequireNatsStreamingSubscription(wg, + natsutil.RequireNatsJetstreamSubscription(wg, createCircuitAckWait, natsCreatedCircuitSetupSubject, natsCreatedCircuitSetupSubject, @@ -50,28 +52,28 @@ func createNatsCircuitSetupSubscriptions(wg *sync.WaitGroup) { } } -func consumeCircuitSetupMsg(msg *stan.Msg) { +func consumeCircuitSetupMsg(msg *nats.Msg) { defer func() { if r := recover(); r != nil { common.Log.Warningf("recovered during circuit setup; %s", r) - natsutil.AttemptNack(msg, createCircuitTimeout) + msg.Nak() } }() - common.Log.Debugf("consuming %d-byte NATS circuit setup message on subject: %s", msg.Size(), msg.Subject) + common.Log.Debugf("consuming %d-byte NATS circuit setup message on subject: %s", len(msg.Data), msg.Subject) params := map[string]interface{}{} err := json.Unmarshal(msg.Data, ¶ms) if err != nil { common.Log.Warningf("failed to unmarshal circuit setup message; %s", err.Error()) - natsutil.Nack(msg) + msg.Nak() return } circuitID, circuitIDOk := params["circuit_id"].(string) if !circuitIDOk { common.Log.Warning("failed to unmarshal circuit_id during setup message handler") - natsutil.Nack(msg) + msg.Nak() return } @@ -82,7 +84,7 @@ func consumeCircuitSetupMsg(msg *stan.Msg) { if circuit == nil || circuit.ID == uuid.Nil { common.Log.Warningf("failed to resolve circuit during async setup; circuit id: %s", circuitID) - natsutil.AttemptNack(msg, createCircuitTimeout) + msg.Nak() return } @@ -94,13 +96,13 @@ func consumeCircuitSetupMsg(msg *stan.Msg) { if circuit.setup(db) { common.Log.Debugf("setup completed for circuit: %s", circuit.ID) circuit.updateStatus(db, circuitStatusProvisioned, nil) - natsutil.NatsStreamingPublish(natsCircuitSetupCompleteSubject, msg.Data) + natsutil.NatsJetstreamPublish(natsCircuitSetupCompleteSubject, msg.Data) msg.Ack() } else { common.Log.Warningf("setup failed for circuit: %s", circuit.ID) err = fmt.Errorf("unspecified error") circuit.updateStatus(db, circuitStatusFailed, common.StringOrNil(err.Error())) - natsutil.NatsStreamingPublish(natsCircuitSetupFailedSubject, msg.Data) - natsutil.AttemptNack(msg, createCircuitTimeout) + natsutil.NatsJetstreamPublish(natsCircuitSetupFailedSubject, msg.Data) + msg.Nak() } } diff --git a/circuit/handlers.go b/circuit/handlers.go index 63c7539..c6319eb 100644 --- a/circuit/handlers.go +++ b/circuit/handlers.go @@ -118,6 +118,15 @@ func createCircuitHandler(c *gin.Context) { } } + if entropyIDString, ok := params["entropy_id"].(string); ok { + entropyID, err := uuid.FromString(entropyIDString) + if err != nil { + provide.RenderError(err.Error(), 422, c) + return + } + circuit.entropyID = &entropyID + } + variables := params["variables"] if circuit.Create(variables) { diff --git a/circuit/notifications.go b/circuit/notifications.go index 956f476..a9e9e7d 100644 --- a/circuit/notifications.go +++ b/circuit/notifications.go @@ -5,6 +5,7 @@ import ( "fmt" natsutil "github.com/kthomas/go-natsutil" + "github.com/nats-io/nats.go" "github.com/provideplatform/privacy/common" ) @@ -13,17 +14,17 @@ const natsCircuitNotificationNoteNullified = "note.nullified" const natsCircuitNotificationExit = "exit" // dispatchNotification broadcasts an event to qualified subjects -func (c *Circuit) dispatchNotification(event string) error { +func (c *Circuit) dispatchNotification(event string) (*nats.PubAck, error) { prefix := c.notificationsSubjectPrefix() if prefix == nil { - return nil + return nil, fmt.Errorf("failed to dispatch event notification for circuit %s; nil prefix", c.ID.String()) } if event == "" { - return fmt.Errorf("failed to dispatch event notification for circuit %s", c.ID.String()) + return nil, fmt.Errorf("failed to dispatch event notification for circuit %s", c.ID.String()) } subject := fmt.Sprintf("%s.%s", *prefix, event) payload, _ := json.Marshal(map[string]interface{}{}) - return natsutil.NatsStreamingPublish(subject, payload) + return natsutil.NatsJetstreamPublish(subject, payload) } // notificationsSubject returns a namespaced subject suitable for pub/sub subscriptions diff --git a/go.mod b/go.mod index 22d0a93..87889f2 100644 --- a/go.mod +++ b/go.mod @@ -3,18 +3,18 @@ module github.com/provideplatform/privacy go 1.15 require ( - github.com/consensys/gnark v0.4.1-0.20210810173659-9e05ca392128 - github.com/consensys/gnark-crypto v0.4.1-0.20210810152820-89f1497f0bc5 + github.com/consensys/gnark v0.5.1-0.20210907165147-4e5ac5738a63 + github.com/consensys/gnark-crypto v0.5.0 github.com/gin-gonic/gin v1.7.0 github.com/golang-migrate/migrate v3.5.4+incompatible github.com/jinzhu/gorm v1.9.16 github.com/joho/godotenv v1.3.0 github.com/kthomas/go-db-config v0.0.0-20200612131637-ec0436a9685e github.com/kthomas/go-logger v0.0.0-20210526080020-a63672d0724c - github.com/kthomas/go-natsutil v0.0.0-20200602073459-388e1f070b05 + github.com/kthomas/go-natsutil v0.0.0-20210908125324-f04da1af9ee6 github.com/kthomas/go-redisutil v0.0.0-20200602073431-aa49de17e9ff github.com/kthomas/go.uuid v1.2.1-0.20190324131420-28d1fa77e9a4 - github.com/nats-io/stan.go v0.9.0 + github.com/nats-io/nats.go v1.12.0 github.com/onsi/ginkgo v1.16.3 // indirect github.com/onsi/gomega v1.13.0 // indirect github.com/providenetwork/merkletree v0.2.1-0.20210730012829-7003f45aa7dd diff --git a/go.sum b/go.sum index 379669c..f8c7d94 100644 --- a/go.sum +++ b/go.sum @@ -28,7 +28,6 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ= -github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 h1:EFSB7Zo9Eg91v7MJPVsifUysc/wPdN+NOnVe6bWbdBM= github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg= github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/badoux/checkmail v0.0.0-20200623144435-f9f80cb795fa h1:Wd0sN2PB+jhNm+z/eJz9p6XT23H8MVUIQUJs+8DQnXc= @@ -56,12 +55,11 @@ github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6D github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/cloudflare-go v0.10.2-0.20190916151808-a80f83b9add9/go.mod h1:1MxXX1Ux4x6mqPmjkUgTP1CdXIBXKX7T+Jk9Gxrmx+U= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ= -github.com/consensys/gnark v0.4.1-0.20210810173659-9e05ca392128 h1:wOqxXVX62WQhYceXRpwh31Z9Jr1ey+JH2WLCwNz9rv8= -github.com/consensys/gnark v0.4.1-0.20210810173659-9e05ca392128/go.mod h1:DZfhqsLXTa8a3xOUujDn3nMJQs//kGyZ0V46rONOvPI= -github.com/consensys/gnark-crypto v0.4.1-0.20210810152820-89f1497f0bc5 h1:q0XUjf9k06ZP17dEHQSx8+kFX2ThmzyF+DU4cf5dDLY= -github.com/consensys/gnark-crypto v0.4.1-0.20210810152820-89f1497f0bc5/go.mod h1:1XphlI46D/u4/TuSy7q5j1231x3XtwPr7jIIGOOZ080= +github.com/consensys/bavard v0.1.8-0.20210806153619-fcffe4ffd871/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ= +github.com/consensys/gnark v0.5.1-0.20210907165147-4e5ac5738a63 h1:IIGYwIp80trOoqP4Qhq1lyIy7xidiUupAoXe2gSVQdU= +github.com/consensys/gnark v0.5.1-0.20210907165147-4e5ac5738a63/go.mod h1:pjzjv55TTNbqcqnbMj7TgPZtFEZ0Q1obK33ZGpHS+Hs= +github.com/consensys/gnark-crypto v0.5.0 h1:c+1SOpCPKmw5lKth/hIoRgcw23KSgWnNR/b5M+JRC3k= +github.com/consensys/gnark-crypto v0.5.0/go.mod h1:wAZ9dsKCDVTSIy2KVTik+ZF16GUX9qp96mxFBDl9iAQ= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -87,9 +85,7 @@ github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD github.com/dop251/goja v0.0.0-20200721192441-a695b0cdd498/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= github.com/dvyukov/go-fuzz v0.0.0-20200318091601-be3528f3a813/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= github.com/edsrzf/mmap-go v0.0.0-20160512033002-935e0e8a636c/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= @@ -135,8 +131,6 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.2.2-0.20190730201129-28a6bbf47e48/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-migrate/migrate v3.5.4+incompatible h1:R7OzwvCJTCgwapPCiX6DyBiu2czIUMDCB118gFTKTUA= github.com/golang-migrate/migrate v3.5.4+incompatible/go.mod h1:IsVUlFN5puWOmXrqjgGUfIRIbU7mr8oNBE2tyERd9Wk= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= @@ -155,7 +149,6 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -173,25 +166,16 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/logger v1.0.1/go.mod h1:w7O8nrRr0xufejBlQMI83MXqRusvREoJdaAxV+CoAB4= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-hclog v0.9.1 h1:9PZfAcVEvez4yhLH2TBU64/h/z4xlFI80cWXRrxuKuM= github.com/hashicorp/go-hclog v0.9.1/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI= github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/raft v1.1.1 h1:HJr7UE1x/JrJSc9Oy6aDBHtNHUUBHjcQjTgvUVihoZs= github.com/hashicorp/raft v1.1.1/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea/go.mod h1:pNv7Wc3ycL6F5oOWn+tPGo2gWD4a5X+yp/ntwdKLjRk= github.com/holiman/uint256 v1.1.1/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= @@ -218,7 +202,6 @@ github.com/julienschmidt/httprouter v1.1.1-0.20170430222011-975b5c4c7c21/go.mod github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -238,8 +221,9 @@ github.com/kthomas/go-logger v0.0.0-20200602041232-5c46e0cab608/go.mod h1:sXRQB7 github.com/kthomas/go-logger v0.0.0-20200602072946-d7d72dfc2531/go.mod h1:sXRQB767yNz+melLbxSNF+yu0H7kxguvoJHqa47Mxh4= github.com/kthomas/go-logger v0.0.0-20210526080020-a63672d0724c h1:RY4Ei3MRDKfjWqaSG9OA2R/xz4GGmRQx/wcgGosYilI= github.com/kthomas/go-logger v0.0.0-20210526080020-a63672d0724c/go.mod h1:TtVSBQILggONVgiZObhmzisbSxWrgnF+GYhwKbNDV8Y= -github.com/kthomas/go-natsutil v0.0.0-20200602073459-388e1f070b05 h1:Sx6QjNcTqprrN0k/EjM8GaAM9Lfgb0BSSbzt3nRWH5U= github.com/kthomas/go-natsutil v0.0.0-20200602073459-388e1f070b05/go.mod h1:N0lpxSQ7hGx0pR4CK79koHPC2duLwvUORDHQ1hEERqU= +github.com/kthomas/go-natsutil v0.0.0-20210908125324-f04da1af9ee6 h1:DPnyPitN+OEdtK1/n5AlkNBAq9h6WNS9kMnFCYoNkGk= +github.com/kthomas/go-natsutil v0.0.0-20210908125324-f04da1af9ee6/go.mod h1:KusOWECXhtBAKMWmuj7yV75orxXeQC9ZVDFhrrHDUwE= github.com/kthomas/go-pgputil v0.0.0-20200602073402-784e96083943 h1:cDp8m82Etk3UybAMLVTgUyvscBc54Yuy1MsoqXbo71c= github.com/kthomas/go-pgputil v0.0.0-20200602073402-784e96083943/go.mod h1:1wYaoVWP9k76g2FfW5U9NaJ6dELUDFt2J2XMzSbJAVg= github.com/kthomas/go-redisutil v0.0.0-20200602073431-aa49de17e9ff h1:8tlYBAzX9jkEwGpIXLOwOMO57S5XmLLAcRDbuEtNJv8= @@ -285,13 +269,12 @@ github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL github.com/nats-io/nats-server/v2 v2.0.4/go.mod h1:AWdGEVbjKRS9ZIx4DSP5eKW48nfFm7q3uiSkP/1KD7M= github.com/nats-io/nats-server/v2 v2.1.2 h1:i2Ly0B+1+rzNZHHWtD4ZwKi+OU5l+uQo1iDHZ2PmiIc= github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= -github.com/nats-io/nats-streaming-server v0.16.2 h1:RyTg8dZ+A8LaDEEmh9BoHFxWJSuSrIGJ4xjsr0fLMeY= github.com/nats-io/nats-streaming-server v0.16.2/go.mod h1:P12vTqmBpT6Ufs+cu0W1C4N2wmISqa6G4xdLQeO2e2s= github.com/nats-io/nats.go v1.8.1/go.mod h1:BrFz9vVn0fU3AcH9Vn4Kd7W0NpJ651tD5omQ3M8LwxM= github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= github.com/nats-io/nats.go v1.10.0/go.mod h1:AjGArbfyR50+afOUotNX2Xs5SYHf+CoOa5HH1eEl2HE= -github.com/nats-io/nats.go v1.11.0 h1:L263PZkrmkRJRJT2YHU8GwWWvEvmr9/LUKuJTXsF32k= -github.com/nats-io/nats.go v1.11.0/go.mod h1:BPko4oXsySz4aSWeFgOHLZs3G4Jq4ZAyE6/zMCxRT6w= +github.com/nats-io/nats.go v1.12.0 h1:n0oZzK2aIZDMKuEiMKJ9qkCUgVY5vTAAksSXtLlz5Xc= +github.com/nats-io/nats.go v1.12.0/go.mod h1:BPko4oXsySz4aSWeFgOHLZs3G4Jq4ZAyE6/zMCxRT6w= github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4= github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= @@ -302,8 +285,6 @@ github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/nats-io/stan.go v0.5.0/go.mod h1:dYqB+vMN3C2F9pT1FRQpg9eHbjPj6mP0yYuyBNuXHZE= github.com/nats-io/stan.go v0.7.0/go.mod h1:Ci6mUIpGQTjl++MqK2XzkWI/0vF+Bl72uScx7ejSYmU= -github.com/nats-io/stan.go v0.9.0 h1:TB73Y31au++0sU0VmnBy2pYkSrwH0zUFNRB9YePHqC4= -github.com/nats-io/stan.go v0.9.0/go.mod h1:0jEuBXKauB1HHJswHM/lx05K48TJ1Yxj6VIfM4k+aB4= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= @@ -327,7 +308,6 @@ github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je4 github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v0.0.0-20170112150404-1b00554d8222/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0= @@ -346,7 +326,6 @@ github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7q github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.3 h1:CTwfnzjQ+8dS6MhHHu4YswVAD99sL2wjPqP+VkURmKE= github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/prometheus/tsdb v0.6.2-0.20190402121629-4f204dcbc150/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/providenetwork/merkletree v0.2.1-0.20210730012829-7003f45aa7dd h1:nVuWAJPkRjG6LUB0e8s13GZ/YKAakoaGOFI7CyzNXa4= @@ -359,7 +338,6 @@ github.com/provideplatform/provide-go v0.0.0-20210624064849-d7328258f0d8/go.mod github.com/provideplatform/provide-go v0.0.0-20210804232208-ced52410c4b0 h1:Z/okTpUoJw1/On1CSt7NwiSAkXF0UVf+PqZb1c6N2Fk= github.com/provideplatform/provide-go v0.0.0-20210804232208-ced52410c4b0/go.mod h1:q0/Q8KaZxYg84rdwBIIE7ZwHluzM5zw7zJJoJOqAbzg= github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521/go.mod h1:RvLn4FgxWubrpZHtQLnOf6EwhN2hEMusxZOhcW9H3UQ= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -395,16 +373,8 @@ github.com/vincent-petithory/dataurl v0.0.0-20191104211930-d1553a71de50/go.mod h github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208/go.mod h1:IotVbo4F+mw0EzQ08zFqg7pK3FebNXpaMsRy2RT+Ees= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= -go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -431,17 +401,12 @@ golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+o 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/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20200801112145-973feb4309de/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -455,15 +420,12 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= -golang.org/x/net v0.0.0-20210331212208-0fccb6fa2b5c/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -471,7 +433,6 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/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-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -496,11 +457,7 @@ golang.org/x/sys v0.0.0-20200824131525-c12d262b63d8/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -509,7 +466,6 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn 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/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -522,16 +478,9 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -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/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -543,12 +492,9 @@ google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww 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/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= 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.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -559,8 +505,9 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= 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/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -568,7 +515,6 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogR gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/dedis/crypto.v0 v0.0.0-20170824083343-8f53a63e87fd/go.mod h1:iaqPCBte+013imsCluFurQDVPHmFazSfB7Hs6Azgj0U= gopkg.in/dedis/kyber.v0 v0.0.0-20170824083343-8f53a63e87fd/go.mod h1:ck5rB03d4jamOCsaksyH9NNlS8F83ClF3QMacKp+hu0= -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/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns= @@ -588,5 +534,3 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= 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/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= diff --git a/ops/docker-compose-integration.yml b/ops/docker-compose-integration.yml index 8c7a9d5..1fd62bc 100644 --- a/ops/docker-compose-integration.yml +++ b/ops/docker-compose-integration.yml @@ -42,9 +42,9 @@ services: restart: always privacy0-nats: - image: provide/nats-server + image: provide/nats-server:2.2.3-beta.4-PRVD container_name: privacy0-nats - command: ["-auth", "testtoken", "-p", "4222", "-D", "-V"] + command: ["--js", "--server_name", "prvd-privacy0-nats", "-auth", "testtoken", "-p", "4222", "-D", "-V"] environment: JWT_SIGNER_PUBLIC_KEY: |- -----BEGIN PUBLIC KEY----- @@ -78,33 +78,11 @@ services: volumes: - ./ops/await_tcp.sh:/usr/local/bin/await_tcp.sh:cached - privacy0-nats-streaming: - image: provide/nats-streaming - command: ["-cid", "provide", "--auth", "testtoken", "-SDV"] - container_name: privacy0-nats-streaming - depends_on: - - privacy0-nats - healthcheck: - test: ["CMD", "/usr/local/bin/await_tcp.sh", "localhost:4222"] - interval: 1m - timeout: 1s - retries: 2 - start_period: 10s - hostname: privacy0-nats-streaming - networks: - - privacy0 - - privacy1 - ports: - - 4222 - restart: always - volumes: - - ./ops/await_tcp.sh:/usr/local/bin/await_tcp.sh:cached - privacy0-ident: image: provide/ident container_name: privacy0-ident depends_on: - - privacy0-nats-streaming + - privacy0-nats - privacy0-postgres - privacy0-redis environment: @@ -116,7 +94,7 @@ services: - DATABASE_SUPERUSER_PASSWORD=prvdp455 - NATS_CLIENT_PREFIX=ident - NATS_URL=nats://privacy0-nats:4222 - - NATS_STREAMING_URL=nats://privacy0-nats-streaming:4222 + - NATS_JETSTREAM_URL=nats://privacy0-nats:4222 - IDENT_API_HOST=privacy0-ident:8080 - IDENT_API_SCHEME=http - REDIS_HOSTS=privacy0-redis:6379 @@ -144,7 +122,7 @@ services: container_name: privacy0-ident-consumer depends_on: - privacy0-ident - - privacy0-nats-streaming + - privacy0-nats - privacy0-postgres - privacy0-redis environment: @@ -157,7 +135,7 @@ services: - DATABASE_SUPERUSER_PASSWORD=prvdp455 - NATS_CLIENT_PREFIX=privacy0-ident-consumer - NATS_URL=nats://privacy0-nats:4222 - - NATS_STREAMING_URL=nats://privacy0-nats-streaming:4222 + - NATS_JETSTREAM_URL=nats://privacy0-nats:4222 - IDENT_API_HOST=privacy0-ident:8080 - IDENT_API_SCHEME=http - REDIS_HOSTS=privacy0-redis:6379 @@ -181,7 +159,7 @@ services: container_name: privacy0-privacy depends_on: - privacy0-ident - - privacy0-nats-streaming + - privacy0-nats - privacy0-postgres - privacy0-consumer - privacy0-redis @@ -198,7 +176,7 @@ services: - LOG_LEVEL=DEBUG - NATS_CLIENT_PREFIX=privacy - NATS_URL=nats://privacy0-nats:4222 - - NATS_STREAMING_URL=nats://privacy0-nats-streaming:4222 + - NATS_JETSTREAM_URL=nats://privacy0-nats:4222 - PORT=8080 - VAULT_API_HOST=privacy0-vault:8080 - VAULT_API_SCHEME=http @@ -221,7 +199,7 @@ services: entrypoint: ./ops/run_consumer.sh container_name: privacy0-consumer depends_on: - - privacy0-nats-streaming + - privacy0-nats - privacy0-postgres - privacy0-redis - privacy0-vault @@ -238,7 +216,7 @@ services: - LOG_LEVEL=DEBUG - NATS_CLIENT_PREFIX=privacy-consumer - NATS_URL=nats://privacy0-nats:4222 - - NATS_STREAMING_URL=nats://privacy0-nats-streaming:4222 + - NATS_JETSTREAM_URL=nats://privacy0-nats:4222 - VAULT_API_HOST=privacy0-vault:8080 - VAULT_API_SCHEME=http - VAULT_REFRESH_TOKEN=eyJhbGciOiJSUzI1NiIsImtpZCI6IjEwOjJlOmQ5OmUxOmI4OmEyOjM0OjM3Ojk5OjNhOjI0OmZjOmFhOmQxOmM4OjU5IiwidHlwIjoiSldUIn0.eyJhdWQiOiJodHRwczovL3Byb3ZpZGUuc2VydmljZXMvYXBpL3YxIiwiaWF0IjoxNjA1NzkxMjQ4LCJpc3MiOiJodHRwczovL2lkZW50LnByb3ZpZGUuc2VydmljZXMiLCJqdGkiOiI5YjUxNGIxNS01NTdlLTRhYWQtYTcwOC0wMTcwZTAwZWE1ZmIiLCJuYXRzIjp7InBlcm1pc3Npb25zIjp7InN1YnNjcmliZSI6eyJhbGxvdyI6WyJhcHBsaWNhdGlvbi4zNjAxNTdmOC1kNWExLTQ0NDAtOTE4Yi1mNjhiYjM5YzBkODAiLCJ1c2VyLjIzY2MwN2UwLTM4NTEtNDBkZC1iNjc1LWRmNzY4MDY3MmY3ZCIsIm5ldHdvcmsuKi5jb25uZWN0b3IuKiIsIm5ldHdvcmsuKi5zdGF0dXMiLCJwbGF0Zm9ybS5cdTAwM2UiXX19fSwicHJ2ZCI6eyJhcHBsaWNhdGlvbl9pZCI6IjM2MDE1N2Y4LWQ1YTEtNDQ0MC05MThiLWY2OGJiMzljMGQ4MCIsImV4dGVuZGVkIjp7InBlcm1pc3Npb25zIjp7IioiOjUxMH19LCJwZXJtaXNzaW9ucyI6NTEwLCJ1c2VyX2lkIjoiMjNjYzA3ZTAtMzg1MS00MGRkLWI2NzUtZGY3NjgwNjcyZjdkIn0sInN1YiI6ImFwcGxpY2F0aW9uOjM2MDE1N2Y4LWQ1YTEtNDQ0MC05MThiLWY2OGJiMzljMGQ4MCJ9.SUh84MKBNstdu3KFu1zEAQq03xbPw1D0lLXeogz1HfBJy77bIGf7HLvCuc6bjkh0xj3cEuEus1dC1Dj3BvlZoSXsvz_biTzSapkXzJjpkwOL6qkYDmqTPZvXwqmk-mUNrHTPkqdiIJL7xA46tzHW3E_hjSA9HjEk1kXjPdJQ6_ifkgWNoAaSD--kudIrhZ7vLnfy0H1JEAOsXzSAMoc5_pNG2n79m0ywvb_4l9BqdsHW8N3xSQOFjcp9gD_tqo6ffug3pkpoy-RSguM_OaMR2lj_CHhYxAt0phtjUceDD3K1h5iZ38kSl7izhOdULMmGBhVpBMoSy6_R6ZzpCL3pj8FcReX9RXR5oYpm8PDtlmWqblQzjwY00-uYLfOX0_iS4MGfEsjadZPfTmJLcOTYC7H4PL9ZRu_XtMDUrGBQQz5b_ad2ZzMXbBNeU6vbxVKDG8VFKWOHAemqHTcvuOAsOCLIqOu-eJpZHlXbx-FXPTYledd-GBDe7IjaC9ll_JK3utCOnCq0qUs6lnXIrQ_Sp1LcTKJJ7aY5f9TxeoAuL-ghDbQ3Xkw6huKyPCz2evOwVLwrB9ZRMlQXgmTnB1OeQvWii1WbmkyV1Zhbz_RPB8ckK7_mFxuPvsXK8wTFiWFmj96sRX470kV-ooSfM5CzKZhSLqgyyaUNC0VaCPq0uuE @@ -327,9 +305,9 @@ services: restart: always privacy1-nats: - image: provide/nats-server + image: provide/nats-server:2.2.3-beta.4-PRVD container_name: privacy1-nats - command: ["-auth", "testtoken", "-p", "4222", "-D", "-V"] + command: ["--js", "--server_name", "prvd-privacy1", "-auth", "testtoken", "-p", "4222", "-D", "-V"] environment: JWT_SIGNER_PUBLIC_KEY: |- -----BEGIN PUBLIC KEY----- @@ -363,33 +341,11 @@ services: volumes: - ./ops/await_tcp.sh:/usr/local/bin/await_tcp.sh:cached - privacy1-nats-streaming: - image: provide/nats-streaming - command: ["-cid", "provide", "--auth", "testtoken", "-SDV"] - container_name: privacy1-nats-streaming - depends_on: - - privacy1-nats - healthcheck: - test: ["CMD", "/usr/local/bin/await_tcp.sh", "localhost:4222"] - interval: 1m - timeout: 1s - retries: 2 - start_period: 10s - hostname: privacy1-nats-streaming - networks: - - privacy0 - - privacy1 - ports: - - 4222 - restart: always - volumes: - - ./ops/await_tcp.sh:/usr/local/bin/await_tcp.sh:cached - privacy1-ident: image: provide/ident container_name: privacy1-ident depends_on: - - privacy1-nats-streaming + - privacy1-nats - privacy1-postgres - privacy1-redis environment: @@ -401,7 +357,7 @@ services: - DATABASE_SUPERUSER_PASSWORD=prvdp455 - NATS_CLIENT_PREFIX=ident - NATS_URL=nats://privacy1-nats:4222 - - NATS_STREAMING_URL=nats://privacy1-nats-streaming:4222 + - NATS_JETSTREAM_URL=nats://privacy1-nats:4222 - IDENT_API_HOST=privacy1-ident:8080 - IDENT_API_SCHEME=http - REDIS_HOSTS=privacy1-redis:6379 @@ -429,7 +385,7 @@ services: container_name: privacy1-ident-consumer depends_on: - privacy1-ident - - privacy1-nats-streaming + - privacy1-nats - privacy1-postgres - privacy1-redis - privacy1-vault @@ -443,7 +399,7 @@ services: - DATABASE_SUPERUSER_PASSWORD=prvdp455 - NATS_CLIENT_PREFIX=ident-consumer - NATS_URL=nats://privacy1-nats:4222 - - NATS_STREAMING_URL=nats://privacy1-nats-streaming:4222 + - NATS_JETSTREAM_URL=nats://privacy1-nats:4222 - IDENT_API_HOST=privacy1-ident:8080 - IDENT_API_SCHEME=http - REDIS_HOSTS=privacy1-redis:6379 @@ -467,7 +423,7 @@ services: container_name: privacy1-privacy depends_on: - privacy1-ident - - privacy1-nats-streaming + - privacy1-nats - privacy1-postgres - privacy1-consumer - privacy1-redis @@ -484,7 +440,7 @@ services: - LOG_LEVEL=DEBUG - NATS_CLIENT_PREFIX=privacy - NATS_URL=nats://privacy1-nats:4222 - - NATS_STREAMING_URL=nats://privacy1-nats-streaming:4222 + - NATS_JETSTREAM_URL=nats://privacy1-nats:4222 - PORT=8080 - VAULT_API_HOST=privacy1-vault:8080 - VAULT_API_SCHEME=http @@ -507,7 +463,7 @@ services: entrypoint: ./ops/run_consumer.sh container_name: privacy1-consumer depends_on: - - privacy1-nats-streaming + - privacy1-nats - privacy1-postgres - privacy1-redis - privacy1-vault @@ -524,7 +480,7 @@ services: - LOG_LEVEL=DEBUG - NATS_CLIENT_PREFIX=privacy-consumer - NATS_URL=nats://privacy1-nats:4222 - - NATS_STREAMING_URL=nats://privacy1-nats-streaming:4222 + - NATS_JETSTREAM_URL=nats://privacy1-nats:4222 - VAULT_API_HOST=privacy1-vault:8080 - VAULT_API_SCHEME=http - VAULT_REFRESH_TOKEN=eyJhbGciOiJSUzI1NiIsImtpZCI6IjEwOjJlOmQ5OmUxOmI4OmEyOjM0OjM3Ojk5OjNhOjI0OmZjOmFhOmQxOmM4OjU5IiwidHlwIjoiSldUIn0.eyJhdWQiOiJodHRwczovL3Byb3ZpZGUuc2VydmljZXMvYXBpL3YxIiwiaWF0IjoxNjA1NzkxMjQ4LCJpc3MiOiJodHRwczovL2lkZW50LnByb3ZpZGUuc2VydmljZXMiLCJqdGkiOiI5YjUxNGIxNS01NTdlLTRhYWQtYTcwOC0wMTcwZTAwZWE1ZmIiLCJuYXRzIjp7InBlcm1pc3Npb25zIjp7InN1YnNjcmliZSI6eyJhbGxvdyI6WyJhcHBsaWNhdGlvbi4zNjAxNTdmOC1kNWExLTQ0NDAtOTE4Yi1mNjhiYjM5YzBkODAiLCJ1c2VyLjIzY2MwN2UwLTM4NTEtNDBkZC1iNjc1LWRmNzY4MDY3MmY3ZCIsIm5ldHdvcmsuKi5jb25uZWN0b3IuKiIsIm5ldHdvcmsuKi5zdGF0dXMiLCJwbGF0Zm9ybS5cdTAwM2UiXX19fSwicHJ2ZCI6eyJhcHBsaWNhdGlvbl9pZCI6IjM2MDE1N2Y4LWQ1YTEtNDQ0MC05MThiLWY2OGJiMzljMGQ4MCIsImV4dGVuZGVkIjp7InBlcm1pc3Npb25zIjp7IioiOjUxMH19LCJwZXJtaXNzaW9ucyI6NTEwLCJ1c2VyX2lkIjoiMjNjYzA3ZTAtMzg1MS00MGRkLWI2NzUtZGY3NjgwNjcyZjdkIn0sInN1YiI6ImFwcGxpY2F0aW9uOjM2MDE1N2Y4LWQ1YTEtNDQ0MC05MThiLWY2OGJiMzljMGQ4MCJ9.SUh84MKBNstdu3KFu1zEAQq03xbPw1D0lLXeogz1HfBJy77bIGf7HLvCuc6bjkh0xj3cEuEus1dC1Dj3BvlZoSXsvz_biTzSapkXzJjpkwOL6qkYDmqTPZvXwqmk-mUNrHTPkqdiIJL7xA46tzHW3E_hjSA9HjEk1kXjPdJQ6_ifkgWNoAaSD--kudIrhZ7vLnfy0H1JEAOsXzSAMoc5_pNG2n79m0ywvb_4l9BqdsHW8N3xSQOFjcp9gD_tqo6ffug3pkpoy-RSguM_OaMR2lj_CHhYxAt0phtjUceDD3K1h5iZ38kSl7izhOdULMmGBhVpBMoSy6_R6ZzpCL3pj8FcReX9RXR5oYpm8PDtlmWqblQzjwY00-uYLfOX0_iS4MGfEsjadZPfTmJLcOTYC7H4PL9ZRu_XtMDUrGBQQz5b_ad2ZzMXbBNeU6vbxVKDG8VFKWOHAemqHTcvuOAsOCLIqOu-eJpZHlXbx-FXPTYledd-GBDe7IjaC9ll_JK3utCOnCq0qUs6lnXIrQ_Sp1LcTKJJ7aY5f9TxeoAuL-ghDbQ3Xkw6huKyPCz2evOwVLwrB9ZRMlQXgmTnB1OeQvWii1WbmkyV1Zhbz_RPB8ckK7_mFxuPvsXK8wTFiWFmj96sRX470kV-ooSfM5CzKZhSLqgyyaUNC0VaCPq0uuE diff --git a/ops/docker-compose.yml b/ops/docker-compose.yml index 3bfbf09..43bc38d 100644 --- a/ops/docker-compose.yml +++ b/ops/docker-compose.yml @@ -40,9 +40,9 @@ services: restart: always nats: - image: provide/nats-server + image: provide/nats-server:2.2.3-beta.4-PRVD container_name: provide-nats - command: ["-auth", "testtoken", "-p", "4222", "-D", "-V"] + command: ["--js", "--server_name", "prvd-nats1", "-auth", "testtoken", "-p", "4222", "-D", "-V"] environment: JWT_SIGNER_PUBLIC_KEY: |- -----BEGIN PUBLIC KEY----- @@ -67,7 +67,7 @@ services: start_period: 10s hostname: nats networks: - - privacy + - provide ports: - 4221:4221 - 4222:4222 @@ -75,32 +75,11 @@ services: volumes: - ./ops/await_tcp.sh:/usr/local/bin/await_tcp.sh:cached - nats-streaming: - image: provide/nats-streaming - command: ["-cid", "provide", "--auth", "testtoken", "-SDV"] - container_name: nats-streaming - depends_on: - - nats - healthcheck: - test: ["CMD", "/usr/local/bin/await_tcp.sh", "localhost:4222"] - interval: 1m - timeout: 1s - retries: 2 - start_period: 10s - hostname: nats-streaming - networks: - - privacy - ports: - - 4222 - restart: always - volumes: - - ./ops/await_tcp.sh:/usr/local/bin/await_tcp.sh:cached - ident: image: provide/ident container_name: ident depends_on: - - nats-streaming + - nats - postgres - redis environment: @@ -112,7 +91,7 @@ services: - DATABASE_SUPERUSER_PASSWORD=prvdp455 - NATS_CLIENT_PREFIX=ident - NATS_URL=nats://nats:4222 - - NATS_STREAMING_URL=nats://nats-streaming:4222 + - NATS_JETSTREAM_URL=nats://nats:4222 - IDENT_API_HOST=localhost:8080 - IDENT_API_SCHEME=http - REDIS_HOSTS=redis:6379 @@ -140,7 +119,7 @@ services: container_name: ident-consumer depends_on: - ident - - nats-streaming + - nats - postgres - redis - vault @@ -156,7 +135,7 @@ services: - IDENT_API_SCHEME=http - NATS_CLIENT_PREFIX=ident-consumer - NATS_URL=nats://nats:4222 - - NATS_STREAMING_URL=nats://nats-streaming:4222 + - NATS_JETSTREAM_URL=nats://nats:4222 - REDIS_HOSTS=redis:6379 - LOG_LEVEL=DEBUG - VAULT_API_HOST=vault:8080 @@ -178,7 +157,7 @@ services: container_name: privacy depends_on: - ident - - nats-streaming + - nats - postgres - privacy-consumer - redis @@ -195,7 +174,7 @@ services: - LOG_LEVEL=DEBUG - NATS_CLIENT_PREFIX=privacy - NATS_URL=nats://nats:4222 - - NATS_STREAMING_URL=nats://nats-streaming:4222 + - NATS_JETSTREAM_URL=nats://nats:4222 - PORT=8080 - VAULT_API_HOST=vault:8080 - VAULT_API_SCHEME=http @@ -218,7 +197,7 @@ services: entrypoint: ./ops/run_consumer.sh container_name: privacy-consumer depends_on: - - nats-streaming + - nats - postgres - redis - vault @@ -235,7 +214,7 @@ services: - LOG_LEVEL=DEBUG - NATS_CLIENT_PREFIX=privacy-consumer - NATS_URL=nats://nats:4222 - - NATS_STREAMING_URL=nats://nats-streaming:4222 + - NATS_JETSTREAM_URL=nats://nats:4222 - VAULT_API_HOST=vault:8080 - VAULT_API_SCHEME=http - VAULT_REFRESH_TOKEN=eyJhbGciOiJSUzI1NiIsImtpZCI6IjEwOjJlOmQ5OmUxOmI4OmEyOjM0OjM3Ojk5OjNhOjI0OmZjOmFhOmQxOmM4OjU5IiwidHlwIjoiSldUIn0.eyJhdWQiOiJodHRwczovL3Byb3ZpZGUuc2VydmljZXMvYXBpL3YxIiwiaWF0IjoxNjA1NzkxMjQ4LCJpc3MiOiJodHRwczovL2lkZW50LnByb3ZpZGUuc2VydmljZXMiLCJqdGkiOiI5YjUxNGIxNS01NTdlLTRhYWQtYTcwOC0wMTcwZTAwZWE1ZmIiLCJuYXRzIjp7InBlcm1pc3Npb25zIjp7InN1YnNjcmliZSI6eyJhbGxvdyI6WyJhcHBsaWNhdGlvbi4zNjAxNTdmOC1kNWExLTQ0NDAtOTE4Yi1mNjhiYjM5YzBkODAiLCJ1c2VyLjIzY2MwN2UwLTM4NTEtNDBkZC1iNjc1LWRmNzY4MDY3MmY3ZCIsIm5ldHdvcmsuKi5jb25uZWN0b3IuKiIsIm5ldHdvcmsuKi5zdGF0dXMiLCJwbGF0Zm9ybS5cdTAwM2UiXX19fSwicHJ2ZCI6eyJhcHBsaWNhdGlvbl9pZCI6IjM2MDE1N2Y4LWQ1YTEtNDQ0MC05MThiLWY2OGJiMzljMGQ4MCIsImV4dGVuZGVkIjp7InBlcm1pc3Npb25zIjp7IioiOjUxMH19LCJwZXJtaXNzaW9ucyI6NTEwLCJ1c2VyX2lkIjoiMjNjYzA3ZTAtMzg1MS00MGRkLWI2NzUtZGY3NjgwNjcyZjdkIn0sInN1YiI6ImFwcGxpY2F0aW9uOjM2MDE1N2Y4LWQ1YTEtNDQ0MC05MThiLWY2OGJiMzljMGQ4MCJ9.SUh84MKBNstdu3KFu1zEAQq03xbPw1D0lLXeogz1HfBJy77bIGf7HLvCuc6bjkh0xj3cEuEus1dC1Dj3BvlZoSXsvz_biTzSapkXzJjpkwOL6qkYDmqTPZvXwqmk-mUNrHTPkqdiIJL7xA46tzHW3E_hjSA9HjEk1kXjPdJQ6_ifkgWNoAaSD--kudIrhZ7vLnfy0H1JEAOsXzSAMoc5_pNG2n79m0ywvb_4l9BqdsHW8N3xSQOFjcp9gD_tqo6ffug3pkpoy-RSguM_OaMR2lj_CHhYxAt0phtjUceDD3K1h5iZ38kSl7izhOdULMmGBhVpBMoSy6_R6ZzpCL3pj8FcReX9RXR5oYpm8PDtlmWqblQzjwY00-uYLfOX0_iS4MGfEsjadZPfTmJLcOTYC7H4PL9ZRu_XtMDUrGBQQz5b_ad2ZzMXbBNeU6vbxVKDG8VFKWOHAemqHTcvuOAsOCLIqOu-eJpZHlXbx-FXPTYledd-GBDe7IjaC9ll_JK3utCOnCq0qUs6lnXIrQ_Sp1LcTKJJ7aY5f9TxeoAuL-ghDbQ3Xkw6huKyPCz2evOwVLwrB9ZRMlQXgmTnB1OeQvWii1WbmkyV1Zhbz_RPB8ckK7_mFxuPvsXK8wTFiWFmj96sRX470kV-ooSfM5CzKZhSLqgyyaUNC0VaCPq0uuE diff --git a/ops/run_api.sh b/ops/run_api.sh index 07eae1f..70869aa 100755 --- a/ops/run_api.sh +++ b/ops/run_api.sh @@ -105,8 +105,8 @@ if [[ -z "${NATS_URL}" ]]; then NATS_URL=nats://localhost:4222 fi -if [[ -z "${NATS_STREAMING_URL}" ]]; then - NATS_STREAMING_URL=nats://localhost:4222 +if [[ -z "${NATS_JETSTREAM_URL}" ]]; then + NATS_JETSTREAM_URL=nats://localhost:4222 fi if [[ -z "${NATS_FORCE_TLS}" ]]; then @@ -129,7 +129,7 @@ CONSUME_NATS_STREAMING_SUBSCRIPTIONS=$CONSUME_NATS_STREAMING_SUBSCRIPTIONS \ NATS_CLUSTER_ID=$NATS_CLUSTER_ID \ NATS_TOKEN=$NATS_TOKEN \ NATS_URL=$NATS_URL \ -NATS_STREAMING_URL=$NATS_STREAMING_URL \ +NATS_JETSTREAM_URL=$NATS_JETSTREAM_URL \ NATS_FORCE_TLS=$NATS_FORCE_TLS \ DATABASE_HOST=$DATABASE_HOST \ DATABASE_NAME=$DATABASE_NAME \ diff --git a/ops/run_consumer.sh b/ops/run_consumer.sh index 3d83d25..7f3a693 100755 --- a/ops/run_consumer.sh +++ b/ops/run_consumer.sh @@ -56,8 +56,8 @@ if [[ -z "${NATS_URL}" ]]; then NATS_URL=nats://localhost:4222 fi -if [[ -z "${NATS_STREAMING_URL}" ]]; then - NATS_STREAMING_URL=nats://localhost:4222 +if [[ -z "${NATS_JETSTREAM_URL}" ]]; then + NATS_JETSTREAM_URL=nats://localhost:4222 fi if [[ -z "${NATS_STREAMING_CONCURRENCY}" ]]; then @@ -90,7 +90,7 @@ NATS_CLUSTER_ID=$NATS_CLUSTER_ID \ NATS_TOKEN=$NATS_TOKEN \ NATS_URL=$NATS_URL \ NATS_STREAMING_CONCURRENCY=$NATS_STREAMING_CONCURRENCY \ -NATS_STREAMING_URL=$NATS_STREAMING_URL \ +NATS_JETSTREAM_URL=$NATS_JETSTREAM_URL \ NATS_FORCE_TLS=$NATS_FORCE_TLS \ DATABASE_HOST=$DATABASE_HOST \ DATABASE_NAME=$DATABASE_NAME \ diff --git a/store/consumer.go b/store/consumer.go index 2182001..9331e55 100644 --- a/store/consumer.go +++ b/store/consumer.go @@ -14,7 +14,7 @@ func init() { return } - natsutil.EstablishSharedNatsStreamingConnection(nil) + natsutil.EstablishSharedNatsConnection(nil) // var waitGroup sync.WaitGroup } diff --git a/test/ceremony/ceremony_test.go b/test/ceremony/ceremony_test.go new file mode 100644 index 0000000..8acd31c --- /dev/null +++ b/test/ceremony/ceremony_test.go @@ -0,0 +1,167 @@ +// +build ceremony + +package test + +import ( + "fmt" + "math/big" + "testing" + + uuid "github.com/kthomas/go.uuid" + "github.com/provideplatform/privacy/ceremony" + "github.com/provideplatform/privacy/common" + "github.com/provideplatform/provide-go/api/privacy" + "github.com/provideplatform/provide-go/common/util" +) + +func setupTestMPCs(t *testing.T, mpcs *[]*ceremony.Ceremony, parties []string, blockID uint64) error { + for i := 0; i < len(parties); i++ { + mpc := ceremony.CeremonyFactory(parties, &ceremony.CeremonyConfig{ + Block: &blockID, + ExpectedEntropy: 32 * (len(parties) + 1), + WordSize: 32, + }) + + err := mpc.GetEntropyFromBeacon(blockID) + if err != nil { + return fmt.Errorf("unable to get entropy; %s", err.Error()) + } + + err = mpc.GenerateEntropy() + if err != nil { + return fmt.Errorf("unable to generate entropy; %s", err.Error()) + } + + err = mpc.SubmitEntropy() + if err != nil { + return fmt.Errorf("unable to submit entropy; %s", err.Error()) + } + + *mpcs = append(*mpcs, mpc) + } + + t.Logf("created %d MPCs", len(*mpcs)) + return nil +} + +// TODO: replace with actual entropy receipt +func addPartiesToTestMPCs(t *testing.T, mpcs []*ceremony.Ceremony) error { + partyCount := len(mpcs) + for i := 0; i < partyCount; i++ { + for j := 0; j < partyCount; j++ { + mpcs[i].AddParty(j, mpcs[j]) + } + } + + return nil +} + +func validateEntropy(t *testing.T, mpcs []*ceremony.Ceremony) error { + for i := 1; i < len(mpcs); i++ { + if !mpcs[i-1].CompareEntropy(mpcs[i]) { + return fmt.Errorf("entropy from mpc %d does not match mpc %d", i-1, i) + } + } + + return nil +} + +func circuitParamsFactory(curve, name, identifier, provingScheme string, noteStoreID, nullifierStoreID *string) map[string]interface{} { + params := map[string]interface{}{ + "curve": curve, + "identifier": identifier, + "name": name, + "provider": "gnark", + "proving_scheme": provingScheme, + } + + if noteStoreID != nil { + params["note_store_id"] = noteStoreID + } + + if nullifierStoreID != nil { + params["nullifier_store_id"] = nullifierStoreID + } + + return params +} + +func TestCeremonySRSGeneration(t *testing.T) { + mpcs := make([]*ceremony.Ceremony, 0) + + // TODO: retrieve block ID properly + blockID := uint64(123456) + const partyCount = 5 + parties := make([]string, 0) + + i := new(big.Int) + for party := int64(0); party < int64(partyCount); party++ { + i.SetInt64(party) + parties = append(parties, i.String()) + } + + err := setupTestMPCs(t, &mpcs, parties, blockID) + if err != nil { + t.Errorf("error setting up test MPCs; %s", err.Error()) + return + } + + t.Logf("set up %d MPCs", len(mpcs)) + + err = addPartiesToTestMPCs(t, mpcs[:]) + if err != nil { + t.Errorf("error adding parties to test MPCs; %s", err.Error()) + return + } + + err = validateEntropy(t, mpcs[:]) + if err != nil { + t.Errorf("error validating entropy for test MPCs; %s", err.Error()) + return + } + + t.Log("all calculated entropy values are valid") + + newVault, err := vaultFactory(util.DefaultVaultAccessJWT, "mpc vault", "contains entropy for mpc") + if err != nil { + t.Errorf("failed to create vault for ceremony test; %s", err.Error()) + return + } + + entropySecretID, err := mpcs[0].StoreEntropy( + common.StringOrNil(util.DefaultVaultAccessJWT), + common.StringOrNil(newVault.ID.String()), + common.StringOrNil("mpc entropy"), + common.StringOrNil("entropy for mpc"), + common.StringOrNil("entropy"), + ) + if err != nil { + t.Errorf("failed to store entropy in vault; %s", err.Error()) + return + } + + t.Logf("stored entropy in vault; secret id: %s", entropySecretID.String()) + + testUserID, _ := uuid.NewV4() + token, _ := userTokenFactory(testUserID) + + params := circuitParamsFactory( + "BN254", + "PO", + "purchase_order", + "plonk", + nil, + nil, + ) + + params["entropy_id"] = entropySecretID.String() + params["vault_id"] = newVault.ID.String() + + circuit, err := privacy.CreateCircuit(*token, params) + if err != nil { + t.Errorf("failed to deploy circuit; %s", err.Error()) + return + } + + t.Logf("created circuit id: %s", circuit.ID.String()) +} diff --git a/test/codegen/codegen.go b/test/codegen/codegen.go index b2f552b..f3b4a52 100644 --- a/test/codegen/codegen.go +++ b/test/codegen/codegen.go @@ -108,7 +108,7 @@ func (c *Circuit) makeCircuitLogic() (string, error) { var logic strings.Builder if c.RollupProofCount > 0 { - fmt.Fprintf(&logic, "\tmimc, err := mimc.NewMiMC(\"seed\", curveID)\n") + fmt.Fprintf(&logic, "\tmimc, err := mimc.NewMiMC(\"seed\", curveID, cs)\n") fmt.Fprintf(&logic, "\tif err != nil {\n") fmt.Fprintf(&logic, "\t\treturn err\n\t}\n") fmt.Fprintf(&logic, "\tmerkle.VerifyProof(cs, mimc, circuit.RootHash, circuit.Proofs[:], circuit.Helpers[:])\n") diff --git a/test/e2e_test.go b/test/e2e_test.go index 5eb437a..52210d1 100644 --- a/test/e2e_test.go +++ b/test/e2e_test.go @@ -7,9 +7,7 @@ import ( "encoding/base64" "encoding/json" "fmt" - "hash" "math/big" - "math/rand" "os" "testing" @@ -21,8 +19,6 @@ import ( gnark_merkle "github.com/consensys/gnark-crypto/accumulator/merkletree" mimc "github.com/consensys/gnark-crypto/ecc/bn254/fr/mimc" - "github.com/consensys/gnark-crypto/ecc/bn254/twistededwards" - "github.com/consensys/gnark-crypto/ecc/bn254/twistededwards/eddsa" uuid "github.com/kthomas/go.uuid" "github.com/provideplatform/privacy/store/providers/merkletree" @@ -57,11 +53,15 @@ func TestProcureToPayWorkflowGroth16(t *testing.T) { tree := merkletree.NewMerkleTree(hFunc) testUserID, _ := uuid.NewV4() - token, _ := userTokenFactory(testUserID) + token, err := userTokenFactory(testUserID) + if err != nil { + t.Errorf("failed to create user token; %s", err.Error()) + return + } circuits, err := createProcureToPayWorkflow(token, testProvingSchemeGroth16) if err != nil { - t.Errorf("failed to create procure to pay workflow circuits%s", err.Error()) + t.Errorf("failed to create procure to pay workflow circuits; %s", err.Error()) return } @@ -103,7 +103,11 @@ func TestCircuitReuse(t *testing.T) { hFunc := mimc.NewMiMC("seed") testUserID, _ := uuid.NewV4() - token, _ := userTokenFactory(testUserID) + token, err := userTokenFactory(testUserID) + if err != nil { + t.Errorf("failed to create user token; %s", err.Error()) + return + } circuit, err := privacy.CreateCircuit( *token, @@ -268,7 +272,11 @@ func TestProcureToPayWorkflowRollupGroth16(t *testing.T) { tree := merkletree.NewMerkleTree(hFunc) testUserID, _ := uuid.NewV4() - token, _ := userTokenFactory(testUserID) + token, err := userTokenFactory(testUserID) + if err != nil { + t.Errorf("failed to create user token; %s", err.Error()) + return + } circuits := make([]*privacy.Circuit, 0) notes := make([][]byte, 0) @@ -281,7 +289,7 @@ func TestProcureToPayWorkflowRollupGroth16(t *testing.T) { workflowCircuits, err := createProcureToPayWorkflow(token, testProvingSchemeGroth16) if err != nil { - t.Errorf("failed to create procure to pay workflow circuits%s", err.Error()) + t.Errorf("failed to create procure to pay workflow circuits; %s", err.Error()) return } @@ -422,116 +430,3 @@ func TestProcureToPayWorkflowRollupGroth16(t *testing.T) { t.Logf("%s proof/verification: %s / %v", *rollupCircuit.Name, *rollupProof.Proof, verification.Result) } - -type STAGE uint16 - -const ( - PURCHASE STAGE = iota - SALES - SHIPMENT - GOODS - INVOICE -) - -func getProcurementWitness(stage STAGE, hFunc hash.Hash, proofString string, creditRating string) (string, map[string]interface{}) { - var i big.Int - - certificateNumber, _ := uuid.FromString("12345678-1234-5678-9abc-123456789abc") - createdOn := []byte("01/02/2021 04:40 PM UTC") - globalGoodsReceiptNumber := []byte("ENTITY-ORDER-NUMBER-20210101-001-GR") - globalPurchaseOrderNumber := []byte("ENTITY-ORDER-NUMBER-20210101-001") // GlobalPONumber from form - globalSalesOrderNumber := []byte("ENTITY-1234567890") - globalShipmentNumber := []byte("ENTITY-0000123456") - goodsReceiptCreatedOn := []byte("01/04/2021 01:40 PM UTC") - soldTo := []byte("56785678") - soNumber := []byte("1234567890") - - identifier := "" - hFunc.Reset() - - switch stage { - case PURCHASE: - // mimc Write never returns an error - hFunc.Write(globalPurchaseOrderNumber) - hFunc.Write(soNumber) - hFunc.Write(certificateNumber.Bytes()) - identifier = "purchase_order" - case SALES: - hFunc.Write(globalPurchaseOrderNumber) - hFunc.Write(globalSalesOrderNumber) - hFunc.Write(createdOn) - identifier = "sales_order" - case SHIPMENT: - hFunc.Write(globalPurchaseOrderNumber) - hFunc.Write(globalShipmentNumber) - hFunc.Write(soldTo) - identifier = "shipment_notification" - case GOODS: - hFunc.Write(globalPurchaseOrderNumber) - hFunc.Write(globalGoodsReceiptNumber) - hFunc.Write(goodsReceiptCreatedOn) - identifier = "goods_receipt" - case INVOICE: - privKey, _ := eddsa.GenerateKey(rand.New(rand.NewSource(time.Now().UnixNano()))) - pubKey := privKey.PublicKey - - var invoiceData big.Int - invoiceIntStr := "123456789123456789123456789123456789" - invoiceData.SetString(invoiceIntStr, 10) - invoiceDataBytes := invoiceData.Bytes() - - sigBytes, err := privKey.Sign(invoiceDataBytes, hFunc) - if err != nil { - return "", nil - } - - verified, err := pubKey.Verify(sigBytes, invoiceDataBytes, hFunc) - if err != nil || !verified { - return "", nil - } - - var sig eddsa.Signature - sig.SetBytes(sigBytes) - - var point twistededwards.PointAffine - pubKeyBytes := pubKey.Bytes() - point.SetBytes(pubKeyBytes) - xKey := point.X.Bytes() - xKeyString := i.SetBytes(xKey[:]).String() - yKey := point.Y.Bytes() - yKeyString := i.SetBytes(yKey[:]).String() - - point.SetBytes(sigBytes) - xSig := point.X.Bytes() - xSigString := i.SetBytes(xSig[:]).String() - ySig := point.Y.Bytes() - ySigString := i.SetBytes(ySig[:]).String() - sigLen := len(sigBytes) / 2 - sigS1String := i.SetBytes(sigBytes[sigLen : sigLen+sigLen/2]).String() - sigS2String := i.SetBytes(sigBytes[sigLen+sigLen/2:]).String() - - return "invoice", map[string]interface{}{ - "Msg": invoiceIntStr, - "PubKey.A.X": xKeyString, - "PubKey.A.Y": yKeyString, - "Sig.R.X": xSigString, - "Sig.R.Y": ySigString, - "Sig.S1": sigS1String, - "Sig.S2": sigS2String, - } - } - - hFunc.Write([]byte(proofString)) - hFunc.Write([]byte(creditRating)) - preImage := hFunc.Sum(nil) - preImageString := i.SetBytes(preImage).String() - - // mimc Sum merely calls Write which never returns an error - hash, _ := mimc.Sum("seed", preImage) - hashString := i.SetBytes(hash).String() - - return identifier, map[string]interface{}{ - "Document.Preimage": preImageString, - "Document.Hash": hashString, - } -} diff --git a/test/notifications_consumer.go b/test/notifications_consumer.go index 1efa811..dee5e57 100644 --- a/test/notifications_consumer.go +++ b/test/notifications_consumer.go @@ -27,7 +27,8 @@ func init() { return } - natsutil.EstablishSharedNatsStreamingConnection(nil) + natsutil.EstablishSharedNatsConnection(nil) + // TODO-- setup stream var waitGroup sync.WaitGroup createNatsCircuitNotificationNoteDepositSubscription(&waitGroup) @@ -51,7 +52,7 @@ func createNatsCircuitNotificationNoteDepositSubscription(wg *sync.WaitGroup) { panic(err) } - natsutil.RequireNatsStreamingSubscription(wg, + natsutil.RequireNatsJetstreamSubscription(wg, natsCircuitNotificationAckWait, *subject, *subject, @@ -70,7 +71,7 @@ func createNatsCircuitNotificationNoteNullifiedSubscription(wg *sync.WaitGroup) panic(err) } - natsutil.RequireNatsStreamingSubscription(wg, + natsutil.RequireNatsJetstreamSubscription(wg, natsCircuitNotificationAckWait, *subject, *subject, @@ -89,7 +90,7 @@ func createNatsCircuitNotificationExitSubscription(wg *sync.WaitGroup) { panic(err) } - natsutil.RequireNatsStreamingSubscription(wg, + natsutil.RequireNatsJetstreamSubscription(wg, natsCircuitNotificationAckWait, *subject, *subject, @@ -104,7 +105,7 @@ func circuitNoteDepositHandler(msg *stan.Msg) { defer func() { if r := recover(); r != nil { common.Log.Warningf("recovered during circuit note deposit notification handler; %s", r) - natsutil.AttemptNack(msg, natsCircuitNotificationTimeout) + msg.Nak() } }() @@ -115,7 +116,7 @@ func circuitNoteNullifiedHandler(msg *stan.Msg) { defer func() { if r := recover(); r != nil { common.Log.Warningf("recovered during circuit note nullified notification handler; %s", r) - natsutil.AttemptNack(msg, natsCircuitNotificationTimeout) + msg.Nak() } }() @@ -126,7 +127,7 @@ func circuitExitHandler(msg *stan.Msg) { defer func() { if r := recover(); r != nil { common.Log.Warningf("recovered during circuit exit notification handler; %s", r) - natsutil.AttemptNack(msg, natsCircuitNotificationTimeout) + msg.Nak() } }() diff --git a/zkp/lib/circuits/gnark/baseline_document.go b/zkp/lib/circuits/gnark/baseline_document.go index 8539f8c..4f12aec 100644 --- a/zkp/lib/circuits/gnark/baseline_document.go +++ b/zkp/lib/circuits/gnark/baseline_document.go @@ -37,13 +37,13 @@ type InvoiceCircuit struct { // Define declares the PO circuit constraints func (circuit *PurchaseOrderCircuit) Define(curveID ecc.ID, cs *frontend.ConstraintSystem) error { // hash function - mimc, err := mimc.NewMiMC("seed", curveID) + mimc, err := mimc.NewMiMC("seed", curveID, cs) if err != nil { return err } - hash := mimc.Hash(cs, circuit.Document.Preimage) - cs.AssertIsEqual(circuit.Document.Hash, hash) + mimc.Write(circuit.Document.Preimage) + cs.AssertIsEqual(circuit.Document.Hash, mimc.Sum()) return nil } @@ -51,13 +51,13 @@ func (circuit *PurchaseOrderCircuit) Define(curveID ecc.ID, cs *frontend.Constra // Define declares the SO circuit constraints func (circuit *SalesOrderCircuit) Define(curveID ecc.ID, cs *frontend.ConstraintSystem) error { // hash function - mimc, err := mimc.NewMiMC("seed", curveID) + mimc, err := mimc.NewMiMC("seed", curveID, cs) if err != nil { return err } - hash := mimc.Hash(cs, circuit.Document.Preimage) - cs.AssertIsEqual(circuit.Document.Hash, hash) + mimc.Write(circuit.Document.Preimage) + cs.AssertIsEqual(circuit.Document.Hash, mimc.Sum()) return nil } @@ -65,13 +65,13 @@ func (circuit *SalesOrderCircuit) Define(curveID ecc.ID, cs *frontend.Constraint // Define declares the SN circuit constraints func (circuit *ShipmentNotificationCircuit) Define(curveID ecc.ID, cs *frontend.ConstraintSystem) error { // hash function - mimc, err := mimc.NewMiMC("seed", curveID) + mimc, err := mimc.NewMiMC("seed", curveID, cs) if err != nil { return err } - hash := mimc.Hash(cs, circuit.Document.Preimage) - cs.AssertIsEqual(circuit.Document.Hash, hash) + mimc.Write(circuit.Document.Preimage) + cs.AssertIsEqual(circuit.Document.Hash, mimc.Sum()) return nil } @@ -79,13 +79,13 @@ func (circuit *ShipmentNotificationCircuit) Define(curveID ecc.ID, cs *frontend. // Define declares the GR circuit constraints func (circuit *GoodsReceiptCircuit) Define(curveID ecc.ID, cs *frontend.ConstraintSystem) error { // hash function - mimc, err := mimc.NewMiMC("seed", curveID) + mimc, err := mimc.NewMiMC("seed", curveID, cs) if err != nil { return err } - hash := mimc.Hash(cs, circuit.Document.Preimage) - cs.AssertIsEqual(circuit.Document.Hash, hash) + mimc.Write(circuit.Document.Preimage) + cs.AssertIsEqual(circuit.Document.Hash, mimc.Sum()) return nil } @@ -93,13 +93,13 @@ func (circuit *GoodsReceiptCircuit) Define(curveID ecc.ID, cs *frontend.Constrai // Define declares the Invoice circuit constraints func (circuit *InvoiceCircuit) Define(curveID ecc.ID, cs *frontend.ConstraintSystem) error { // hash function - mimc, err := mimc.NewMiMC("seed", curveID) + mimc, err := mimc.NewMiMC("seed", curveID, cs) if err != nil { return err } - hash := mimc.Hash(cs, circuit.Document.Preimage) - cs.AssertIsEqual(circuit.Document.Hash, hash) + mimc.Write(circuit.Document.Preimage) + cs.AssertIsEqual(circuit.Document.Hash, mimc.Sum()) return nil } diff --git a/zkp/lib/circuits/gnark/baseline_document_complete.go b/zkp/lib/circuits/gnark/baseline_document_complete.go index 64fc8ab..b4ae293 100644 --- a/zkp/lib/circuits/gnark/baseline_document_complete.go +++ b/zkp/lib/circuits/gnark/baseline_document_complete.go @@ -68,8 +68,9 @@ func (circuit *BaselineDocumentCompleteCircuit) Define(curveID ecc.ID, cs *front // Check for knowledge of preimage // Hash = mimc(Preimage) - mimc, _ := mimc.NewMiMC("seed", curveID) - cs.AssertIsEqual(circuit.Doc.Hash, mimc.Hash(cs, circuit.Doc.Preimage)) + mimc, _ := mimc.NewMiMC("seed", curveID, cs) + mimc.Write(circuit.Doc.Preimage) + cs.AssertIsEqual(circuit.Doc.Hash, mimc.Sum()) return nil } diff --git a/zkp/lib/circuits/gnark/baseline_rollup.go b/zkp/lib/circuits/gnark/baseline_rollup.go index 0fc8f25..43e5104 100644 --- a/zkp/lib/circuits/gnark/baseline_rollup.go +++ b/zkp/lib/circuits/gnark/baseline_rollup.go @@ -16,7 +16,7 @@ type BaselineRollupCircuit struct { // Define declares the circuit constraints func (circuit *BaselineRollupCircuit) Define(curveID ecc.ID, cs *frontend.ConstraintSystem) error { // hash function - mimc, err := mimc.NewMiMC("seed", curveID) + mimc, err := mimc.NewMiMC("seed", curveID, cs) if err != nil { return err } diff --git a/zkp/lib/circuits/gnark/mimc.go b/zkp/lib/circuits/gnark/mimc.go index e968b47..ed16cd8 100644 --- a/zkp/lib/circuits/gnark/mimc.go +++ b/zkp/lib/circuits/gnark/mimc.go @@ -19,11 +19,12 @@ type MimcCircuit struct { // Hash = mimc(Preimage) func (circuit *MimcCircuit) Define(curveID ecc.ID, cs *frontend.ConstraintSystem) error { // hash function - mimc, _ := mimc.NewMiMC("seed", curveID) + mimc, _ := mimc.NewMiMC("seed", curveID, cs) // specify constraints // mimc(preImage) == hash - cs.AssertIsEqual(circuit.Hash, mimc.Hash(cs, circuit.Preimage)) + mimc.Write(circuit.Preimage) + cs.AssertIsEqual(circuit.Hash, mimc.Sum()) return nil } diff --git a/zkp/lib/circuits/gnark/primitives.go b/zkp/lib/circuits/gnark/primitives.go index 9b6c6c2..7ebe147 100644 --- a/zkp/lib/circuits/gnark/primitives.go +++ b/zkp/lib/circuits/gnark/primitives.go @@ -24,7 +24,7 @@ func (circuit *EqualCircuit) Define(curveID ecc.ID, cs *frontend.ConstraintSyste cs.AssertIsLessOrEqual(circuit.Vals.Val, circuit.Vals.RelVal) cs.AssertIsLessOrEqual(circuit.Vals.RelVal, circuit.Vals.Val) // AssertIsEqual having trouble with this circuit, this is a workaround //diff := cs.Sub(circuit.Vals.Val, circuit.Vals.RelVal) - //diffIsZero := cs.IsZero(diff, curveID) + //diffIsZero := cs.IsZero(diff) //cs.AssertIsEqual(diffIsZero, cs.Constant(1)) return nil } @@ -37,7 +37,7 @@ type NotEqualCircuit struct { // Define declares the circuit constraints func (circuit *NotEqualCircuit) Define(curveID ecc.ID, cs *frontend.ConstraintSystem) error { diff := cs.Sub(circuit.Vals.Val, circuit.Vals.RelVal) - diffIsZero := cs.IsZero(diff, curveID) + diffIsZero := cs.IsZero(diff) cs.AssertIsEqual(diffIsZero, cs.Constant(0)) return nil } @@ -94,13 +94,13 @@ type ProofHashCircuit struct { // Define declares the circuit constraints func (circuit *ProofHashCircuit) Define(curveID ecc.ID, cs *frontend.ConstraintSystem) error { - hFunc, err := mimc.NewMiMC("seed", curveID) + hFunc, err := mimc.NewMiMC("seed", curveID, cs) if err != nil { return err } - hash := hFunc.Hash(cs, circuit.Proof[:]...) - cs.AssertIsEqual(hash, circuit.Hash) + hFunc.Write(circuit.Proof[:]...) + cs.AssertIsEqual(hFunc.Sum(), circuit.Hash) return nil } @@ -120,13 +120,13 @@ func (circuit *ProofEddsaCircuit) Define(curveID ecc.ID, cs *frontend.Constraint } circuit.PubKey.Curve = curve - hFunc, err := mimc.NewMiMC("seed", curveID) + hFunc, err := mimc.NewMiMC("seed", curveID, cs) if err != nil { return err } - hash := hFunc.Hash(cs, circuit.Msg[:]...) - eddsa.Verify(cs, circuit.Sig, hash, circuit.PubKey) + hFunc.Write(circuit.Msg[:]...) + eddsa.Verify(cs, circuit.Sig, hFunc.Sum(), circuit.PubKey) return nil }