Create a key list key structure where all the keys in the list are required to sign transactions that modify accounts, topics, tokens, smart contracts, or files. A key list can contain a Ed25519 or ECDSA (secp256k1_)_ key type.
If all the keys in the key list key structure do not sign, the transaction will fail and return an "INVALID_SIGNATURE" error. A key list can have repeated keys. A signature for the repeated key will count as many times as the key is listed in the key list. For example, a key list has three keys. Two of the three public keys in the list are the same. When a user signs a transaction with the repeated key it will account for two out of the three keys required signature.
Method
Type
Description
KeyList.of(<keys>)
Key
Keys to add to the key list
//Generate 3 keysPrivateKey key1 =PrivateKey.generate();PublicKey publicKey1 =key1.getPublicKey();PrivateKey key2 =PrivateKey.generate();PublicKey publicKey2 =key2.getPublicKey();PrivateKey key3 =PrivateKey.generate();PublicKey publicKey3 =key3.getPublicKey();//Create a key list where all 3 keys are required to signKeyList keyStructure =KeyList.of(key1, key2, key3);System.println(keyStructure)//v2.0.0
//Generate 3 keysconst key1 =PrivateKey.generate();const publicKey1 =key1.publicKey;const key2 =PrivateKey.generate();const publicKey2 =key2.publicKey;const key3 =PrivateKey.generate();const publicKey3 =key3.publicKey;//Create a list of the keysconst publicKeyList = [];publicKeyList.push(publicKey1);publicKeyList.push(publicKey2);publicKeyList.push(publicKey3);//Create a key list where all 3 keys are required to signconst keys =newKeyList(publicKeyList);//v2.0.13
//Generate 3 keyskey1, err :=hedera.GeneratePrivateKey()if err != nil {panic(err)}publicKey1, err :=key1.PublicKey()key2, err :=hedera.GeneratePrivateKey()if err != nil {panic(err)}publicKey2, err :=key2.PublicKey()key3, err :=hedera.GeneratePrivateKey()if err != nil {panic(err)}publicKey3, err :=key3.PublicKey()//Create a key list where all 3 keys are required to signkeys :=make([]hedera.PublicKey,3)keys[0] = publicKey1keys[1] = publicKey2keys[2] = publicKey3keyStructure :=hedera.NewKeyList().AddAllPublicKeys(keys)fmt.Printf("The key list is %v\n", keyStructure) //v2.0.0