[golang] github.com의 private repo 접근하기

$ git config --global url.git@github.com:.insteadOf https://dasomoli@github.com/
$ go get github.com/dasomoli/private-repo

참고: https://stackoverflow.com/questions/27500861/whats-the-proper-way-to-go-get-a-private-repository

[Ethereum] 키와 주소

타원 곡선 함수, Elliptic curve cryptography 에서 다음 p를 사용

p = 2**256 - 2**32 - 2**9 - 2**8 - 2**7 - 2**6 - 2**4 - 1
y ** 2 mod p = (x ** 3 + 7) mod p

Private key -> Public key -> Address 로 얻는다.

개인키 (Private key)

k가 private key.

k = rand() % (2 ** 256), 따라서 256 bits, 64 bytes.

공개키 (Public key)

K가 public key로 (x, y) 좌표. G는 미리 정의된 값.

K = k * G = (x, y)

Public key, K를 표현할 때는 Standards for Efficient Cryptography (SEC1)Serialized EC public key prefixes 의 prefix를 사용해서 나타낸다. 이더리움은 uncompressed point만을 지원하므로 0x04 prefix로 사용한다. 따라서 0x04 뒤에 x와 y를 concatenate한다.

0x04 | x | y

주소 (Address)

keccak-256 Hash function을 사용. Public key (x, y)를 concatenate한 값(0x04가 붙지 않았다!)을 keccak-256 로 hash 값을 얻은 후 마지막 20 바이트 값을 사용한다.

(keccak-256(x | y))[-20:]

[github] Public repo를 private으로 바꾸기

public project를 가져와서 혼자 몰래 뭘 해보고 싶을 때, Apache 2.0 License 등 derived works의 source code 공개 의무가 없는 프로젝트의 경우 private으로 바꿔서 작업을 해볼 수 있다.

다음과 같이 한다.

먼저 만들고 싶은 이름으로 github에서 project를 하나 private으로 만든다.

$ git clone --bare https://github.com/publicproject/project.git
$ cd project.git
$ git push --mirror https://github.com/myname/myproject.git

그리고 나서 실제로 clone해서 쓰면 된다.

$ git push https://github.com/myname/myproject.git

최신 코드로의 업데이트는 public repository를 여기다 remote로 추가해서 fetch & rebase하면 된다.

push는 public으로 fork해온 후 거기다 push 해서 pull request하면 될 듯.

참고: https://medium.com/@bilalbayasut/github-how-to-make-a-fork-of-public-repository-private-6ee8cacaf9d3