Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openssl: add fallback for ripemd160 implementation #59

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
black . --check --diff
- name: flake8 check
run: |
flake8 --ignore=E501,E731,W503
make check-flake8
- name: Test with pytest
run: |
pytest tests
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /usr/bin/make

PYTHONFILES := $(shell find * -name '*.py')
PYTHONFILES := $(shell find * ! -path "build/*" ! -path "venv/*" -name '*.py')
POSSIBLE_PYTEST_NAMES=pytest-3 pytest3 pytest
PYTEST := $(shell for p in $(POSSIBLE_PYTEST_NAMES); do if type $$p > /dev/null; then echo $$p; break; fi done)
TEST_DIR=tests
Expand All @@ -16,7 +16,7 @@ check: check-pytest-found
check-source: check-fmt check-flake8 check-mypy check-internal-tests

check-flake8:
flake8 --ignore=E501,E731,W503
flake8 --ignore=E501,E731,W503 --exclude=venv\/,build\/

check-mypy:
mypy --ignore-missing-imports --disallow-untyped-defs --disallow-incomplete-defs $(PYTHONFILES)
Expand Down
10 changes: 4 additions & 6 deletions docker/Dockerfile.clightning
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM ubuntu:20.04
FROM ubuntu:22.04
LABEL mantainer="Vincenzo Palazzo vincenzopalazzodev@gmail.com"

WORKDIR /work

ENV BITCOIN_VERSION=23.0
ENV CLIGHTNING_VERSION=0.11.0
ENV CLIGHTNING_VERSION=0.12.0
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get -qq update && \
Expand Down Expand Up @@ -59,10 +59,8 @@ RUN pip3 install -U pip && \
RUN git config --global user.name "John Doe" && \
git config --global user.email johndoe@example.com && \
git clone https://github.com/ElementsProject/lightning.git && \
cd lightning && \
# git checkout v$CLIGHTNING_VERSION && \
# fetch core lightning patch
git pull origin pull/5367/head && \
cd lightning && \
git checkout v$CLIGHTNING_VERSION && \
poetry config virtualenvs.create false && \
poetry install && \
./configure --enable-developer && \
Expand Down
2 changes: 1 addition & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/bash
cd lnprototest || exit
for i in range{0..20};
for i in range{0..14};
do
if make check PYTEST_ARGS='--runner=lnprototest.clightning.Runner -n4 --dist=loadfile --log-cli-level=DEBUG'; then
echo "iteration $i succeeded"
Expand Down
7 changes: 1 addition & 6 deletions lnprototest/backend/bitcoind.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ def f(*args: Any) -> Callable:
"Calling {name} with arguments {args}".format(name=name, args=args)
)
res = self.__proxy._call(name, *args)
logging.debug(
"Result for {name} call: {res}".format(
name=name,
res=res,
)
)
logging.debug("Result for {name} call: {res}".format(name=name, res=res))
return res

# Make debuggers show <function bitcoin.rpc.name> rather than <function
Expand Down
1 change: 1 addition & 0 deletions lnprototest/clightning/clightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def start(self, also_bitcoind: bool = True) -> None:
"--bitcoin-rpcport={}".format(self.bitcoind.port),
"--log-level=debug",
"--log-file=log",
"--htlc-maximum-msat=2000sat",
]
+ self.startup_flags
)
Expand Down
18 changes: 12 additions & 6 deletions lnprototest/commit_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
CTxWitness,
CScriptWitness,
)
from bitcoin.core.contrib.ripemd160 import ripemd160
import bitcoin.core.script as script
from bitcoin.core.script import CScript
import struct
import hashlib
from hashlib import sha256
from .keyset import KeySet
from .errors import SpecFileError, EventError
Expand Down Expand Up @@ -111,9 +111,7 @@ def __init__(

@staticmethod
def ripemd160(b: bytes) -> bytes:
hasher = hashlib.new("ripemd160")
hasher.update(b)
return hasher.digest()
return ripemd160(b)

def revocation_privkey(self, side: Side) -> coincurve.PrivateKey:
"""Derive the privkey used for the revocation of side's commitment transaction."""
Expand Down Expand Up @@ -1178,7 +1176,11 @@ def test_simple_commitment() -> None:
# x_local_per_commitment_secret: 1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a0908070605040302010001

# This is not derived as expected, but defined :(
c.keyset[Side.local].raw_per_commit_secret = lambda _: coincurve.PrivateKey(bytes.fromhex("1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100")) # type: ignore
c.keyset[Side.local].raw_per_commit_secret = lambda _: coincurve.PrivateKey(
bytes.fromhex(
"1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"
)
) # type: ignore

# BOLT #3:
# commitment_number: 42
Expand Down Expand Up @@ -1975,7 +1977,11 @@ def test_anchor_commitment() -> None:
# x_local_per_commitment_secret: 1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a0908070605040302010001

# This is not derived as expected, but defined :(
c.keyset[Side.local].raw_per_commit_secret = lambda _: coincurve.PrivateKey(bytes.fromhex("1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100")) # type: ignore
c.keyset[Side.local].raw_per_commit_secret = lambda _: coincurve.PrivateKey(
bytes.fromhex(
"1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"
)
) # type: ignore

# BOLT #3:
# commitment_number: 42
Expand Down
15 changes: 7 additions & 8 deletions lnprototest/funding.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,15 +524,14 @@ def channel_update(
if disable:
channel_flags |= 2

# BOLT #7: The `message_flags` bitfield is used to indicate the
# presence of optional fields in the `channel_update` message:
# BOLT #7: The message_flags bitfield is used to provide additional
# details about the message:
#
# | Bit Position | Name | Field |
# | ------------- | ------------------------- | -------------------------------- |
# | 0 | `option_channel_htlc_max` | `htlc_maximum_msat` |
message_flags = 0
if htlc_maximum_msat:
message_flags |= 1
# | Bit Position | Name |
# | ------------- | ---------------|
# | 0 | `must_be_one` |
# | 1 | `dont_forward` |
message_flags = 1

# Begin with a fake signature.
update = Message(
Expand Down
9 changes: 1 addition & 8 deletions lnprototest/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@
from .utils import privkey_expand
from .keyset import KeySet
from abc import ABC, abstractmethod
from typing import (
Dict,
Optional,
List,
Union,
Any,
Callable,
)
vincenzopalazzo marked this conversation as resolved.
Show resolved Hide resolved
from typing import Dict, Optional, List, Union, Any, Callable


class Conn(object):
Expand Down
Loading