idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
32,300 | public static String dateToString ( Date date ) { final TimeZone utc = TimeZone . getTimeZone ( "UTC" ) ; SimpleDateFormat tformat = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ss.SSSXXX" ) ; tformat . setTimeZone ( utc ) ; return tformat . format ( date ) ; } | Converts Date type to String based on RFC3339 formatting |
32,301 | public static ECP weakBBSign ( BIG sk , BIG m ) { BIG exp = IdemixUtils . modAdd ( sk , m , IdemixUtils . GROUP_ORDER ) ; exp . invmodp ( IdemixUtils . GROUP_ORDER ) ; return IdemixUtils . genG1 . mul ( exp ) ; } | Produces a WBB signature for a give message |
32,302 | public static boolean weakBBVerify ( ECP2 pk , ECP sig , BIG m ) { ECP2 p = new ECP2 ( ) ; p . copy ( pk ) ; p . add ( IdemixUtils . genG2 . mul ( m ) ) ; p . affine ( ) ; return PAIR . fexp ( PAIR . ate ( p , sig ) ) . equals ( IdemixUtils . genGT ) ; } | Verify a WBB signature for a certain message |
32,303 | boolean check ( IdemixIssuerPublicKey ipk ) { if ( nym == null || issuerNonce == null || proofC == null || proofS == null || ipk == null ) { return false ; } ECP t = ipk . getHsk ( ) . mul ( proofS ) ; t . sub ( nym . mul ( proofC ) ) ; byte [ ] proofData = new byte [ 0 ] ; proofData = IdemixUtils . append ( proofData , CREDREQUEST_LABEL . getBytes ( ) ) ; proofData = IdemixUtils . append ( proofData , IdemixUtils . ecpToBytes ( t ) ) ; proofData = IdemixUtils . append ( proofData , IdemixUtils . ecpToBytes ( ipk . getHsk ( ) ) ) ; proofData = IdemixUtils . append ( proofData , IdemixUtils . ecpToBytes ( nym ) ) ; proofData = IdemixUtils . append ( proofData , IdemixUtils . bigToBytes ( issuerNonce ) ) ; proofData = IdemixUtils . append ( proofData , ipk . getHash ( ) ) ; byte [ ] hproofdata = IdemixUtils . bigToBytes ( IdemixUtils . hashModOrder ( proofData ) ) ; return Arrays . equals ( IdemixUtils . bigToBytes ( proofC ) , hproofdata ) ; } | Cryptographically verify the IdemixCredRequest |
32,304 | public String toJson ( ) { StringWriter stringWriter = new StringWriter ( ) ; JsonWriter jsonWriter = Json . createWriter ( new PrintWriter ( stringWriter ) ) ; jsonWriter . writeObject ( toJsonObject ( ) ) ; jsonWriter . close ( ) ; return stringWriter . toString ( ) ; } | Convert the enrollment request to a JSON string |
32,305 | public String getPackageId ( ) throws ProposalException { if ( Status . SUCCESS != getStatus ( ) ) { throw new ProposalException ( format ( "Status of install proposal did not ret ok for %s, %s " , getPeer ( ) , getStatus ( ) ) ) ; } ByteString payload = getProposalResponse ( ) . getResponse ( ) . getPayload ( ) ; Lifecycle . InstallChaincodeResult installChaincodeResult = null ; try { installChaincodeResult = Lifecycle . InstallChaincodeResult . parseFrom ( payload ) ; } catch ( InvalidProtocolBufferException e ) { throw new ProposalException ( format ( "Bad protobuf received for install proposal %s" , getPeer ( ) ) ) ; } return installChaincodeResult . getPackageId ( ) ; } | The packageId the identifies this chaincode change . |
32,306 | public boolean check ( ) { if ( AttributeNames == null || Hsk == null || HRand == null || HAttrs == null || BarG1 == null || BarG1 . is_infinity ( ) || BarG2 == null || HAttrs . length < AttributeNames . length ) { return false ; } for ( int i = 0 ; i < AttributeNames . length ; i ++ ) { if ( HAttrs [ i ] == null ) { return false ; } } ECP2 t1 = IdemixUtils . genG2 . mul ( ProofS ) ; ECP t2 = BarG1 . mul ( ProofS ) ; t1 . add ( W . mul ( BIG . modneg ( ProofC , IdemixUtils . GROUP_ORDER ) ) ) ; t2 . add ( BarG2 . mul ( BIG . modneg ( ProofC , IdemixUtils . GROUP_ORDER ) ) ) ; byte [ ] proofData = new byte [ 0 ] ; proofData = IdemixUtils . append ( proofData , IdemixUtils . ecpToBytes ( t1 ) ) ; proofData = IdemixUtils . append ( proofData , IdemixUtils . ecpToBytes ( t2 ) ) ; proofData = IdemixUtils . append ( proofData , IdemixUtils . ecpToBytes ( IdemixUtils . genG2 ) ) ; proofData = IdemixUtils . append ( proofData , IdemixUtils . ecpToBytes ( BarG1 ) ) ; proofData = IdemixUtils . append ( proofData , IdemixUtils . ecpToBytes ( W ) ) ; proofData = IdemixUtils . append ( proofData , IdemixUtils . ecpToBytes ( BarG2 ) ) ; return Arrays . equals ( IdemixUtils . bigToBytes ( IdemixUtils . hashModOrder ( proofData ) ) , IdemixUtils . bigToBytes ( ProofC ) ) ; } | check whether the issuer public key is correct |
32,307 | public Map < String , Boolean > getApprovalMap ( ) throws ProposalException { Lifecycle . QueryApprovalStatusResults rs = getApprovalStatusResults ( ) ; if ( rs == null ) { return Collections . emptyMap ( ) ; } return rs . getApprovedMap ( ) ; } | A map of approved and not approved . The key contains name of org the value a Boolean if approved . |
32,308 | public Collection < String > getPeerNames ( ) { if ( peers == null ) { return Collections . EMPTY_SET ; } else { return new HashSet < > ( peers . keySet ( ) ) ; } } | Names of Peers found |
32,309 | public Collection < String > getOrdererNames ( ) { if ( orderers == null ) { return Collections . EMPTY_SET ; } else { return new HashSet < > ( orderers . keySet ( ) ) ; } } | Names of Orderers found |
32,310 | public void setPeerProperties ( String name , Properties properties ) throws InvalidArgumentException { setNodeProperties ( "Peer" , name , peers , properties ) ; } | Set a specific peer s properties . |
32,311 | public void setOrdererProperties ( String name , Properties properties ) throws InvalidArgumentException { setNodeProperties ( "Orderer" , name , orderers , properties ) ; } | Set a specific orderer s properties . |
32,312 | public static NetworkConfig fromYamlFile ( File configFile ) throws InvalidArgumentException , IOException , NetworkConfigurationException { return fromFile ( configFile , false ) ; } | Creates a new NetworkConfig instance configured with details supplied in a YAML file . |
32,313 | public static NetworkConfig fromJsonFile ( File configFile ) throws InvalidArgumentException , IOException , NetworkConfigurationException { return fromFile ( configFile , true ) ; } | Creates a new NetworkConfig instance configured with details supplied in a JSON file . |
32,314 | public static NetworkConfig fromYamlStream ( InputStream configStream ) throws InvalidArgumentException , NetworkConfigurationException { logger . trace ( "NetworkConfig.fromYamlStream..." ) ; if ( configStream == null ) { throw new InvalidArgumentException ( "configStream must be specified" ) ; } Yaml yaml = new Yaml ( ) ; @ SuppressWarnings ( "unchecked" ) Map < String , Object > map = yaml . load ( configStream ) ; JsonObjectBuilder builder = Json . createObjectBuilder ( map ) ; JsonObject jsonConfig = builder . build ( ) ; return fromJsonObject ( jsonConfig ) ; } | Creates a new NetworkConfig instance configured with details supplied in YAML format |
32,315 | public static NetworkConfig fromJsonStream ( InputStream configStream ) throws InvalidArgumentException , NetworkConfigurationException { logger . trace ( "NetworkConfig.fromJsonStream..." ) ; if ( configStream == null ) { throw new InvalidArgumentException ( "configStream must be specified" ) ; } try ( JsonReader reader = Json . createReader ( configStream ) ) { JsonObject jsonConfig = ( JsonObject ) reader . read ( ) ; return fromJsonObject ( jsonConfig ) ; } } | Creates a new NetworkConfig instance configured with details supplied in JSON format |
32,316 | public static NetworkConfig fromJsonObject ( JsonObject jsonConfig ) throws InvalidArgumentException , NetworkConfigurationException { if ( jsonConfig == null ) { throw new InvalidArgumentException ( "jsonConfig must be specified" ) ; } if ( logger . isTraceEnabled ( ) ) { logger . trace ( format ( "NetworkConfig.fromJsonObject: %s" , jsonConfig . toString ( ) ) ) ; } return NetworkConfig . load ( jsonConfig ) ; } | Creates a new NetworkConfig instance configured with details supplied in a JSON object |
32,317 | private static NetworkConfig fromFile ( File configFile , boolean isJson ) throws InvalidArgumentException , IOException , NetworkConfigurationException { if ( configFile == null ) { throw new InvalidArgumentException ( "configFile must be specified" ) ; } if ( logger . isTraceEnabled ( ) ) { logger . trace ( format ( "NetworkConfig.fromFile: %s isJson = %b" , configFile . getAbsolutePath ( ) , isJson ) ) ; } NetworkConfig config ; try ( InputStream stream = new FileInputStream ( configFile ) ) { config = isJson ? fromJsonStream ( stream ) : fromYamlStream ( stream ) ; } return config ; } | Loads a NetworkConfig object from a Json or Yaml file |
32,318 | private static NetworkConfig load ( JsonObject jsonConfig ) throws InvalidArgumentException , NetworkConfigurationException { if ( jsonConfig == null ) { throw new InvalidArgumentException ( "config must be specified" ) ; } return new NetworkConfig ( jsonConfig ) ; } | Returns a new NetworkConfig instance and populates it from the specified JSON object |
32,319 | public Map < String , OrgInfo > getPeerOrgInfos ( final String peerName ) throws InvalidArgumentException { if ( Utils . isNullOrEmpty ( peerName ) ) { throw new InvalidArgumentException ( "peerName can not be null or empty." ) ; } if ( organizations == null || organizations . isEmpty ( ) ) { return new HashMap < > ( ) ; } Map < String , OrgInfo > ret = new HashMap < > ( 16 ) ; organizations . forEach ( ( name , orgInfo ) -> { if ( orgInfo . getPeerNames ( ) . contains ( peerName ) ) { ret . put ( name , orgInfo ) ; } } ) ; return ret ; } | Find organizations for a peer . |
32,320 | public UserInfo getPeerAdmin ( String orgName ) throws NetworkConfigurationException { OrgInfo org = getOrganizationInfo ( orgName ) ; if ( org == null ) { throw new NetworkConfigurationException ( format ( "Organization %s is not defined" , orgName ) ) ; } return org . getPeerAdmin ( ) ; } | Returns the admin user associated with the specified organization |
32,321 | private void createAllOrderers ( ) throws NetworkConfigurationException { if ( orderers != null ) { throw new NetworkConfigurationException ( "INTERNAL ERROR: orderers has already been initialized!" ) ; } orderers = new HashMap < > ( ) ; JsonObject jsonOrderers = getJsonObject ( jsonConfig , "orderers" ) ; if ( jsonOrderers != null ) { for ( Entry < String , JsonValue > entry : jsonOrderers . entrySet ( ) ) { String ordererName = entry . getKey ( ) ; JsonObject jsonOrderer = getJsonValueAsObject ( entry . getValue ( ) ) ; if ( jsonOrderer == null ) { throw new NetworkConfigurationException ( format ( "Error loading config. Invalid orderer entry: %s" , ordererName ) ) ; } Node orderer = createNode ( ordererName , jsonOrderer , "url" ) ; if ( orderer == null ) { throw new NetworkConfigurationException ( format ( "Error loading config. Invalid orderer entry: %s" , ordererName ) ) ; } orderers . put ( ordererName , orderer ) ; } } } | Creates Node instances representing all the orderers defined in the config file |
32,322 | private void createAllPeers ( ) throws NetworkConfigurationException { if ( peers != null ) { throw new NetworkConfigurationException ( "INTERNAL ERROR: peers has already been initialized!" ) ; } peers = new HashMap < > ( ) ; JsonObject jsonPeers = getJsonObject ( jsonConfig , "peers" ) ; if ( jsonPeers != null ) { for ( Entry < String , JsonValue > entry : jsonPeers . entrySet ( ) ) { String peerName = entry . getKey ( ) ; JsonObject jsonPeer = getJsonValueAsObject ( entry . getValue ( ) ) ; if ( jsonPeer == null ) { throw new NetworkConfigurationException ( format ( "Error loading config. Invalid peer entry: %s" , peerName ) ) ; } Node peer = createNode ( peerName , jsonPeer , "url" ) ; if ( peer == null ) { throw new NetworkConfigurationException ( format ( "Error loading config. Invalid peer entry: %s" , peerName ) ) ; } peers . put ( peerName , peer ) ; } } } | Creates Node instances representing all the peers defined in the config file |
32,323 | private Map < String , JsonObject > findCertificateAuthorities ( ) throws NetworkConfigurationException { Map < String , JsonObject > ret = new HashMap < > ( ) ; JsonObject jsonCertificateAuthorities = getJsonObject ( jsonConfig , "certificateAuthorities" ) ; if ( null != jsonCertificateAuthorities ) { for ( Entry < String , JsonValue > entry : jsonCertificateAuthorities . entrySet ( ) ) { String name = entry . getKey ( ) ; JsonObject jsonCA = getJsonValueAsObject ( entry . getValue ( ) ) ; if ( jsonCA == null ) { throw new NetworkConfigurationException ( format ( "Error loading config. Invalid CA entry: %s" , name ) ) ; } ret . put ( name , jsonCA ) ; } } return ret ; } | Produce a map from tag to jsonobject for the CA |
32,324 | private void createAllOrganizations ( Map < String , JsonObject > foundCertificateAuthorities ) throws NetworkConfigurationException { if ( organizations != null ) { throw new NetworkConfigurationException ( "INTERNAL ERROR: organizations has already been initialized!" ) ; } organizations = new HashMap < > ( ) ; JsonObject jsonOrganizations = getJsonObject ( jsonConfig , "organizations" ) ; if ( jsonOrganizations != null ) { for ( Entry < String , JsonValue > entry : jsonOrganizations . entrySet ( ) ) { String orgName = entry . getKey ( ) ; JsonObject jsonOrg = getJsonValueAsObject ( entry . getValue ( ) ) ; if ( jsonOrg == null ) { throw new NetworkConfigurationException ( format ( "Error loading config. Invalid Organization entry: %s" , orgName ) ) ; } OrgInfo org = createOrg ( orgName , jsonOrg , foundCertificateAuthorities ) ; organizations . put ( orgName , org ) ; } } } | Creates JsonObjects representing all the Organizations defined in the config file |
32,325 | private Orderer getOrderer ( HFClient client , String ordererName ) throws InvalidArgumentException { Orderer orderer = null ; Node o = orderers . get ( ordererName ) ; if ( o != null ) { orderer = client . newOrderer ( o . getName ( ) , o . getUrl ( ) , o . getProperties ( ) ) ; } return orderer ; } | Returns a new Orderer instance for the specified orderer name |
32,326 | private Node createNode ( String nodeName , JsonObject jsonNode , String urlPropName ) throws NetworkConfigurationException { String url = jsonNode . getString ( urlPropName , null ) ; if ( url == null ) { return null ; } Properties props = extractProperties ( jsonNode , "grpcOptions" ) ; if ( null != props ) { String value = props . getProperty ( "grpc.keepalive_time_ms" ) ; if ( null != value ) { props . remove ( "grpc.keepalive_time_ms" ) ; props . put ( "grpc.NettyChannelBuilderOption.keepAliveTime" , new Object [ ] { new Long ( value ) , TimeUnit . MILLISECONDS } ) ; } value = props . getProperty ( "grpc.keepalive_timeout_ms" ) ; if ( null != value ) { props . remove ( "grpc.keepalive_timeout_ms" ) ; props . put ( "grpc.NettyChannelBuilderOption.keepAliveTimeout" , new Object [ ] { new Long ( value ) , TimeUnit . MILLISECONDS } ) ; } } getTLSCerts ( nodeName , jsonNode , props ) ; return new Node ( nodeName , url , props , jsonNode ) ; } | Creates a new Node instance from a JSON object |
32,327 | private OrgInfo createOrg ( String orgName , JsonObject jsonOrg , Map < String , JsonObject > foundCertificateAuthorities ) throws NetworkConfigurationException { String msgPrefix = format ( "Organization %s" , orgName ) ; String mspId = getJsonValueAsString ( jsonOrg . get ( "mspid" ) ) ; OrgInfo org = new OrgInfo ( orgName , mspId ) ; JsonArray jsonPeers = getJsonValueAsArray ( jsonOrg . get ( "peers" ) ) ; if ( jsonPeers != null ) { for ( JsonValue peer : jsonPeers ) { String peerName = getJsonValueAsString ( peer ) ; if ( peerName != null ) { org . addPeerName ( peerName ) ; } } } JsonArray jsonCertificateAuthorities = getJsonValueAsArray ( jsonOrg . get ( "certificateAuthorities" ) ) ; if ( jsonCertificateAuthorities != null ) { for ( JsonValue jsonCA : jsonCertificateAuthorities ) { String caName = getJsonValueAsString ( jsonCA ) ; if ( caName != null ) { JsonObject jsonObject = foundCertificateAuthorities . get ( caName ) ; if ( jsonObject != null ) { org . addCertificateAuthority ( createCA ( caName , jsonObject , org ) ) ; } else { throw new NetworkConfigurationException ( format ( "%s: Certificate Authority %s is not defined" , msgPrefix , caName ) ) ; } } } } String adminPrivateKeyString = extractPemString ( jsonOrg , "adminPrivateKey" , msgPrefix ) ; String signedCert = extractPemString ( jsonOrg , "signedCert" , msgPrefix ) ; if ( ! isNullOrEmpty ( adminPrivateKeyString ) && ! isNullOrEmpty ( signedCert ) ) { PrivateKey privateKey = null ; try { privateKey = getPrivateKeyFromString ( adminPrivateKeyString ) ; } catch ( IOException ioe ) { throw new NetworkConfigurationException ( format ( "%s: Invalid private key" , msgPrefix ) , ioe ) ; } final PrivateKey privateKeyFinal = privateKey ; try { org . peerAdmin = new UserInfo ( CryptoSuite . Factory . getCryptoSuite ( ) , mspId , "PeerAdmin_" + mspId + "_" + orgName , null ) ; } catch ( Exception e ) { throw new NetworkConfigurationException ( e . getMessage ( ) , e ) ; } org . peerAdmin . setEnrollment ( new X509Enrollment ( privateKeyFinal , signedCert ) ) ; } return org ; } | Creates a new OrgInfo instance from a JSON object |
32,328 | private CAInfo createCA ( String name , JsonObject jsonCA , OrgInfo org ) throws NetworkConfigurationException { String url = getJsonValueAsString ( jsonCA . get ( "url" ) ) ; Properties httpOptions = extractProperties ( jsonCA , "httpOptions" ) ; String enrollId = null ; String enrollSecret = null ; List < JsonObject > registrars = getJsonValueAsList ( jsonCA . get ( "registrar" ) ) ; List < UserInfo > regUsers = new LinkedList < > ( ) ; if ( registrars != null ) { for ( JsonObject reg : registrars ) { enrollId = getJsonValueAsString ( reg . get ( "enrollId" ) ) ; enrollSecret = getJsonValueAsString ( reg . get ( "enrollSecret" ) ) ; try { regUsers . add ( new UserInfo ( CryptoSuite . Factory . getCryptoSuite ( ) , org . mspId , enrollId , enrollSecret ) ) ; } catch ( Exception e ) { throw new NetworkConfigurationException ( e . getMessage ( ) , e ) ; } } } CAInfo caInfo = new CAInfo ( name , org . mspId , url , regUsers , httpOptions ) ; String caName = getJsonValueAsString ( jsonCA . get ( "caName" ) ) ; if ( caName != null ) { caInfo . setCaName ( caName ) ; } Properties properties = new Properties ( ) ; if ( null != httpOptions && "false" . equals ( httpOptions . getProperty ( "verify" ) ) ) { properties . setProperty ( "allowAllHostNames" , "true" ) ; } getTLSCerts ( name , jsonCA , properties ) ; caInfo . setProperties ( properties ) ; return caInfo ; } | Creates a new CAInfo instance from a JSON object |
32,329 | private static Properties extractProperties ( JsonObject json , String fieldName ) { Properties props = new Properties ( ) ; JsonObject options = getJsonObject ( json , fieldName ) ; if ( options != null ) { for ( Entry < String , JsonValue > entry : options . entrySet ( ) ) { String key = entry . getKey ( ) ; JsonValue value = entry . getValue ( ) ; props . setProperty ( key , getJsonValue ( value ) ) ; } } return props ; } | Extracts all defined properties of the specified field and returns a Properties object |
32,330 | private Peer getPeer ( HFClient client , String peerName ) throws InvalidArgumentException { Peer peer = null ; Node p = peers . get ( peerName ) ; if ( p != null ) { peer = client . newPeer ( p . getName ( ) , p . getUrl ( ) , p . getProperties ( ) ) ; } return peer ; } | Returns a new Peer instance for the specified peer name |
32,331 | private static String getJsonValue ( JsonValue value ) { String s = null ; if ( value != null ) { s = getJsonValueAsString ( value ) ; if ( s == null ) { s = getJsonValueAsNumberString ( value ) ; } if ( s == null ) { Boolean b = getJsonValueAsBoolean ( value ) ; if ( b != null ) { s = b ? "true" : "false" ; } } } return s ; } | If it s anything else it returns null |
32,332 | private static JsonObject getJsonValueAsObject ( JsonValue value ) { return ( value != null && value . getValueType ( ) == ValueType . OBJECT ) ? value . asJsonObject ( ) : null ; } | Returns the specified JsonValue as a JsonObject or null if it s not an object |
32,333 | private static JsonArray getJsonValueAsArray ( JsonValue value ) { return ( value != null && value . getValueType ( ) == ValueType . ARRAY ) ? value . asJsonArray ( ) : null ; } | Returns the specified JsonValue as a JsonArray or null if it s not an array |
32,334 | private static List < JsonObject > getJsonValueAsList ( JsonValue value ) { if ( value != null ) { if ( value . getValueType ( ) == ValueType . ARRAY ) { return value . asJsonArray ( ) . getValuesAs ( JsonObject . class ) ; } else if ( value . getValueType ( ) == ValueType . OBJECT ) { List < JsonObject > ret = new ArrayList < > ( ) ; ret . add ( value . asJsonObject ( ) ) ; return ret ; } } return null ; } | Returns the specified JsonValue as a List . Allows single or array |
32,335 | private static Boolean getJsonValueAsBoolean ( JsonValue value ) { if ( value != null ) { if ( value . getValueType ( ) == ValueType . TRUE ) { return true ; } else if ( value . getValueType ( ) == ValueType . FALSE ) { return false ; } } return null ; } | Returns the specified JsonValue as a Boolean or null if it s not a boolean |
32,336 | private static JsonObject getJsonObject ( JsonObject object , String propName ) { JsonObject obj = null ; JsonValue val = object . get ( propName ) ; if ( val != null && val . getValueType ( ) == ValueType . OBJECT ) { obj = val . asJsonObject ( ) ; } return obj ; } | Returns the specified property as a JsonObject |
32,337 | public Set < String > getChannelNames ( ) { Set < String > ret = Collections . EMPTY_SET ; JsonObject channels = getJsonObject ( jsonConfig , "channels" ) ; if ( channels != null ) { final Set < String > channelNames = channels . keySet ( ) ; if ( channelNames != null && ! channelNames . isEmpty ( ) ) { ret = new HashSet < > ( channelNames ) ; } } return ret ; } | Get the channel names found . |
32,338 | public void setTransientMap ( Map < String , byte [ ] > transientMap ) throws InvalidArgumentException { if ( null == transientMap ) { throw new InvalidArgumentException ( "Transient map may not be set to null" ) ; } this . transientMap = transientMap ; } | Transient data added to the proposal that is not added to the ledger . |
32,339 | public static LifecycleChaincodeEndorsementPolicy fromStream ( InputStream inputStream ) throws IOException { return new LifecycleChaincodeEndorsementPolicy ( ByteString . copyFrom ( IOUtils . toByteArray ( inputStream ) ) ) ; } | Construct a chaincode endorsement policy from a stream . |
32,340 | public void setChaincodeName ( String chaincodeName ) throws InvalidArgumentException { if ( Utils . isNullOrEmpty ( chaincodeName ) ) { throw new InvalidArgumentException ( "The chaincodeName parameter can not be null or empty." ) ; } this . chaincodeName = chaincodeName ; } | The name of the chaincode to approve . |
32,341 | public void setChaincodeVersion ( String chaincodeVersion ) throws InvalidArgumentException { if ( Utils . isNullOrEmpty ( chaincodeVersion ) ) { throw new InvalidArgumentException ( "The chaincodeVersion parameter can not be null or empty." ) ; } this . chaincodeVersion = chaincodeVersion ; } | The version of the chaincode to approve . |
32,342 | public void setChaincodeEndorsementPlugin ( String chaincodeEndorsementPlugin ) throws InvalidArgumentException { if ( Utils . isNullOrEmpty ( chaincodeEndorsementPlugin ) ) { throw new InvalidArgumentException ( "The getChaincodeEndorsementPlugin parameter can not be null or empty." ) ; } this . chaincodeEndorsementPlugin = chaincodeEndorsementPlugin ; } | This is the chaincode endorsement plugin . Should default not needing set . ONLY set if there is a specific endorsement is set for your organization |
32,343 | public void setChaincodeValidationPlugin ( String chaincodeValidationPlugin ) throws InvalidArgumentException { if ( Utils . isNullOrEmpty ( chaincodeValidationPlugin ) ) { throw new InvalidArgumentException ( "The getChaincodeValidationPlugin parameter can not be null or empty." ) ; } this . chaincodeValidationPlugin = chaincodeValidationPlugin ; } | This is the chaincode validation plugin . Should default not needing set . ONLY set if there is a specific validation is set for your organization |
32,344 | public void setUpdateChannelConfiguration ( byte [ ] updateChannelConfigurationAsBytes ) throws InvalidArgumentException { if ( updateChannelConfigurationAsBytes == null ) { throw new InvalidArgumentException ( "UpdateChannelConfiguration updateChannelConfigurationAsBytes must be non-null" ) ; } logger . trace ( "Creating setUpdateChannelConfiguration from bytes" ) ; configBytes = updateChannelConfigurationAsBytes ; } | sets the UpdateChannelConfiguration from a byte array |
32,345 | void setChannel ( Channel channel ) throws InvalidArgumentException { if ( null != this . channel ) { throw new InvalidArgumentException ( format ( "Can not add peer %s to channel %s because it already belongs to channel %s." , name , channel . getName ( ) , this . channel . getName ( ) ) ) ; } logger . debug ( format ( "%s setting channel to %s, from %s" , toString ( ) , "" + channel , "" + this . channel ) ) ; this . channel = channel ; this . channelName = channel . getName ( ) ; } | Set the channel the peer is on . |
32,346 | public PeerEventingServiceDisconnected setPeerEventingServiceDisconnected ( PeerEventingServiceDisconnected newPeerEventingServiceDisconnectedHandler ) { PeerEventingServiceDisconnected ret = disconnectedHandler ; disconnectedHandler = newPeerEventingServiceDisconnectedHandler ; return ret ; } | Set class to handle peer eventing service disconnects |
32,347 | public void setChannelConfiguration ( byte [ ] channelConfigurationAsBytes ) throws InvalidArgumentException { if ( channelConfigurationAsBytes == null ) { throw new InvalidArgumentException ( "ChannelConfiguration channelConfigurationAsBytes must be non-null" ) ; } logger . trace ( "Creating setChannelConfiguration from bytes" ) ; this . configBytes = channelConfigurationAsBytes ; } | sets the ChannelConfiguration from a byte array |
32,348 | public static RAND getRand ( ) { int seedLength = IdemixUtils . FIELD_BYTES ; SecureRandom random = new SecureRandom ( ) ; byte [ ] seed = random . generateSeed ( seedLength ) ; RAND rng = new RAND ( ) ; rng . clean ( ) ; rng . seed ( seedLength , seed ) ; return rng ; } | Returns a random number generator amcl . RAND initialized with a fresh seed . |
32,349 | public static BIG hashModOrder ( byte [ ] data ) { HASH256 hash = new HASH256 ( ) ; for ( byte b : data ) { hash . process ( b ) ; } byte [ ] hasheddata = hash . hash ( ) ; BIG ret = BIG . fromBytes ( hasheddata ) ; ret . mod ( IdemixUtils . GROUP_ORDER ) ; return ret ; } | hashModOrder hashes bytes to an amcl . BIG in 0 ... GROUP_ORDER |
32,350 | public static byte [ ] bigToBytes ( BIG big ) { byte [ ] ret = new byte [ IdemixUtils . FIELD_BYTES ] ; big . toBytes ( ret ) ; return ret ; } | bigToBytes turns a BIG into a byte array |
32,351 | static byte [ ] ecpToBytes ( ECP e ) { byte [ ] ret = new byte [ 2 * FIELD_BYTES + 1 ] ; e . toBytes ( ret , false ) ; return ret ; } | ecpToBytes turns an ECP into a byte array |
32,352 | static byte [ ] append ( byte [ ] data , byte [ ] toAppend ) { ByteArrayOutputStream stream = new ByteArrayOutputStream ( ) ; try { stream . write ( data ) ; stream . write ( toAppend ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return stream . toByteArray ( ) ; } | append appends a byte array to an existing byte array |
32,353 | static byte [ ] append ( byte [ ] data , boolean [ ] toAppend ) { byte [ ] toAppendBytes = new byte [ toAppend . length ] ; for ( int i = 0 ; i < toAppend . length ; i ++ ) { toAppendBytes [ i ] = toAppend [ i ] ? ( byte ) 1 : ( byte ) 0 ; } return append ( data , toAppendBytes ) ; } | append appends a boolean array to an existing byte array |
32,354 | static ECP transformFromProto ( Idemix . ECP w ) { byte [ ] valuex = w . getX ( ) . toByteArray ( ) ; byte [ ] valuey = w . getY ( ) . toByteArray ( ) ; return new ECP ( BIG . fromBytes ( valuex ) , BIG . fromBytes ( valuey ) ) ; } | Returns an amcl . BN256 . ECP on input of an ECP protobuf object . |
32,355 | static ECP2 transformFromProto ( Idemix . ECP2 w ) { byte [ ] valuexa = w . getXa ( ) . toByteArray ( ) ; byte [ ] valuexb = w . getXb ( ) . toByteArray ( ) ; byte [ ] valueya = w . getYa ( ) . toByteArray ( ) ; byte [ ] valueyb = w . getYb ( ) . toByteArray ( ) ; FP2 valuex = new FP2 ( BIG . fromBytes ( valuexa ) , BIG . fromBytes ( valuexb ) ) ; FP2 valuey = new FP2 ( BIG . fromBytes ( valueya ) , BIG . fromBytes ( valueyb ) ) ; return new ECP2 ( valuex , valuey ) ; } | Returns an amcl . BN256 . ECP2 on input of an ECP2 protobuf object . |
32,356 | static Idemix . ECP2 transformToProto ( ECP2 w ) { byte [ ] valueXA = new byte [ IdemixUtils . FIELD_BYTES ] ; byte [ ] valueXB = new byte [ IdemixUtils . FIELD_BYTES ] ; byte [ ] valueYA = new byte [ IdemixUtils . FIELD_BYTES ] ; byte [ ] valueYB = new byte [ IdemixUtils . FIELD_BYTES ] ; w . getX ( ) . getA ( ) . toBytes ( valueXA ) ; w . getX ( ) . getB ( ) . toBytes ( valueXB ) ; w . getY ( ) . getA ( ) . toBytes ( valueYA ) ; w . getY ( ) . getB ( ) . toBytes ( valueYB ) ; return Idemix . ECP2 . newBuilder ( ) . setXa ( ByteString . copyFrom ( valueXA ) ) . setXb ( ByteString . copyFrom ( valueXB ) ) . setYa ( ByteString . copyFrom ( valueYA ) ) . setYb ( ByteString . copyFrom ( valueYB ) ) . build ( ) ; } | Converts an amcl . BN256 . ECP2 into an ECP2 protobuf object . |
32,357 | static Idemix . ECP transformToProto ( ECP w ) { byte [ ] valueX = new byte [ IdemixUtils . FIELD_BYTES ] ; byte [ ] valueY = new byte [ IdemixUtils . FIELD_BYTES ] ; w . getX ( ) . toBytes ( valueX ) ; w . getY ( ) . toBytes ( valueY ) ; return Idemix . ECP . newBuilder ( ) . setX ( ByteString . copyFrom ( valueX ) ) . setY ( ByteString . copyFrom ( valueY ) ) . build ( ) ; } | Converts an amcl . BN256 . ECP into an ECP protobuf object . |
32,358 | static BIG modAdd ( BIG a , BIG b , BIG m ) { BIG c = a . plus ( b ) ; c . mod ( m ) ; return c ; } | Takes input BIGs a b m and returns a + b modulo m |
32,359 | static BIG modSub ( BIG a , BIG b , BIG m ) { return modAdd ( a , BIG . modneg ( b , m ) , m ) ; } | Modsub takes input BIGs a b m and returns a - b modulo m |
32,360 | public void fromYamlFile ( File yamlPolicyFile ) throws IOException , ChaincodeEndorsementPolicyParseException { final Yaml yaml = new Yaml ( ) ; final Map < ? , ? > load = ( Map < ? , ? > ) yaml . load ( new FileInputStream ( yamlPolicyFile ) ) ; Map < ? , ? > mp = ( Map < ? , ? > ) load . get ( "policy" ) ; if ( null == mp ) { throw new ChaincodeEndorsementPolicyParseException ( "The policy file has no policy section" ) ; } IndexedHashMap < String , MSPPrincipal > identities = parseIdentities ( ( Map < ? , ? > ) load . get ( "identities" ) ) ; SignaturePolicy sp = parsePolicy ( identities , mp ) ; policyBytes = Policies . SignaturePolicyEnvelope . newBuilder ( ) . setVersion ( 0 ) . addAllIdentities ( identities . values ( ) ) . setRule ( sp ) . build ( ) . toByteArray ( ) ; } | From a yaml file |
32,361 | public static ChaincodeEndorsementPolicy fromBytes ( byte [ ] policyAsBytes ) { ChaincodeEndorsementPolicy ret = new ChaincodeEndorsementPolicy ( ) ; ret . policyBytes = new byte [ policyAsBytes . length ] ; System . arraycopy ( policyAsBytes , 0 , ret . policyBytes , 0 , policyAsBytes . length ) ; return ret ; } | sets the ChaincodeEndorsementPolicy from a byte array |
32,362 | public int read ( User registrar ) throws AffiliationException , InvalidArgumentException { if ( registrar == null ) { throw new InvalidArgumentException ( "Registrar should be a valid member" ) ; } String readAffURL = "" ; try { readAffURL = HFCA_AFFILIATION + "/" + name ; logger . debug ( format ( "affiliation url: %s, registrar: %s" , readAffURL , registrar . getName ( ) ) ) ; JsonObject result = client . httpGet ( readAffURL , registrar ) ; logger . debug ( format ( "affiliation url: %s, registrar: %s done." , readAffURL , registrar ) ) ; HFCAAffiliationResp resp = getResponse ( result ) ; this . childHFCAAffiliations = resp . getChildren ( ) ; this . identities = resp . getIdentities ( ) ; this . deleted = false ; return resp . statusCode ; } catch ( HTTPException e ) { String msg = format ( "[Code: %d] - Error while getting affiliation '%s' from url '%s': %s" , e . getStatusCode ( ) , this . name , readAffURL , e . getMessage ( ) ) ; AffiliationException affiliationException = new AffiliationException ( msg , e ) ; logger . error ( msg ) ; throw affiliationException ; } catch ( Exception e ) { String msg = format ( "Error while getting affiliation %s url: %s %s " , this . name , readAffURL , e . getMessage ( ) ) ; AffiliationException affiliationException = new AffiliationException ( msg , e ) ; logger . error ( msg ) ; throw affiliationException ; } } | gets a specific affiliation |
32,363 | public HFCAAffiliationResp create ( User registrar , boolean force ) throws AffiliationException , InvalidArgumentException { if ( registrar == null ) { throw new InvalidArgumentException ( "Registrar should be a valid member" ) ; } String createURL = "" ; try { createURL = client . getURL ( HFCA_AFFILIATION ) ; logger . debug ( format ( "affiliation url: %s, registrar: %s" , createURL , registrar . getName ( ) ) ) ; Map < String , String > queryParm = new HashMap < String , String > ( ) ; queryParm . put ( "force" , String . valueOf ( force ) ) ; String body = client . toJson ( affToJsonObject ( ) ) ; JsonObject result = client . httpPost ( createURL , body , registrar ) ; logger . debug ( format ( "identity url: %s, registrar: %s done." , createURL , registrar ) ) ; this . deleted = false ; return getResponse ( result ) ; } catch ( HTTPException e ) { String msg = format ( "[Code: %d] - Error while creating affiliation '%s' from url '%s': %s" , e . getStatusCode ( ) , this . name , createURL , e . getMessage ( ) ) ; AffiliationException affiliationException = new AffiliationException ( msg , e ) ; logger . error ( msg ) ; throw affiliationException ; } catch ( Exception e ) { String msg = format ( "Error while creating affiliation %s url: %s %s " , this . name , createURL , e . getMessage ( ) ) ; AffiliationException affiliationException = new AffiliationException ( msg , e ) ; logger . error ( msg ) ; throw affiliationException ; } } | create an affiliation |
32,364 | public HFCAAffiliationResp update ( User registrar , boolean force ) throws AffiliationException , InvalidArgumentException { if ( this . deleted ) { throw new AffiliationException ( "Affiliation has been deleted" ) ; } if ( registrar == null ) { throw new InvalidArgumentException ( "Registrar should be a valid member" ) ; } if ( Utils . isNullOrEmpty ( name ) ) { throw new InvalidArgumentException ( "Affiliation name cannot be null or empty" ) ; } String updateURL = "" ; try { Map < String , String > queryParm = new HashMap < String , String > ( ) ; queryParm . put ( "force" , String . valueOf ( force ) ) ; updateURL = client . getURL ( HFCA_AFFILIATION + "/" + this . name , queryParm ) ; logger . debug ( format ( "affiliation url: %s, registrar: %s" , updateURL , registrar . getName ( ) ) ) ; String body = client . toJson ( affToJsonObject ( ) ) ; JsonObject result = client . httpPut ( updateURL , body , registrar ) ; generateResponse ( result ) ; logger . debug ( format ( "identity url: %s, registrar: %s done." , updateURL , registrar ) ) ; HFCAAffiliationResp resp = getResponse ( result ) ; this . childHFCAAffiliations = resp . childHFCAAffiliations ; this . identities = resp . identities ; return getResponse ( result ) ; } catch ( HTTPException e ) { String msg = format ( "[Code: %d] - Error while updating affiliation '%s' from url '%s': %s" , e . getStatusCode ( ) , this . name , updateURL , e . getMessage ( ) ) ; AffiliationException affiliationException = new AffiliationException ( msg , e ) ; logger . error ( msg ) ; throw affiliationException ; } catch ( Exception e ) { String msg = format ( "Error while updating affiliation %s url: %s %s " , this . name , updateURL , e . getMessage ( ) ) ; AffiliationException affiliationException = new AffiliationException ( msg , e ) ; logger . error ( msg ) ; throw affiliationException ; } } | update an affiliation |
32,365 | public HFCAAffiliationResp delete ( User registrar , boolean force ) throws AffiliationException , InvalidArgumentException { if ( this . deleted ) { throw new AffiliationException ( "Affiliation has been deleted" ) ; } if ( registrar == null ) { throw new InvalidArgumentException ( "Registrar should be a valid member" ) ; } String deleteURL = "" ; try { Map < String , String > queryParm = new HashMap < String , String > ( ) ; queryParm . put ( "force" , String . valueOf ( force ) ) ; deleteURL = client . getURL ( HFCA_AFFILIATION + "/" + this . name , queryParm ) ; logger . debug ( format ( "affiliation url: %s, registrar: %s" , deleteURL , registrar . getName ( ) ) ) ; JsonObject result = client . httpDelete ( deleteURL , registrar ) ; logger . debug ( format ( "identity url: %s, registrar: %s done." , deleteURL , registrar ) ) ; this . deleted = true ; return getResponse ( result ) ; } catch ( HTTPException e ) { String msg = format ( "[Code: %d] - Error while deleting affiliation '%s' from url '%s': %s" , e . getStatusCode ( ) , this . name , deleteURL , e . getMessage ( ) ) ; AffiliationException affiliationException = new AffiliationException ( msg , e ) ; logger . error ( msg ) ; throw affiliationException ; } catch ( Exception e ) { String msg = format ( "Error while deleting affiliation %s url: %s %s " , this . name , deleteURL , e . getMessage ( ) ) ; AffiliationException affiliationException = new AffiliationException ( msg , e ) ; logger . error ( msg ) ; throw affiliationException ; } } | delete an affiliation |
32,366 | private JsonObject affToJsonObject ( ) { JsonObjectBuilder ob = Json . createObjectBuilder ( ) ; if ( client . getCAName ( ) != null ) { ob . add ( HFCAClient . FABRIC_CA_REQPROP , client . getCAName ( ) ) ; } if ( this . updateName != null ) { ob . add ( "name" , updateName ) ; this . updateName = null ; } else { ob . add ( "name" , name ) ; } return ob . build ( ) ; } | Convert the affiliation request to a JSON object |
32,367 | void validateAffiliationNames ( String name ) throws InvalidArgumentException { checkFormat ( name ) ; if ( name . startsWith ( "." ) ) { throw new InvalidArgumentException ( "Affiliation name cannot start with a dot '.'" ) ; } if ( name . endsWith ( "." ) ) { throw new InvalidArgumentException ( "Affiliation name cannot end with a dot '.'" ) ; } for ( int i = 0 ; i < name . length ( ) ; i ++ ) { if ( ( name . charAt ( i ) == '.' ) && ( name . charAt ( i ) == name . charAt ( i - 1 ) ) ) { throw new InvalidArgumentException ( "Affiliation name cannot contain multiple consecutive dots '.'" ) ; } } } | Validate affiliation name for proper formatting |
32,368 | static final synchronized CryptoSuiteFactory getDefault ( ) throws ClassNotFoundException , IllegalAccessException , InstantiationException , NoSuchMethodException , InvocationTargetException { if ( null == theFACTORY ) { String cf = config . getDefaultCryptoSuiteFactory ( ) ; if ( null == cf || cf . isEmpty ( ) || cf . equals ( HLSDKJCryptoSuiteFactory . class . getName ( ) ) ) { theFACTORY = HLSDKJCryptoSuiteFactory . instance ( ) ; } else { Class < ? > aClass = Class . forName ( cf ) ; Method method = aClass . getMethod ( "instance" ) ; Object theFACTORYObject = method . invoke ( null ) ; if ( null == theFACTORYObject ) { throw new InstantiationException ( String . format ( "Class specified by %s has instance method returning null. Expected object implementing CryptoSuiteFactory interface." , cf ) ) ; } if ( ! ( theFACTORYObject instanceof CryptoSuiteFactory ) ) { throw new InstantiationException ( String . format ( "Class specified by %s has instance method returning a class %s which does not implement interface CryptoSuiteFactory " , cf , theFACTORYObject . getClass ( ) . getName ( ) ) ) ; } theFACTORY = ( CryptoSuiteFactory ) theFACTORYObject ; } } return theFACTORY ; } | one and only factory . |
32,369 | public boolean verify ( BIG sk , IdemixIssuerPublicKey ipk ) { if ( ipk == null || Attrs . length != ipk . getAttributeNames ( ) . length ) { return false ; } for ( byte [ ] attr : Attrs ) { if ( attr == null ) { return false ; } } ECP bPrime = new ECP ( ) ; bPrime . copy ( IdemixUtils . genG1 ) ; bPrime . add ( ipk . getHsk ( ) . mul2 ( sk , ipk . getHRand ( ) , S ) ) ; for ( int i = 0 ; i < Attrs . length / 2 ; i ++ ) { bPrime . add ( ipk . getHAttrs ( ) [ 2 * i ] . mul2 ( BIG . fromBytes ( Attrs [ 2 * i ] ) , ipk . getHAttrs ( ) [ 2 * i + 1 ] , BIG . fromBytes ( Attrs [ 2 * i + 1 ] ) ) ) ; } if ( Attrs . length % 2 != 0 ) { bPrime . add ( ipk . getHAttrs ( ) [ Attrs . length - 1 ] . mul ( BIG . fromBytes ( Attrs [ Attrs . length - 1 ] ) ) ) ; } if ( ! B . equals ( bPrime ) ) { return false ; } ECP2 a = IdemixUtils . genG2 . mul ( E ) ; a . add ( ipk . getW ( ) ) ; a . affine ( ) ; return PAIR . fexp ( PAIR . ate ( a , A ) ) . equals ( PAIR . fexp ( PAIR . ate ( IdemixUtils . genG2 , B ) ) ) ; } | verify cryptographically verifies the credential |
32,370 | public int getTransactionCount ( ) { if ( isFiltered ( ) ) { int ltransactionCount = transactionCount ; if ( ltransactionCount < 0 ) { ltransactionCount = 0 ; for ( int i = filteredBlock . getFilteredTransactionsCount ( ) - 1 ; i >= 0 ; -- i ) { FilteredTransaction filteredTransactions = filteredBlock . getFilteredTransactions ( i ) ; Common . HeaderType type = filteredTransactions . getType ( ) ; if ( type == Common . HeaderType . ENDORSER_TRANSACTION ) { ++ ltransactionCount ; } } transactionCount = ltransactionCount ; } return transactionCount ; } int ltransactionCount = transactionCount ; if ( ltransactionCount < 0 ) { ltransactionCount = 0 ; for ( int i = getEnvelopeCount ( ) - 1 ; i >= 0 ; -- i ) { try { EnvelopeInfo envelopeInfo = getEnvelopeInfo ( i ) ; if ( envelopeInfo . getType ( ) == TRANSACTION_ENVELOPE ) { ++ ltransactionCount ; } } catch ( InvalidProtocolBufferException e ) { throw new InvalidProtocolBufferRuntimeException ( e ) ; } } transactionCount = ltransactionCount ; } return transactionCount ; } | Number of endorser transaction found in the block . |
32,371 | public EnvelopeInfo getEnvelopeInfo ( int envelopeIndex ) throws InvalidProtocolBufferException { try { EnvelopeInfo ret ; if ( isFiltered ( ) ) { switch ( filteredBlock . getFilteredTransactions ( envelopeIndex ) . getType ( ) . getNumber ( ) ) { case Common . HeaderType . ENDORSER_TRANSACTION_VALUE : ret = new TransactionEnvelopeInfo ( this . filteredBlock . getFilteredTransactions ( envelopeIndex ) ) ; break ; default : ret = new EnvelopeInfo ( this . filteredBlock . getFilteredTransactions ( envelopeIndex ) ) ; break ; } } else { EnvelopeDeserializer ed = EnvelopeDeserializer . newInstance ( block . getBlock ( ) . getData ( ) . getData ( envelopeIndex ) , block . getTransActionsMetaData ( ) [ envelopeIndex ] ) ; switch ( ed . getType ( ) ) { case Common . HeaderType . ENDORSER_TRANSACTION_VALUE : ret = new TransactionEnvelopeInfo ( ( EndorserTransactionEnvDeserializer ) ed ) ; break ; default : ret = new EnvelopeInfo ( ed ) ; break ; } } return ret ; } catch ( InvalidProtocolBufferRuntimeException e ) { throw e . getCause ( ) ; } } | Return a specific envelope in the block by it s index . |
32,372 | Ab . BroadcastResponse sendTransaction ( Common . Envelope transaction ) throws Exception { if ( shutdown ) { throw new TransactionException ( format ( "Orderer %s was shutdown." , name ) ) ; } logger . debug ( format ( "Orderer.sendTransaction %s" , toString ( ) ) ) ; OrdererClient localOrdererClient = getOrdererClient ( ) ; try { return localOrdererClient . sendTransaction ( transaction ) ; } catch ( Throwable t ) { removeOrdererClient ( true ) ; throw t ; } } | Send transaction to Order |
32,373 | public static ChaincodeCollectionConfiguration fromYamlFile ( File configFile ) throws InvalidArgumentException , IOException , ChaincodeCollectionConfigurationException { return fromFile ( configFile , false ) ; } | Creates a new ChaincodeCollectionConfiguration instance configured with details supplied in a YAML file . |
32,374 | public static ChaincodeCollectionConfiguration fromJsonFile ( File configFile ) throws InvalidArgumentException , IOException , ChaincodeCollectionConfigurationException { return fromFile ( configFile , true ) ; } | Creates a new ChaincodeCollectionConfiguration instance configured with details supplied in a JSON file . |
32,375 | public static ChaincodeCollectionConfiguration fromYamlStream ( InputStream configStream ) throws InvalidArgumentException , ChaincodeCollectionConfigurationException { logger . trace ( "ChaincodeCollectionConfiguration.fromYamlStream..." ) ; if ( configStream == null ) { throw new InvalidArgumentException ( "ConfigStream must be specified" ) ; } Yaml yaml = new Yaml ( ) ; @ SuppressWarnings ( "unchecked" ) List < Object > map = yaml . load ( configStream ) ; JsonArrayBuilder builder = Json . createArrayBuilder ( map ) ; JsonArray jsonConfig = builder . build ( ) ; return fromJsonObject ( jsonConfig ) ; } | Creates a new ChaincodeCollectionConfiguration instance configured with details supplied in YAML format |
32,376 | public static ChaincodeCollectionConfiguration fromJsonStream ( InputStream configStream ) throws InvalidArgumentException , ChaincodeCollectionConfigurationException { logger . trace ( "ChaincodeCollectionConfiguration.fromJsonStream..." ) ; if ( configStream == null ) { throw new InvalidArgumentException ( "configStream must be specified" ) ; } try ( JsonReader reader = Json . createReader ( configStream ) ) { return fromJsonObject ( ( JsonArray ) reader . read ( ) ) ; } } | Creates a new ChaincodeCollectionConfiguration instance configured with details supplied in JSON format |
32,377 | public static ChaincodeCollectionConfiguration fromJsonObject ( JsonArray jsonConfig ) throws InvalidArgumentException , ChaincodeCollectionConfigurationException { if ( jsonConfig == null ) { throw new InvalidArgumentException ( "jsonConfig must be specified" ) ; } if ( logger . isTraceEnabled ( ) ) { logger . trace ( format ( "ChaincodeCollectionConfiguration.fromJsonObject: %s" , jsonConfig . toString ( ) ) ) ; } return load ( jsonConfig ) ; } | Creates a new ChaincodeCollectionConfiguration instance configured with details supplied in a JSON object |
32,378 | private static ChaincodeCollectionConfiguration fromFile ( File configFile , boolean isJson ) throws InvalidArgumentException , IOException , ChaincodeCollectionConfigurationException { if ( configFile == null ) { throw new InvalidArgumentException ( "configFile must be specified" ) ; } if ( logger . isTraceEnabled ( ) ) { logger . trace ( format ( "ChaincodeCollectionConfiguration.fromFile: %s isJson = %b" , configFile . getAbsolutePath ( ) , isJson ) ) ; } try ( InputStream stream = new FileInputStream ( configFile ) ) { return isJson ? fromJsonStream ( stream ) : fromYamlStream ( stream ) ; } } | Loads a ChaincodeCollectionConfiguration object from a Json or Yaml file |
32,379 | private static ChaincodeCollectionConfiguration load ( JsonArray jsonConfig ) throws InvalidArgumentException , ChaincodeCollectionConfigurationException { if ( jsonConfig == null ) { throw new InvalidArgumentException ( "jsonConfig must be specified" ) ; } return new ChaincodeCollectionConfiguration ( jsonConfig ) ; } | Returns a new ChaincodeCollectionConfiguration instance and populates it from the specified JSON object |
32,380 | public byte [ ] getValidationParameter ( ) throws ProposalException { ByteString payloadBytes = parsePayload ( ) . getValidationParameter ( ) ; if ( null == payloadBytes ) { return null ; } return payloadBytes . toByteArray ( ) ; } | The validation parameter bytes that were set when the chaincode was defined . |
32,381 | public ChaincodeCollectionConfiguration getChaincodeCollectionConfiguration ( ) throws ProposalException { Collection . CollectionConfigPackage collections = parsePayload ( ) . getCollections ( ) ; if ( null == collections || ! parsePayload ( ) . hasCollections ( ) ) { return null ; } try { return ChaincodeCollectionConfiguration . fromCollectionConfigPackage ( collections ) ; } catch ( InvalidArgumentException e ) { throw new ProposalException ( e ) ; } } | The collection configuration this chaincode was defined . |
32,382 | public boolean verify ( ECP nym , IdemixIssuerPublicKey ipk , byte [ ] msg ) { if ( nym == null || ipk == null || msg == null ) { return false ; } ECP t = ipk . getHsk ( ) . mul2 ( proofSSk , ipk . getHRand ( ) , proofSRNym ) ; t . sub ( nym . mul ( proofC ) ) ; byte [ ] proofData = new byte [ 0 ] ; proofData = IdemixUtils . append ( proofData , NYM_SIGN_LABEL . getBytes ( ) ) ; proofData = IdemixUtils . append ( proofData , IdemixUtils . ecpToBytes ( t ) ) ; proofData = IdemixUtils . append ( proofData , IdemixUtils . ecpToBytes ( nym ) ) ; proofData = IdemixUtils . append ( proofData , ipk . getHash ( ) ) ; proofData = IdemixUtils . append ( proofData , msg ) ; BIG cvalue = IdemixUtils . hashModOrder ( proofData ) ; byte [ ] finalProofData = new byte [ 0 ] ; finalProofData = IdemixUtils . append ( finalProofData , IdemixUtils . bigToBytes ( cvalue ) ) ; finalProofData = IdemixUtils . append ( finalProofData , IdemixUtils . bigToBytes ( nonce ) ) ; byte [ ] hashedProofData = IdemixUtils . bigToBytes ( IdemixUtils . hashModOrder ( finalProofData ) ) ; return Arrays . equals ( IdemixUtils . bigToBytes ( proofC ) , hashedProofData ) ; } | Verify this IdemixPseudonymSignature |
32,383 | public Idemix . Signature toProto ( ) { Idemix . Signature . Builder builder = Idemix . Signature . newBuilder ( ) . setAPrime ( IdemixUtils . transformToProto ( aPrime ) ) . setABar ( IdemixUtils . transformToProto ( aBar ) ) . setBPrime ( IdemixUtils . transformToProto ( bPrime ) ) . setNym ( IdemixUtils . transformToProto ( nym ) ) . setProofC ( ByteString . copyFrom ( IdemixUtils . bigToBytes ( proofC ) ) ) . setProofSSk ( ByteString . copyFrom ( IdemixUtils . bigToBytes ( proofSSk ) ) ) . setProofSE ( ByteString . copyFrom ( IdemixUtils . bigToBytes ( proofSE ) ) ) . setProofSR2 ( ByteString . copyFrom ( IdemixUtils . bigToBytes ( proofSR2 ) ) ) . setProofSR3 ( ByteString . copyFrom ( IdemixUtils . bigToBytes ( proofSR3 ) ) ) . setProofSRNym ( ByteString . copyFrom ( IdemixUtils . bigToBytes ( proofSRNym ) ) ) . setProofSSPrime ( ByteString . copyFrom ( IdemixUtils . bigToBytes ( proofSSPrime ) ) ) . setNonce ( ByteString . copyFrom ( IdemixUtils . bigToBytes ( nonce ) ) ) . setRevocationEpochPk ( revocationPk ) . setRevocationPkSig ( ByteString . copyFrom ( revocationPKSig ) ) . setEpoch ( epoch ) . setNonRevocationProof ( nonRevocationProof ) ; for ( BIG attr : proofSAttrs ) { builder . addProofSAttrs ( ByteString . copyFrom ( IdemixUtils . bigToBytes ( attr ) ) ) ; } return builder . build ( ) ; } | Convert this signature to a proto |
32,384 | private int [ ] hiddenIndices ( boolean [ ] disclosure ) { if ( disclosure == null ) { throw new IllegalArgumentException ( "cannot compute hidden indices of null disclosure" ) ; } List < Integer > hiddenIndicesList = new ArrayList < > ( ) ; for ( int i = 0 ; i < disclosure . length ; i ++ ) { if ( ! disclosure [ i ] ) { hiddenIndicesList . add ( i ) ; } } int [ ] hiddenIndices = new int [ hiddenIndicesList . size ( ) ] ; for ( int i = 0 ; i < hiddenIndicesList . size ( ) ; i ++ ) { hiddenIndices [ i ] = hiddenIndicesList . get ( i ) ; } return hiddenIndices ; } | Some attributes may be hidden some disclosed . The indices of the hidden attributes will be passed . |
32,385 | public synchronized void setExecutorService ( ExecutorService executorService ) throws InvalidArgumentException { if ( executorService == null ) { throw new InvalidArgumentException ( "Executor service can not be null." ) ; } if ( this . executorService != null && this . executorService != executorService ) { throw new InvalidArgumentException ( "Executor service has already been set." ) ; } this . executorService = executorService ; } | Set executor service Applications need to set the executor service prior to doing any other operations on the client . |
32,386 | public Channel newChannel ( String name ) throws InvalidArgumentException { clientCheck ( ) ; if ( Utils . isNullOrEmpty ( name ) ) { throw new InvalidArgumentException ( "Channel name can not be null or empty string." ) ; } synchronized ( channels ) { if ( channels . containsKey ( name ) ) { throw new InvalidArgumentException ( format ( "Channel by the name %s already exists" , name ) ) ; } logger . trace ( "Creating channel :" + name ) ; Channel newChannel = Channel . createNewInstance ( name , this ) ; channels . put ( name , newChannel ) ; return newChannel ; } } | newChannel - already configured channel . |
32,387 | public Channel newChannel ( String name , Orderer orderer , ChannelConfiguration channelConfiguration , byte [ ] ... channelConfigurationSignatures ) throws TransactionException , InvalidArgumentException { clientCheck ( ) ; if ( Utils . isNullOrEmpty ( name ) ) { throw new InvalidArgumentException ( "Channel name can not be null or empty string." ) ; } synchronized ( channels ) { if ( channels . containsKey ( name ) ) { throw new InvalidArgumentException ( format ( "Channel by the name %s already exits" , name ) ) ; } logger . trace ( "Creating channel :" + name ) ; Channel newChannel = Channel . createNewInstance ( name , this , orderer , channelConfiguration , channelConfigurationSignatures ) ; channels . put ( name , newChannel ) ; return newChannel ; } } | Create a new channel |
32,388 | public Peer newPeer ( String name , String grpcURL ) throws InvalidArgumentException { clientCheck ( ) ; return Peer . createNewInstance ( name , grpcURL , null ) ; } | newPeer create a new peer |
32,389 | public Collection < LifecycleQueryInstalledChaincodeProposalResponse > sendLifecycleQueryInstalledChaincode ( LifecycleQueryInstalledChaincodeRequest lifecycleQueryInstalledChaincodeRequest , Collection < Peer > peers ) throws InvalidArgumentException , ProposalException { if ( null == lifecycleQueryInstalledChaincodeRequest ) { throw new InvalidArgumentException ( "The lifecycleQueryInstalledChaincodeRequest parameter can not be null." ) ; } clientCheck ( ) ; if ( null == peers ) { throw new InvalidArgumentException ( "The parameter peers set to null" ) ; } if ( peers . isEmpty ( ) ) { throw new InvalidArgumentException ( "Peers to query is empty." ) ; } if ( lifecycleQueryInstalledChaincodeRequest == null ) { throw new InvalidArgumentException ( "The lifecycleQueryInstalledChaincoded parameter must not be null." ) ; } if ( Utils . isNullOrEmpty ( lifecycleQueryInstalledChaincodeRequest . getPackageId ( ) ) ) { throw new InvalidArgumentException ( "The lifecycleQueryInstalledChaincoded packageID parameter must not be null." ) ; } try { Channel systemChannel = Channel . newSystemChannel ( this ) ; return systemChannel . lifecycleQueryInstalledChaincode ( lifecycleQueryInstalledChaincodeRequest , peers ) ; } catch ( ProposalException e ) { logger . error ( format ( "lifecycleQueryInstalledChaincodeRequest for failed. %s" , e . getMessage ( ) ) , e ) ; throw e ; } } | Query installed chaincode on a peer . |
32,390 | public Collection < LifecycleQueryInstalledChaincodesProposalResponse > sendLifecycleQueryInstalledChaincodes ( LifecycleQueryInstalledChaincodesRequest lifecycleQueryInstalledChaincodesRequest , Collection < Peer > peers ) throws InvalidArgumentException , ProposalException { if ( null == lifecycleQueryInstalledChaincodesRequest ) { throw new InvalidArgumentException ( "The lifecycleQueryInstalledChaincodesRequest parameter can not be null." ) ; } clientCheck ( ) ; if ( null == peers ) { throw new InvalidArgumentException ( "The peers set to null" ) ; } if ( peers . isEmpty ( ) ) { throw new InvalidArgumentException ( "The peers parameter is empty." ) ; } try { Channel systemChannel = Channel . newSystemChannel ( this ) ; return systemChannel . lifecycleQueryInstalledChaincodes ( lifecycleQueryInstalledChaincodesRequest , peers ) ; } catch ( ProposalException e ) { logger . error ( e ) ; throw e ; } } | Query the peer for installed chaincodes information |
32,391 | public User setUserContext ( User userContext ) throws InvalidArgumentException { if ( null == cryptoSuite ) { throw new InvalidArgumentException ( "No cryptoSuite has been set." ) ; } userContextCheck ( userContext ) ; User ret = this . userContext ; this . userContext = userContext ; logger . debug ( format ( "Setting user context to MSPID: %s user: %s" , userContext . getMspId ( ) , userContext . getName ( ) ) ) ; return ret ; } | Set the User context for this client . |
32,392 | public Orderer newOrderer ( String name , String grpcURL ) throws InvalidArgumentException { clientCheck ( ) ; return newOrderer ( name , grpcURL , null ) ; } | Create a new urlOrderer . |
32,393 | public Orderer newOrderer ( String name , String grpcURL , Properties properties ) throws InvalidArgumentException { clientCheck ( ) ; return Orderer . createNewInstance ( name , grpcURL , properties ) ; } | Create a new orderer . |
32,394 | public Set < String > queryChannels ( Peer peer ) throws InvalidArgumentException , ProposalException { clientCheck ( ) ; if ( null == peer ) { throw new InvalidArgumentException ( "peer set to null" ) ; } try { Channel systemChannel = Channel . newSystemChannel ( this ) ; return systemChannel . queryChannels ( peer ) ; } catch ( InvalidArgumentException e ) { throw e ; } catch ( ProposalException e ) { logger . error ( format ( "queryChannels for peer %s failed." + e . getMessage ( ) , peer . getName ( ) ) , e ) ; throw e ; } } | Query the joined channels for peers |
32,395 | public List < ChaincodeInfo > queryInstalledChaincodes ( Peer peer ) throws InvalidArgumentException , ProposalException { clientCheck ( ) ; if ( null == peer ) { throw new InvalidArgumentException ( "peer set to null" ) ; } try { Channel systemChannel = Channel . newSystemChannel ( this ) ; return systemChannel . queryInstalledChaincodes ( peer ) ; } catch ( ProposalException e ) { logger . error ( format ( "queryInstalledChaincodes for peer %s failed." + e . getMessage ( ) , peer . getName ( ) ) , e ) ; throw e ; } } | Query the peer for installed chaincode information |
32,396 | public byte [ ] getChannelConfigurationSignature ( ChannelConfiguration channelConfiguration , User signer ) throws InvalidArgumentException { clientCheck ( ) ; Channel systemChannel = Channel . newSystemChannel ( this ) ; return systemChannel . getChannelConfigurationSignature ( channelConfiguration , signer ) ; } | Get signature for channel configuration |
32,397 | public byte [ ] getUpdateChannelConfigurationSignature ( UpdateChannelConfiguration updateChannelConfiguration , User signer ) throws InvalidArgumentException { clientCheck ( ) ; Channel systemChannel = Channel . newSystemChannel ( this ) ; return systemChannel . getUpdateChannelConfigurationSignature ( updateChannelConfiguration , signer ) ; } | Get signature for update channel configuration |
32,398 | private String getProperty ( String property ) { String ret = sdkProperties . getProperty ( property ) ; if ( null == ret ) { logger . warn ( String . format ( "No configuration value found for '%s'" , property ) ) ; } return ret ; } | getProperty return back property for the given value . |
32,399 | public byte [ ] getPayload ( ) { ByteString ret = getChaincodeEvent ( ) . getPayload ( ) ; if ( null == ret ) { return null ; } return ret . toByteArray ( ) ; } | Binary data associated with this event . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.