跳到正文
DEV Community· Xianghua Feng·· 22 小時前AI 評分39

電錶故障來電:MPAN 格式驗證不等於核實來電者身份

Who called me about a faulty meter? Validating an identifier is not verifying it

AI 導讀

文章以電錶故障來電為例,説明 MPAN 格式驗證只能判斷號碼是否符合規則,不能證明號碼屬於用戶或來電者身份。MPAN 核心由 13 位數字組成,須與自有帳單比對,才知道是否為該電錶號碼;即使相符,仍不構成身份認證。遇上相關來電,應自行透過已知渠道聯絡供應商,並記錄來電頻次。

正文

A caller says your meter is faulty. Did they know which meter is yours? A call lookup can add context about the number, at best. The meter question is a data question, and it has a clean engineering answer: a value can be well-formed without being yours.

Affiliation and AI note: This is promotional editorial from the website whocallme.co.uk, drafted with AI assistance. The code below is an illustrative sketch that was run locally only to confirm it executes. It is not a product, and no real meter numbers were used.

The source note

The number page for 020 3917 8878 lists a landline, allocation hint Gamma Telecom Holdings Limited, numbering area London. Those labels describe a number range, not a caller. Caller ID can be spoofed, and the page does not identify who holds the number.

When fetched for this post the page showed nine searches, one user report and a "first seen: 6 days ago" page label. That label is not the date of the note. The note is imported and its original publication date is unknown. The visitor filed it as Scam/Fraud. That is their category, not an established fact.

The visitor wrote that the caller presented as "our supposed energy supplier British Gas" and said the household had "a faulty meter" that was "not giving accurate readings". The visitor asked for the meter's MPAN, and the caller "gave totally wrong number". The visitor pointed out that they submit readings online and that bills were being issued without a problem. They added: "This is the 3rd call in a 7days."

Nothing beyond that text is assumed here. Whether the caller had any link with the supplier named is unknown.

The visitor's move was a challenge, not a disclosure

Look at the direction of the question. The visitor did not read their MPAN out. They asked the caller to supply it, then compared the answer with what they already knew.

That is the right shape for this kind of check:

  • the claimant supplies a value;
  • you compare it with a record you obtained yourself;
  • nothing flows from you to them.

The reverse shape, where you recite your own identifier "so they can find the account", turns you into the lookup service. Any value you speak is now theirs.

Two different checks: validation and verification

An MPAN (Meter Point Administration Number) identifies an electricity supply point in Great Britain. Its last 13 digits are the core, and the final digit of the core is a check digit.

That gives us two separate tests, and it is worth keeping them apart in code:

  1. Validation: is the value well-formed? Right length, digits only, check digit consistent.
  2. Verification: is it the value on your own bill?

A failed validation means the caller's number could not be a real MPAN core as stated. A passed validation means very little on its own, because any well-formed number passes. Only verification against your own record says anything about your meter. And even a match is not authentication, since the number is printed on bills and is not a secret.

Gas supply points use a different identifier (the MPRN), so a check like this applies to electricity numbers only.

The check digit

The published algorithm multiplies the first 12 digits of the core by the primes 3, 5, 7, 13, 17, 19, 23, 29, 31, 37, 41 and 43 (11 is skipped). Sum the products, take the result modulo 11, then modulo 10. The answer should equal the 13th digit.

Here is a standard-library version with a comparison step:

PRIMES = (3, 5, 7, 13, 17, 19, 23, 29, 31, 37, 41, 43)

def normalise(raw: str) -> str:
    """Keep digits only; the core is the final 13 digits."""
    digits = "".join(ch for ch in raw if ch.isdigit())
    return digits[-13:]

def is_well_formed(core: str) -> bool:
    if len(core) != 13 or not core.isdigit():
        return False
    total = sum(int(d) * p for d, p in zip(core[:12], PRIMES))
    return total % 11 % 10 == int(core[12])

def compare(offered: str, on_file: str) -> str:
    o, f = normalise(offered), normalise(on_file)
    if not is_well_formed(o):
        return "mismatch: offered value is not a well-formed core"
    if o != f:
        return "mismatch: well-formed, but not the value on your bill"
    return "match: consistent, still not proof of identity"

And a run with made-up values. The distributor prefix 99 is used deliberately so nothing here resembles a real supply point:

on_file = "99 0000 0123 454"               # typed from your own bill
print(compare("9900000123455", on_file))   # bad check digit
print(compare("9900000678906", on_file))   # well-formed, different
print(compare("S 01 801 101 99 0000 0123 454", on_file))

Output:

mismatch: offered value is not a well-formed core
mismatch: well-formed, but not the value on your bill
match: consistent, still not proof of identity

Notice that the first two results lead to the same decision. Whether the offered number is malformed or simply belongs to someone else, it does not match your meter. The distinction is useful for logging, not for trusting.

Why a match still isn't authentication

It is tempting to treat the third branch as "verified". Resist that. An identifier that appears on every paper bill can be known by many people. A correct value raises the chance that a caller has some data about you. It does not show that they are your supplier.

So the decision table stays one-sided:

Result What it tells you What to do
malformed caller's value can't be an MPAN core end the call, record it
well-formed, different not your meter end the call, record it
match caller has data you also have still contact the supplier via your own account

Every branch ends in the same safe action: any real meter issue is raised through a channel you open yourself.

A record that captures frequency

The visitor's last line, three calls in seven days, is a data point that usually gets lost. A minimal record keeps it:

- reviewed_on: 2026-11-21        # the day you wrote this, not a call date
  number_shown: "020 3917 8878"
  claim: "faulty meter, inaccurate readings"
  identifier_requested_from_caller: MPAN
  identifier_check: mismatch   # the note does not say which kind
  disclosed_by_me: none
  calls_in_window: {count: 3, days: 7}
  follow_up: "raise any meter question via own supplier login"

Keep disclosed_by_me honest. If it ever reads anything other than "none", the next step is to contact the supplier through your own login.

Where a lookup fits

The number page is context for the claim field. The visitor note about a faulty-meter call shows that one other person heard this pitch from the displayed number. It is anonymous and unverified, and it does not tie the line to any supplier.

If you log calls like this regularly, a quick reference of UK numbers with visitor reports can help fill in context before you write a record. The rule from the code still holds. Ask the caller for the value, compare it locally, and give nothing back.

來源:DEV Community · dev.to