GALENOS OFFLINE VERIFICATION KIT
================================

Contents (exact schema-v2 inventory, 20 files)
  verify_offline.py          Python 3 standard-library verifier (no network calls)
  portfolio-manifest.json    14 receipt entries and portfolioRootSha256
  *-audit.json               the 14 audit receipts named in the manifest
  galenos_core-dossier.json  dossier scaffold referenced by the core audit
  public-provenance.json     public input provenance manifest
  README.txt                 this file
  SHA256SUMS                 SHA-256 of every file above

Authenticate first, execute second
  Run this one command in the folder that holds the two downloads
  (galenos-offline-kit.tar and verify_offline.py), before extracting the
  archive or running any file from it. An altered archive can carry an
  altered verify_offline.py, and an altered download of verify_offline.py
  can print any result. The operating-system shasum tool therefore checks
  both files against pinned SHA-256 values before Python starts, and the
  verifier runs only when both match.

  printf '%s  galenos-offline-kit.tar\n%s  verify_offline.py\n' '<ARCHIVE_SHA256>' 'ad57bb9ccd847a1fc6c3a763fc81c3f36b882bc5c8d77868bbcf0f43c1f63afc' | shasum -a 256 -c - && python3 -I verify_offline.py --archive galenos-offline-kit.tar --expect-archive-sha256 '<ARCHIVE_SHA256>'

  Prerequisite for publisher authenticity: obtain the two expected SHA-256
  values (for galenos-offline-kit.tar and for verify_offline.py) from a
  release channel that is authenticated independently of the GALENOS site,
  such as the audited git release commit or a signed release record. Put the
  archive value in place of <ARCHIVE_SHA256> (it appears twice) and
  compare the verifier value with the one in the command.
  The GALENOS sign-off, status and evidence pages show the same command with
  both digests filled in. Those digests are served by the same site as the
  two files, so running the command with them is a transfer-integrity check
  only. It does not authenticate the publisher.
  verify_offline.py SHA-256 for this release:
  ad57bb9ccd847a1fc6c3a763fc81c3f36b882bc5c8d77868bbcf0f43c1f63afc
  On Linux, sha256sum -c - does the same as shasum -a 256 -c -. Add
  --tamper-self-test to also require that mutated copies of the kit are
  rejected. Do not use the verify_offline.py copy inside an archive you have
  not authenticated yet.

  The published galenos-offline-kit.sha256 lists the same two digests. It,
  the verifier and the archive are served by the same site, so checking
  against it is also a transfer-integrity check only. The independent pins
  are the two SHA-256 values from the out-of-band release record.
  On an archive hash mismatch the verifier stops before tar parsing and extraction.
  python3 -I isolates Python imports only. It is not an operating-system
  sandbox.

portfolioRootSha256 of this kit
  f842457bbb0d67173fd61664905e190dea00abe63fb976ec8282f45f3b4fbe9f

Formulas
  portfolioRootSha256   = sha256(utf8(json.dumps(manifest['receipts'], sort_keys=True, separators=(',', ':'))))
  canonicalOutputSha256 = sha256(ascii(json.dumps(audit_json, sort_keys=True, separators=(',', ':'), ensure_ascii=True)))
  ledgerReceiptId       = 'cohort-' + package + '-' + canonicalOutputSha256[:12] + '-' + sha256(ascii(canonicalOutputSha256 + ':' + runFileSha256[package]))[:12]

  portfolioRootSha256 is NOT a hash over concatenated receipt hashes. It is the
  SHA-256 of the canonical JSON text of the whole manifest["receipts"] list:
  keys sorted, separators "," and ":", no whitespace, UTF-8 bytes.

What MATCH means, and what was pinned
  MATCH: the file, manifest receipt, canonical output, receipt ID and
  portfolio root digests were recomputed from the bytes in the kit and
  agreed, and the kit holds exactly the 20 expected files. That is internal
  consistency. The TRUST_ANCHOR line printed above the result states what was
  pinned from outside the kit:
    RELEASE_ARCHIVE_PINNED  --expect-archive-sha256 matched the whole archive.
                            Only this anchor covers every file in the kit.
    RECEIPT_SET_PINNED      --expect-root matched portfolioRootSha256. This
                            pins the receipt list only. README.txt, the
                            verifier, the dossier, the provenance manifest and
                            the other manifest fields are then checked by the
                            local SHA256SUMS only.
    NONE                    internal consistency only.
  --expect-archive-sha256 and --checksum-file are refused in directory mode
  (--kit-dir), because an extracted directory has no archive digest.
  The per-package run files are not in the kit. ledgerReceiptId is recomputed
  from their published SHA-256 digests (runFileSha256 in the manifest).
  The audits are computational research records on public cohorts. They are
  not clinical validation and carry no human auditor signature.

--------------------------------------------------------------------------

GALENOS 오프라인 검증 키트

먼저 인증하고, 그다음에 실행합니다
  아래 명령 한 줄은 내려받은 두 파일(galenos-offline-kit.tar,
  verify_offline.py)이 있는 폴더에서, 아카이브를 풀거나 그 안의 파일을
  실행하기 전에 실행하십시오. 변조된 아카이브에는 변조된 verify_offline.py가
  들어 있을 수 있고, 변조된 verify_offline.py는 어떤 결과든 출력할 수
  있습니다. 그래서 파이썬이 시작되기 전에 운영체제의 shasum 도구가 두 파일을
  고정된 SHA-256 값과 대조하고, 둘 다 일치할 때만 검증 스크립트가 실행됩니다.

  printf '%s  galenos-offline-kit.tar\n%s  verify_offline.py\n' '<ARCHIVE_SHA256>' 'ad57bb9ccd847a1fc6c3a763fc81c3f36b882bc5c8d77868bbcf0f43c1f63afc' | shasum -a 256 -c - && python3 -I verify_offline.py --archive galenos-offline-kit.tar --expect-archive-sha256 '<ARCHIVE_SHA256>'

  배포자 진위 확인의 전제 조건: 두 기대 SHA-256 값(galenos-offline-kit.tar,
  verify_offline.py)을 GALENOS 사이트와 따로 인증된 배포 경로(예: 감사된
  git 릴리스 커밋, 서명된 릴리스 기록)에서 받으십시오. 아카이브 값은
  <ARCHIVE_SHA256> 자리(두 곳)에 넣고, 검증 스크립트 값은 명령에 적힌
  값과 대조하십시오.
  GALENOS 서명 확인, 상태, 증거 페이지에는 두 해시를 모두 채운 같은 명령이
  있습니다. 그 해시는 두 파일과 같은 사이트에서 제공되므로, 그 값으로 명령을
  실행하는 것은 전송 무결성 확인일 뿐이며 배포자 인증이 아닙니다.
  이 릴리스의 verify_offline.py SHA-256:
  ad57bb9ccd847a1fc6c3a763fc81c3f36b882bc5c8d77868bbcf0f43c1f63afc
  --tamper-self-test를 붙이면 변조한 사본이 거부되는지도 확인합니다. 아직
  인증하지 않은 아카이브 안의 verify_offline.py 사본은 쓰지 마십시오.

  공개된 galenos-offline-kit.sha256에도 같은 두 해시가 적혀 있습니다. 이
  파일과 검증 스크립트, 아카이브는 같은 사이트에서 제공되므로 이 파일과의
  대조도 전송 무결성 확인일 뿐입니다. 독립된 고정값은 사이트 밖 릴리스
  기록에서 받은 두 SHA-256 값입니다. 아카이브 해시가 다르면 검증기는 tar 해석과
  압축 풀기 전에 멈춥니다.
  python3 -I는 파이썬 import 경로만 격리하며 운영체제 샌드박스가 아닙니다.

portfolioRootSha256 산출 규칙
  sha256(utf8(json.dumps(manifest['receipts'], sort_keys=True, separators=(',', ':'))))
  영수증 해시를 이어 붙여 해시한 값이 아닙니다. manifest["receipts"] 목록 전체를
  키 정렬, 구분자 "," 와 ":", 공백 없음 조건으로 직렬화한 JSON 문자열의
  UTF-8 바이트를 SHA-256으로 계산한 값입니다.

MATCH의 뜻과 고정 범위
  MATCH는 파일, 영수증, 정규 출력, 영수증 ID, 포트폴리오 루트 해시를 키트 안의
  바이트에서 다시 계산해 일치했고,
  키트가 정해진 20개 파일만 담고 있다는 뜻입니다. 이것은 내부 정합성입니다.
  결과 위에 출력되는 TRUST_ANCHOR 줄이 키트 바깥 값으로 무엇을 고정했는지
  알려 줍니다.
    RELEASE_ARCHIVE_PINNED  --expect-archive-sha256이 아카이브 전체와 일치.
                            키트의 모든 파일을 덮는 고정값은 이것뿐입니다.
    RECEIPT_SET_PINNED      --expect-root가 portfolioRootSha256과 일치.
                            영수증 목록만 고정합니다. README.txt, 검증
                            스크립트, 도시에, 출처 목록, 매니페스트의 다른
                            항목은 키트 안의 SHA256SUMS로만 확인됩니다.
    NONE                    내부 정합성만 확인.
  폴더 검증(--kit-dir)에서는 --expect-archive-sha256과 --checksum-file을
  받지 않습니다. 풀어 놓은 폴더에는 대조할 아카이브 해시가 없기 때문입니다.
  패키지별 run 파일은 키트에 없습니다. ledgerReceiptId는 매니페스트에 공개한
  run 파일 SHA-256(runFileSha256)으로 다시 계산합니다.
  감사 영수증은 공개 코호트에 대한 연구용 계산 기록이며, 임상 검증이 아니고
  사람 감사자 서명이 없습니다.
