How to use the nucypher.crypto.powers.SigningPower function in nucypher

To help you get started, we’ve selected a few nucypher examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github drbh / ncipfs / ncipfs.py View on Github external
def creat_nucid(alice, cid, enc_pubkey, sig_pubkey, label):
    powers_and_material = { DecryptingPower: enc_pubkey, SigningPower: sig_pubkey }
    doctor_strange = Bob.from_public_keys(powers_and_material=powers_and_material, federated_only=True)
    policy_end_datetime = maya.now() + datetime.timedelta(days=5)
    # m, n = 1, 2
    m, n = 2, 3
    print(doctor_strange, label, m, n, policy_end_datetime)
    print(alice)
    policy = alice.grant(bob=doctor_strange, label=label, m=m, n=n, expiration=policy_end_datetime)
    policy_info = {
        "policy_pubkey": base58.b58encode(policy.public_key.to_bytes()).decode("utf-8"),
        "alice_sig_pubkey": base58.b58encode(bytes(alice.stamp)).decode("utf-8"),
        "label": label.decode("utf-8"),
    }
    
    store_url = "%s_%s_%s_%s"%(cid,
                               base58.b58encode(policy.public_key.to_bytes()).decode("utf-8"),
                               base58.b58encode(bytes(alice.stamp)).decode("utf-8"),
github drbh / ncipfs / ncipfs.py View on Github external
def act_as_bob(self, name):
        dirname = "accounts/" + name + "/"
        fname = dirname+"recipent.private.json"
        with open(fname) as data_file:    
            data = json.load(data_file)
        enc_privkey = UmbralPrivateKey.from_bytes(bytes.fromhex(data["enc"]))
        sig_privkey = UmbralPrivateKey.from_bytes(bytes.fromhex(data["sig"]))
        
        bob_enc_keypair = DecryptingKeypair(private_key=enc_privkey)
        bob_sig_keypair = SigningKeypair(private_key=sig_privkey)
        enc_power = DecryptingPower(keypair=bob_enc_keypair)
        sig_power = SigningPower(keypair=bob_sig_keypair)
        power_ups = [enc_power, sig_power]
        bob = Bob(
            is_me=True,
            federated_only=True,
            crypto_power_ups=power_ups,
            start_learning_now=True,
            abort_on_learning_error=True,
            known_nodes=[self.ursula],
            save_metadata=False,
            network_middleware=RestMiddleware(),
        )
        return bob