import $protobuf from "protobufjs/minimal.js" ; const $Reader = $protobuf . Reader , $Writer = $protobuf . Writer , $util = $protobuf . util ; const $root = $protobuf . roots [ "libp2p-crypto-keys" ] || ( $protobuf . roots [ "libp2p-crypto-keys" ] = { } ) ; exports enum { number } property property property export const KeyType = $root . KeyType = ( ( ) => { const valuesById = { } , values = Object . create ( valuesById ) ; values [ valuesById [ 0 ] = "RSA" ] = 0 ; values [ valuesById [ 1 ] = "Ed25519" ] = 1 ; values [ valuesById [ 2 ] = "Secp256k1" ] = 2 ; return values ; } ) ( ) ; exports interface property property exports classdesc implements IPublicKey constructor param { IPublicKey = } p export function PublicKey ( p ) { if ( p ) for ( var ks = Object . keys ( p ) , i = 0 ; i < ks . length ; ++ i ) if ( p [ ks [ i ] ] != null ) this [ ks [ i ] ] = p [ ks [ i ] ] ; } member memberof instance PublicKey . prototype . Type = 0 ; member memberof instance PublicKey . prototype . Data = $util . newBuffer ( [ ] ) ; /**
 * Encodes the specified PublicKey message. Does not implicitly  PublicKey . verify messages.
 *  function memberof static param { IPublicKey } m param { $protobuf . Writer } w returns { $protobuf . Writer } PublicKey . encode = function encode ( m , w ) { if ( ! w ) w = $Writer . create ( ) ; w . uint32 ( 8 ) . int32 ( m . Type ) ; w . uint32 ( 18 ) . bytes ( m . Data ) ; return w ; } ; function memberof static param { $protobuf . Reader | Uint8Array } r param { number } l returns { PublicKey } throws throws PublicKey . decode = function decode ( r , l ) { if ( ! ( r instanceof $Reader ) ) r = $Reader . create ( r ) ; var c = l === undefined ? r . len : r . pos + l , m = new PublicKey ( ) ; while ( r . pos < c ) { var t = r . uint32 ( ) ; switch ( t >>> 3 ) { case 1 : m . Type = r . int32 ( ) ; break ; case 2 : m . Data = r . bytes ( ) ; break ; default : r . skipType ( t & 7 ) ; break ; } } if ( ! m . hasOwnProperty ( "Type" ) ) throw $util . ProtocolError ( "missing required 'Type'" , { instance : m } ) ; if ( ! m . hasOwnProperty ( "Data" ) ) throw $util . ProtocolError ( "missing required 'Data'" , { instance : m } ) ; return m ; } ; function memberof static param { Object . < string , * > } d returns { PublicKey } PublicKey . fromObject = function fromObject ( d ) { if ( d instanceof PublicKey ) return d ; var m = new PublicKey ( ) ; switch ( d . Type ) { case "RSA" : case 0 : m . Type = 0 ; break ; case "Ed25519" : case 1 : m . Type = 1 ; break ; case "Secp256k1" : case 2 : m . Type = 2 ; break ; } if ( d . Data != null ) { if ( typeof d . Data === "string" ) $util . base64 . decode ( d . Data , m . Data = $util . newBuffer ( $util . base64 . length ( d . Data ) ) , 0 ) ; else if ( d . Data . length ) m . Data = d . Data ; } return m ; } ; function memberof static param { PublicKey } m param { $protobuf . IConversionOptions } o returns { Object . < string , * > } PublicKey . toObject = function toObject ( m , o ) { if ( ! o ) o = { } ; var d = { } ; if ( o . defaults ) { d . Type = o . enums === String ? "RSA" : 0 ; if ( o . bytes === String ) d . Data = "" ; else { d . Data = [ ] ; if ( o . bytes !== Array ) d . Data = $util . newBuffer ( d . Data ) ; } } if ( m . Type != null && m . hasOwnProperty ( "Type" ) ) { d . Type = o . enums === String ? $root . KeyType [ m . Type ] : m . Type ; } if ( m . Data != null && m . hasOwnProperty ( "Data" ) ) { d . Data = o . bytes === String ? $util . base64 . encode ( m . Data , 0 , m . Data . length ) : o . bytes === Array ? Array . prototype . slice . call ( m . Data ) : m . Data ; } return d ; } ; function memberof instance returns { Object . < string , * > } PublicKey . prototype . toJSON = function toJSON ( ) { return this . constructor . toObject ( this , $protobuf . util . toJSONOptions ) ; } ; exports interface property property exports classdesc implements IPrivateKey constructor param { IPrivateKey = } p export function PrivateKey ( p ) { if ( p ) for ( var ks = Object . keys ( p ) , i = 0 ; i < ks . length ; ++ i ) if ( p [ ks [ i ] ] != null ) this [ ks [ i ] ] = p [ ks [ i ] ] ; } member memberof instance PrivateKey . prototype . Type = 0 ; member memberof instance PrivateKey . prototype . Data = $util . newBuffer ( [ ] ) ; /**
 * Encodes the specified PrivateKey message. Does not implicitly  PrivateKey . verify messages.
 *  function memberof static param { IPrivateKey } m param { $protobuf . Writer } w returns { $protobuf . Writer } PrivateKey . encode = function encode ( m , w ) { if ( ! w ) w = $Writer . create ( ) ; w . uint32 ( 8 ) . int32 ( m . Type ) ; w . uint32 ( 18 ) . bytes ( m . Data ) ; return w ; } ; function memberof static param { $protobuf . Reader | Uint8Array } r param { number } l returns { PrivateKey } throws throws PrivateKey . decode = function decode ( r , l ) { if ( ! ( r instanceof $Reader ) ) r = $Reader . create ( r ) ; var c = l === undefined ? r . len : r . pos + l , m = new PrivateKey ( ) ; while ( r . pos < c ) { var t = r . uint32 ( ) ; switch ( t >>> 3 ) { case 1 : m . Type = r . int32 ( ) ; break ; case 2 : m . Data = r . bytes ( ) ; break ; default : r . skipType ( t & 7 ) ; break ; } } if ( ! m . hasOwnProperty ( "Type" ) ) throw $util . ProtocolError ( "missing required 'Type'" , { instance : m } ) ; if ( ! m . hasOwnProperty ( "Data" ) ) throw $util . ProtocolError ( "missing required 'Data'" , { instance : m } ) ; return m ; } ; function memberof static param { Object . < string , * > } d returns { PrivateKey } PrivateKey . fromObject = function fromObject ( d ) { if ( d instanceof PrivateKey ) return d ; var m = new PrivateKey ( ) ; switch ( d . Type ) { case "RSA" : case 0 : m . Type = 0 ; break ; case "Ed25519" : case 1 : m . Type = 1 ; break ; case "Secp256k1" : case 2 : m . Type = 2 ; break ; } if ( d . Data != null ) { if ( typeof d . Data === "string" ) $util . base64 . decode ( d . Data , m . Data = $util . newBuffer ( $util . base64 . length ( d . Data ) ) , 0 ) ; else if ( d . Data . length ) m . Data = d . Data ; } return m ; } ; function memberof static param { PrivateKey } m param { $protobuf . IConversionOptions } o returns { Object . < string , * > } PrivateKey . toObject = function toObject ( m , o ) { if ( ! o ) o = { } ; var d = { } ; if ( o . defaults ) { d . Type = o . enums === String ? "RSA" : 0 ; if ( o . bytes === String ) d . Data = "" ; else { d . Data = [ ] ; if ( o . bytes !== Array ) d . Data = $util . newBuffer ( d . Data ) ; } } if ( m . Type != null && m . hasOwnProperty ( "Type" ) ) { d . Type = o . enums === String ? $root . KeyType [ m . Type ] : m . Type ; } if ( m . Data != null && m . hasOwnProperty ( "Data" ) ) { d . Data = o . bytes === String ? $util . base64 . encode ( m . Data , 0 , m . Data . length ) : o . bytes === Array ? Array . prototype . slice . call ( m . Data ) : m . Data ; } return d ; } ; function memberof instance returns { Object . < string , * > } PrivateKey . prototype . toJSON = function toJSON ( ) { return this . constructor . toObject ( this , $protobuf . util . toJSONOptions ) ; } ;