This will register the secret and set the lock to the unlocked stated.

    Even though the lock is unlock it is *not* claimed. The capacity will
    increase once the next balance proof is received.
963737
def register_offchain_secret(
        channel_state: NettingChannelState,
        secret: Secret,
        secrethash: SecretHash,
) -> None:
    
    our_state = channel_state.our_state
    partner_state = channel_state.partner_state

    register_secret_endstate(our_state, secret, secrethash)
    register_secret_endstate(partner_state, secret, secrethash)
325300
def unlocked(self):
        
        achieved = CRef.cbool()
        result = self._iface.get_ach(self.name, achieved)

        if not result:
            return False

        return bool(achieved)
484189
def sign(self, message, privkey, secret):
        
        m = self.GFn.value(message)
        x = self.GFn.value(privkey)
        k = self.GFn.value(secret)

        R = self.G * k

        r = self.GFn.value(R.x)
        s = (m + x * r) / k

        return (r, s)
1081583
def leak(self):
        
        capacity, last_leak = self.storage.mget(self.key_amount, self.key_last_leak,
                coherent=True)

        now = time.time()

        if last_leak:
            elapsed = now - last_leak
            decrement = elapsed * self.rate

            new_capacity = max(int(capacity - decrement), 0)
        else:
            new_capacity = 0

        self.storage.mset({
            self.key_amount: new_capacity,
            self.key_last_leak: now,
        })

        return new_capacity
510925
final protected synchronized void set(boolean verifyChecksum,
      Checksum sum, int maxChunkSize, int checksumSize ) {
    this.verifyChecksum = verifyChecksum;
    this.sum = sum;
    this.buf = new byte[maxChunkSize];
    this.checksum = new byte[checksumSize];
    this.count = 0;
    this.pos = 0;
  }
1027801
public void setCapacity(int capacity) {
        if (capacity < 0) {
            throw new IllegalArgumentException();
        }
        this.capacity = Math.min(capacity, MAXIMUM_CAPACITY);

        evictionLock.lock();
        try {
            drainBuffers(AMORTIZED_DRAIN_THRESHOLD);
            evict();
        } finally {
            evictionLock.unlock();
        }
        notifyListener();
    }
67599
def release_lock(self):
    
    if not self._lock.acquired:
      return False
    else:
      self._lock.release()
      return True
361887
def is_lock_expired(
        end_state: NettingChannelEndState,
        lock: LockType,
        block_number: BlockNumber,
        lock_expiration_threshold: BlockNumber,
) -> SuccessOrError:
    

    secret_registered_on_chain = lock.secrethash in end_state.secrethashes_to_onchain_unlockedlocks
    if secret_registered_on_chain:
        return (False, 'lock has been unlocked on-chain')

    if block_number < lock_expiration_threshold:
        msg = (
            f'current block number ({block_number}) is not larger than '
            f'lock.expiration + confirmation blocks ({lock_expiration_threshold})'
        )
        return (False, msg)

    return (True, None)
801505
public void proveIdentity(byte[] sharedSecret, KeyPair key) throws IOException, GeneralSecurityException {
        String algorithm = detectKeyAlgorithm(key);
        writeUTF(algorithm);
        writeKey(key.getPublic());

        Signature sig = Signature.getInstance("SHA1with"+algorithm);
        sig.initSign(key.getPrivate());
        sig.update(key.getPublic().getEncoded());
        sig.update(sharedSecret);
        writeObject(sig.sign());
    }
1355981
def changememokey(ctx, key, account):
    
    pprint(ctx.blockchain.update_memo_key(key, account=account))
903700
def handle_unlock(
        target_state: TargetTransferState,
        state_change: ReceiveUnlock,
        channel_state: NettingChannelState,
) -> TransitionResult[TargetTransferState]:
    
    balance_proof_sender = state_change.balance_proof.sender

    is_valid, events, _ = channel.handle_unlock(
        channel_state,
        state_change,
    )
    next_target_state: Optional[TargetTransferState] = target_state

    if is_valid:
        transfer = target_state.transfer
        payment_received_success = EventPaymentReceivedSuccess(
            payment_network_identifier=channel_state.payment_network_identifier,
            token_network_identifier=TokenNetworkID(channel_state.token_network_identifier),
            identifier=transfer.payment_identifier,
            amount=TokenAmount(transfer.lock.amount),
            initiator=transfer.initiator,
        )

        unlock_success = EventUnlockClaimSuccess(
            transfer.payment_identifier,
            transfer.lock.secrethash,
        )

        send_processed = SendProcessed(
            recipient=balance_proof_sender,
            channel_identifier=CHANNEL_IDENTIFIER_GLOBAL_QUEUE,
            message_identifier=state_change.message_identifier,
        )

        events.extend([payment_received_success, unlock_success, send_processed])
        next_target_state = None

    return TransitionResult(next_target_state, events)
628110
def lock(self):
        
        if self.cache.get(self.lock_name):
            return False
        else:
            self.cache.set(self.lock_name, timezone.now(), self.timeout)
            return True
211571
def set_unlock_previous(self, unlock_previous):
        """"""
        if unlock_previous is None:
            raise NullArgument('unlock_previous cannot be None')
        if unlock_previous is not None and not utilities.is_string(unlock_previous):
            raise InvalidArgument('unlock_previous must be a string')
        self.my_osid_object_form._my_map['unlockPrevious'] = unlock_previous
309529
def _del_lock(end_state: NettingChannelEndState, secrethash: SecretHash) -> None:
    
    assert is_lock_pending(end_state, secrethash)

    _del_unclaimed_lock(end_state, secrethash)

    if secrethash in end_state.secrethashes_to_onchain_unlockedlocks:
        del end_state.secrethashes_to_onchain_unlockedlocks[secrethash]
1207132
def lock_exists_in_either_channel_side(
        channel_state: NettingChannelState,
        secrethash: SecretHash,
) -> bool:
    """"""
    lock = get_lock(channel_state.our_state, secrethash)
    if not lock:
        lock = get_lock(channel_state.partner_state, secrethash)
    return lock is not None
520975
def verify(self, secret_key):
        
        verification_input = NotificationMessage.SERVICE_NAME
        verification_input += NotificationMessage.OPERATION_NAME
        verification_input += self.timestamp
        h = hmac.new(key=secret_key, digestmod=sha)
        h.update(verification_input)
        signature_calc = base64.b64encode(h.digest())
        return self.signature == signature_calc
1280025
def is_lock_pending(
        end_state: NettingChannelEndState,
        secrethash: SecretHash,
) -> bool:
    
    return (
        secrethash in end_state.secrethashes_to_lockedlocks or
        secrethash in end_state.secrethashes_to_unlockedlocks or
        secrethash in end_state.secrethashes_to_onchain_unlockedlocks
    )