6

GitHub - iden3/go-circuits: Circuits

 6 months ago
source link: https://github.com/iden3/go-circuits
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

go-circuits

General description:

The library goal is to create a wrapper for private and public inputs for identity circuits

Repository of circuits implementation: https://github.com/iden3/circuits

Set of functionality for circuits inputs preparation, and public signals schema retrieving

How to use :

  • All circuits implement InputsMarshaller and PubSignalsUnmarshal Interfaces

    type InputsMarshaller interface {
        InputsMarshal() ([]byte, error)
    }
    
    
    type PubSignalsUnmarshaller interface {
        PubSignalsUnmarshal(data []byte) error
    }
  • Example of usage:

At the moment you have to fill all needed attributes for a specific Inputs, take a look in test for each specific Input

  inputs := AuthInputs{
        ID: identifier,
        AuthClaim: Claim{
            Claim:       claim,
            Proof:       claimEntryMTP,
            TreeState:   treeState,
            NonRevProof: &ClaimNonRevStatus{treeState, claimNonRevMTP},
        },
        Signature: signature,
        Challenge: challenge,
    }

    circuitInputJSON, err := inputs.InputsMarshal() // marshal JSON inputs for specific circuit in proper format
  • It’s easy to extend Circuits mapping through registering custom Circuit Wrapper implementation

    RegisterCircuit(CustomCircuitID, Data{
        Input:  CustomInputs{},
        Output: &CustomPubSignals{},
    })

    Querying :

    The library defines the Query structure for atomic circuits and contains the mapping between query operation and its number. This library is not responsible for resolving SlotIndex for the claim field.

    // Query represents basic request to claim slot verification
    type Query struct {
        SlotIndex int
        Value     *big.Int
        Operator  int
    }
    
    
    // QueryOperators represents operators for atomic circuits
    var QueryOperators = map[string]int{
        "$noop": NOOP,
        "$eq":   EQ,
        "$lt":   LT,
        "$gt":   GT,
        "$in":   IN,
        "$nin":  NIN,
        "$ne":   NE,
    }

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as below, without any additional terms or conditions.

License

© 2023 0kims Association

This project is licensed under either of

at your option.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK